mirror of
https://github.com/X11Libre/xserver.git
synced 2026-10-15 00:13:28 +00:00
Merge accel_indirect branch to HEAD.
This commit is contained in:
parent
b1b731c286
commit
c3342c8000
52 changed files with 2718 additions and 3942 deletions
|
|
@ -630,7 +630,7 @@ AOUT_GetSymbols(AOUTModulePtr aoutfile)
|
|||
* Public API for the a.out implementation of the loader
|
||||
*/
|
||||
void *
|
||||
AOUTLoadModule(loaderPtr modrec, int aoutfd, LOOKUP ** ppLookup)
|
||||
AOUTLoadModule(loaderPtr modrec, int aoutfd, LOOKUP ** ppLookup, int flags)
|
||||
{
|
||||
AOUTModulePtr aoutfile = NULL;
|
||||
AOUTHDR *header;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#ifndef _AOUTLOADER_H
|
||||
#define _AOUTLOADER_H
|
||||
extern void *AOUTLoadModule(loaderPtr, int, LOOKUP **);
|
||||
extern void *AOUTLoadModule(loaderPtr, int, LOOKUP **, int flags);
|
||||
extern void AOUTResolveSymbols(void *);
|
||||
extern int AOUTCheckForUnresolved(void *);
|
||||
extern char *AOUTAddressToSection(void *, unsigned long);
|
||||
|
|
|
|||
|
|
@ -1149,7 +1149,7 @@ COFFCollectSections(COFFModulePtr cofffile)
|
|||
* Public API for the COFF implementation of the loader.
|
||||
*/
|
||||
void *
|
||||
COFFLoadModule(loaderPtr modrec, int cofffd, LOOKUP **ppLookup)
|
||||
COFFLoadModule(loaderPtr modrec, int cofffd, LOOKUP **ppLookup, int flags)
|
||||
{
|
||||
COFFModulePtr cofffile;
|
||||
FILHDR *header;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#ifndef _COFFLOADER_H
|
||||
#define _COFFLOADER_H
|
||||
/* coffloader.c */
|
||||
extern void *COFFLoadModule(loaderPtr, int, LOOKUP **);
|
||||
extern void *COFFLoadModule(loaderPtr, int, LOOKUP **, int flags);
|
||||
extern void COFFResolveSymbols(void *);
|
||||
extern int COFFCheckForUnresolved(void *);
|
||||
extern char *COFFAddressToSection(void *, unsigned long);
|
||||
|
|
|
|||
|
|
@ -63,8 +63,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#define DLOPEN_FLAGS ( DLOPEN_LAZY | DLOPEN_GLOBAL )
|
||||
|
||||
#if defined(CSRG_BASED) && !defined(__ELF__)
|
||||
#define NEED_UNDERSCORE_FOR_DLLSYM
|
||||
#endif
|
||||
|
|
@ -76,6 +74,7 @@
|
|||
typedef struct {
|
||||
int handle;
|
||||
void *dlhandle;
|
||||
int flags;
|
||||
} DLModuleRec, *DLModulePtr;
|
||||
|
||||
/*
|
||||
|
|
@ -88,6 +87,28 @@ typedef struct DLModuleList {
|
|||
|
||||
DLModuleList *dlModuleList = NULL;
|
||||
|
||||
void *
|
||||
DLFindSymbolLocal(pointer module, const char *name)
|
||||
{
|
||||
DLModulePtr dlfile = module;
|
||||
void *p;
|
||||
char *n;
|
||||
|
||||
#ifdef NEED_UNDERSCORE_FOR_DLLSYM
|
||||
static const char symPrefix[] = "_";
|
||||
#else
|
||||
static const char symPrefix[] = "";
|
||||
#endif
|
||||
|
||||
n = xf86loadermalloc(strlen(symPrefix) + strlen(name) + 1);
|
||||
sprintf(n, "%s%s", symPrefix, name);
|
||||
p = dlsym(dlfile->dlhandle, n);
|
||||
xf86loaderfree(n);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Search a symbol in the module list
|
||||
*/
|
||||
|
|
@ -97,30 +118,11 @@ DLFindSymbol(const char *name)
|
|||
DLModuleList *l;
|
||||
void *p;
|
||||
|
||||
#ifdef NEED_UNDERSCORE_FOR_DLLSYM
|
||||
char *n;
|
||||
|
||||
n = xf86loadermalloc(strlen(name) + 2);
|
||||
sprintf(n, "_%s", name);
|
||||
#endif
|
||||
|
||||
(void)dlerror(); /* Clear out any previous error */
|
||||
for (l = dlModuleList; l != NULL; l = l->next) {
|
||||
#ifdef NEED_UNDERSCORE_FOR_DLLSYM
|
||||
p = dlsym(l->module->dlhandle, n);
|
||||
#else
|
||||
p = dlsym(l->module->dlhandle, name);
|
||||
#endif
|
||||
if (dlerror() == NULL) {
|
||||
#ifdef NEED_UNDERSCORE_FOR_DLLSYM
|
||||
xf86loaderfree(n);
|
||||
#endif
|
||||
p = DLFindSymbolLocal(l->module, name);
|
||||
if (p)
|
||||
return p;
|
||||
}
|
||||
}
|
||||
#ifdef NEED_UNDERSCORE_FOR_DLLSYM
|
||||
xf86loaderfree(n);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -129,23 +131,28 @@ DLFindSymbol(const char *name)
|
|||
* public interface
|
||||
*/
|
||||
void *
|
||||
DLLoadModule(loaderPtr modrec, int fd, LOOKUP ** ppLookup)
|
||||
DLLoadModule(loaderPtr modrec, int fd, LOOKUP ** ppLookup, int flags)
|
||||
{
|
||||
DLModulePtr dlfile;
|
||||
DLModuleList *l;
|
||||
int dlopen_flags;
|
||||
|
||||
if ((dlfile = xf86loadercalloc(1, sizeof(DLModuleRec))) == NULL) {
|
||||
ErrorF("Unable to allocate DLModuleRec\n");
|
||||
return NULL;
|
||||
}
|
||||
dlfile->handle = modrec->handle;
|
||||
dlfile->dlhandle = dlopen(modrec->name, DLOPEN_FLAGS);
|
||||
if (flags & LD_FLAG_GLOBAL)
|
||||
dlopen_flags = DLOPEN_LAZY | DLOPEN_GLOBAL;
|
||||
else
|
||||
dlopen_flags = DLOPEN_LAZY;
|
||||
dlfile->dlhandle = dlopen(modrec->name, dlopen_flags);
|
||||
if (dlfile->dlhandle == NULL) {
|
||||
ErrorF("dlopen: %s\n", dlerror());
|
||||
xf86loaderfree(dlfile);
|
||||
return NULL;
|
||||
}
|
||||
/* Add it to the module list */
|
||||
|
||||
l = xf86loadermalloc(sizeof(DLModuleList));
|
||||
l->module = dlfile;
|
||||
l->next = dlModuleList;
|
||||
|
|
|
|||
|
|
@ -27,10 +27,11 @@
|
|||
|
||||
#ifndef _DLLOADER_H
|
||||
#define _DLLOADER_H
|
||||
extern void *DLLoadModule(loaderPtr, int, LOOKUP **);
|
||||
extern void *DLLoadModule(loaderPtr, int, LOOKUP **, int flags);
|
||||
extern void DLResolveSymbols(void *);
|
||||
extern int DLCheckForUnresolved(void *);
|
||||
extern void DLUnloadModule(void *);
|
||||
extern void *DLFindSymbol(const char *name);
|
||||
extern void *DLFindSymbolLocal(pointer module, const char *name);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* $XdotOrg: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.7 2005/04/23 19:01:13 ajax Exp $ */
|
||||
/* $XdotOrg: xserver/xorg/hw/xfree86/loader/elfloader.c,v 1.10.12.1 2006/02/24 05:49:34 krh Exp $ */
|
||||
/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.61tsi Exp $ */
|
||||
|
||||
/*
|
||||
|
|
@ -2884,7 +2884,7 @@ ELFCollectSections(ELFModulePtr elffile, int pass, int *totalsize,
|
|||
* Public API for the ELF implementation of the loader.
|
||||
*/
|
||||
void *
|
||||
ELFLoadModule(loaderPtr modrec, int elffd, LOOKUP **ppLookup)
|
||||
ELFLoadModule(loaderPtr modrec, int elffd, LOOKUP **ppLookup, int flags)
|
||||
{
|
||||
ELFModulePtr elffile;
|
||||
Elf_Ehdr *header;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#ifndef _ELFLOADER_H
|
||||
#define _ELFLOADER_H
|
||||
/* elfloader.c */
|
||||
extern void *ELFLoadModule(loaderPtr, int, LOOKUP **);
|
||||
extern void *ELFLoadModule(loaderPtr, int, LOOKUP **, int flags);
|
||||
extern void ELFResolveSymbols(void *);
|
||||
extern int ELFCheckForUnresolved(void *);
|
||||
extern char *ELFAddressToSection(void *, unsigned long);
|
||||
|
|
|
|||
|
|
@ -973,7 +973,7 @@ _LoaderHandleUnresolved(char *symbol, char *module)
|
|||
* Handle an archive.
|
||||
*/
|
||||
void *
|
||||
ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP ** ppLookup)
|
||||
ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP ** ppLookup, int flags)
|
||||
{
|
||||
loaderPtr tmp = NULL;
|
||||
void *ret = NULL;
|
||||
|
|
@ -1171,7 +1171,7 @@ ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP ** ppLookup)
|
|||
}
|
||||
offsetbias = offset;
|
||||
|
||||
if ((tmp->private = funcs[modtype].LoadModule(tmp, arfd, &lookup_ret))
|
||||
if ((tmp->private = funcs[modtype].LoadModule(tmp, arfd, &lookup_ret, LD_FLAG_GLOBAL))
|
||||
== NULL) {
|
||||
ErrorF("Failed to load %s\n", hdr.ar_name);
|
||||
offsetbias = 0;
|
||||
|
|
@ -1233,13 +1233,14 @@ _LoaderGetRelocations(void *mod)
|
|||
return &(formatrec->pRelocs);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Public Interface to the loader.
|
||||
*/
|
||||
|
||||
int
|
||||
LoaderOpen(const char *module, const char *cname, int handle,
|
||||
int *errmaj, int *errmin, int *wasLoaded)
|
||||
int *errmaj, int *errmin, int *wasLoaded, int flags)
|
||||
{
|
||||
loaderPtr tmp;
|
||||
int new_handle, modtype;
|
||||
|
|
@ -1329,7 +1330,7 @@ LoaderOpen(const char *module, const char *cname, int handle,
|
|||
tmp->module = moduleseq++;
|
||||
tmp->funcs = &funcs[modtype];
|
||||
|
||||
if ((tmp->private = funcs[modtype].LoadModule(tmp, fd, &pLookup)) == NULL) {
|
||||
if ((tmp->private = funcs[modtype].LoadModule(tmp, fd, &pLookup, flags)) == NULL) {
|
||||
xf86Msg(X_ERROR, "Failed to load %s\n", module);
|
||||
_LoaderListPop(new_handle);
|
||||
freeHandles[new_handle] = HANDLE_FREE;
|
||||
|
|
|
|||
|
|
@ -80,6 +80,11 @@
|
|||
#define LD_PROCESSED_ARCHIVE -1
|
||||
/* #define UNINIT_SECTION */
|
||||
#define HANDLE_IN_HASH_ENTRY
|
||||
|
||||
/* LoadModule proc flags; LD_FLAG_GLOBAL adds symbols to global
|
||||
* namespace, default is to keep symbols local to module. */
|
||||
#define LD_FLAG_GLOBAL 1
|
||||
|
||||
/*
|
||||
* COFF Section nmumbers
|
||||
*/
|
||||
|
|
@ -193,7 +198,7 @@ typedef struct _loader *loaderPtr;
|
|||
* _loader_funcs hold the entry points for a module format.
|
||||
*/
|
||||
|
||||
typedef void *(*LoadModuleProcPtr) (loaderPtr modrec, int fd, LOOKUP **);
|
||||
typedef void *(*LoadModuleProcPtr) (loaderPtr modrec, int fd, LOOKUP **, int flags);
|
||||
typedef void (*ResolveSymbolsProcPtr) (void *);
|
||||
typedef int (*CheckForUnresolvedProcPtr) (void *);
|
||||
typedef char *(*AddressToSectionProcPtr) (void *, unsigned long);
|
||||
|
|
@ -256,7 +261,7 @@ void LoaderDumpSymbols(void);
|
|||
char *_LoaderModuleToName(int);
|
||||
int _LoaderAddressToSection(const unsigned long, const char **,
|
||||
const char **);
|
||||
int LoaderOpen(const char *, const char *, int, int *, int *, int *);
|
||||
int LoaderOpen(const char *, const char *, int, int *, int *, int *, int);
|
||||
int LoaderHandleOpen(int);
|
||||
|
||||
/*
|
||||
|
|
@ -285,7 +290,7 @@ char *_LoaderHandleToCanonicalName(int handle);
|
|||
#include "elfloader.h"
|
||||
#include "dlloader.h"
|
||||
/* LD_ARCHIVE */
|
||||
void *ARCHIVELoadModule(loaderPtr, int, LOOKUP **);
|
||||
void *ARCHIVELoadModule(loaderPtr, int, LOOKUP **, int flags);
|
||||
|
||||
extern void _loader_debug_state(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,10 @@ ModuleDescPtr LoadModule(const char *, const char *, const char **,
|
|||
ModuleDescPtr LoadSubModule(ModuleDescPtr, const char *,
|
||||
const char **, const char **, pointer,
|
||||
const XF86ModReqInfo *, int *, int *);
|
||||
ModuleDescPtr LoadSubModuleLocal(ModuleDescPtr, const char *,
|
||||
const char **, const char **,
|
||||
pointer, const XF86ModReqInfo *,
|
||||
int *, int *);
|
||||
ModuleDescPtr DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent);
|
||||
void LoadFont(FontModule *);
|
||||
void UnloadModule(ModuleDescPtr);
|
||||
|
|
|
|||
|
|
@ -88,6 +88,10 @@ static Bool CheckVersion(const char *, XF86ModuleVersionInfo *,
|
|||
static void UnloadModuleOrDriver(ModuleDescPtr mod);
|
||||
static char *LoaderGetCanonicalName(const char *, PatternPtr);
|
||||
static void RemoveChild(ModuleDescPtr);
|
||||
static ModuleDescPtr doLoadModule(const char *, const char *, const char **,
|
||||
const char **, pointer,
|
||||
const XF86ModReqInfo *, int *, int *,
|
||||
int flags);
|
||||
|
||||
ModuleVersions LoaderVersionInfo = {
|
||||
XORG_VERSION_CURRENT,
|
||||
|
|
@ -782,8 +786,44 @@ LoadSubModule(ModuleDescPtr parent, const char *module,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
submod = LoadModule(module, NULL, subdirlist, patternlist, options,
|
||||
modreq, errmaj, errmin);
|
||||
submod = doLoadModule(module, NULL, subdirlist, patternlist, options,
|
||||
modreq, errmaj, errmin, LD_FLAG_GLOBAL);
|
||||
if (submod) {
|
||||
parent->child = AddSibling(parent->child, submod);
|
||||
submod->parent = parent;
|
||||
}
|
||||
return submod;
|
||||
}
|
||||
|
||||
ModuleDescPtr
|
||||
LoadSubModuleLocal(ModuleDescPtr parent, const char *module,
|
||||
const char **subdirlist, const char **patternlist,
|
||||
pointer options, const XF86ModReqInfo * modreq,
|
||||
int *errmaj, int *errmin)
|
||||
{
|
||||
ModuleDescPtr submod;
|
||||
|
||||
xf86MsgVerb(X_INFO, 3, "Loading local sub module \"%s\"\n", module);
|
||||
|
||||
/* Absolute module paths are not allowed here */
|
||||
#ifndef __UNIXOS2__
|
||||
if (module[0] == '/')
|
||||
#else
|
||||
if (isalpha(module[0]) && module[1] == ':' && module[2] == '/')
|
||||
#endif
|
||||
{
|
||||
xf86Msg(X_ERROR,
|
||||
"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
|
||||
module);
|
||||
if (errmaj)
|
||||
*errmaj = LDR_BADUSAGE;
|
||||
if (errmin)
|
||||
*errmin = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
submod = doLoadModule(module, NULL, subdirlist, patternlist, options,
|
||||
modreq, errmaj, errmin, 0);
|
||||
if (submod) {
|
||||
parent->child = AddSibling(parent->child, submod);
|
||||
submod->parent = parent;
|
||||
|
|
@ -823,48 +863,12 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* LoadModule: load a module
|
||||
*
|
||||
* module The module name. Normally this is not a filename but the
|
||||
* module's "canonical name. A full pathname is, however,
|
||||
* also accepted.
|
||||
* path A comma separated list of module directories.
|
||||
* subdirlist A NULL terminated list of subdirectories to search. When
|
||||
* NULL, the default "stdSubdirs" list is used. The default
|
||||
* list is also substituted for entries with value DEFAULT_LIST.
|
||||
* patternlist A NULL terminated list of regular expressions used to find
|
||||
* module filenames. Each regex should contain exactly one
|
||||
* subexpression that corresponds to the canonical module name.
|
||||
* When NULL, the default "stdPatterns" list is used. The
|
||||
* default list is also substituted for entries with value
|
||||
* DEFAULT_LIST.
|
||||
* options A NULL terminated list of Options that are passed to the
|
||||
* module's SetupProc function.
|
||||
* modreq An optional XF86ModReqInfo* containing
|
||||
* version/ABI/vendor-ABI requirements to check for when
|
||||
* loading the module. The following fields of the
|
||||
* XF86ModReqInfo struct are checked:
|
||||
* majorversion - must match the module's majorversion exactly
|
||||
* minorversion - the module's minorversion must be >= this
|
||||
* patchlevel - the module's minorversion.patchlevel must be
|
||||
* >= this. Patchlevel is ignored when
|
||||
* minorversion is not set.
|
||||
* abiclass - (string) must match the module's abiclass
|
||||
* abiversion - must be consistent with the module's
|
||||
* abiversion (major equal, minor no older)
|
||||
* moduleclass - string must match the module's moduleclass
|
||||
* string
|
||||
* "don't care" values are ~0 for numbers, and NULL for strings
|
||||
* errmaj Major error return.
|
||||
* errmin Minor error return.
|
||||
*
|
||||
*/
|
||||
|
||||
ModuleDescPtr
|
||||
LoadModule(const char *module, const char *path, const char **subdirlist,
|
||||
const char **patternlist, pointer options,
|
||||
const XF86ModReqInfo * modreq, int *errmaj, int *errmin)
|
||||
static ModuleDescPtr
|
||||
doLoadModule(const char *module, const char *path, const char **subdirlist,
|
||||
const char **patternlist, pointer options,
|
||||
const XF86ModReqInfo * modreq,
|
||||
int *errmaj, int *errmin, int flags)
|
||||
{
|
||||
XF86ModuleData *initdata = NULL;
|
||||
char **pathlist = NULL;
|
||||
|
|
@ -957,7 +961,8 @@ LoadModule(const char *module, const char *path, const char **subdirlist,
|
|||
*errmin = 0;
|
||||
goto LoadModule_fail;
|
||||
}
|
||||
ret->handle = LoaderOpen(found, name, 0, errmaj, errmin, &wasLoaded);
|
||||
ret->handle = LoaderOpen(found, name, 0,
|
||||
errmaj, errmin, &wasLoaded, flags);
|
||||
if (ret->handle < 0)
|
||||
goto LoadModule_fail;
|
||||
|
||||
|
|
@ -1066,6 +1071,52 @@ LoadModule(const char *module, const char *path, const char **subdirlist,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* LoadModule: load a module
|
||||
*
|
||||
* module The module name. Normally this is not a filename but the
|
||||
* module's "canonical name. A full pathname is, however,
|
||||
* also accepted.
|
||||
* path A comma separated list of module directories.
|
||||
* subdirlist A NULL terminated list of subdirectories to search. When
|
||||
* NULL, the default "stdSubdirs" list is used. The default
|
||||
* list is also substituted for entries with value DEFAULT_LIST.
|
||||
* patternlist A NULL terminated list of regular expressions used to find
|
||||
* module filenames. Each regex should contain exactly one
|
||||
* subexpression that corresponds to the canonical module name.
|
||||
* When NULL, the default "stdPatterns" list is used. The
|
||||
* default list is also substituted for entries with value
|
||||
* DEFAULT_LIST.
|
||||
* options A NULL terminated list of Options that are passed to the
|
||||
* module's SetupProc function.
|
||||
* modreq An optional XF86ModReqInfo* containing
|
||||
* version/ABI/vendor-ABI requirements to check for when
|
||||
* loading the module. The following fields of the
|
||||
* XF86ModReqInfo struct are checked:
|
||||
* majorversion - must match the module's majorversion exactly
|
||||
* minorversion - the module's minorversion must be >= this
|
||||
* patchlevel - the module's minorversion.patchlevel must be
|
||||
* >= this. Patchlevel is ignored when
|
||||
* minorversion is not set.
|
||||
* abiclass - (string) must match the module's abiclass
|
||||
* abiversion - must be consistent with the module's
|
||||
* abiversion (major equal, minor no older)
|
||||
* moduleclass - string must match the module's moduleclass
|
||||
* string
|
||||
* "don't care" values are ~0 for numbers, and NULL for strings
|
||||
* errmaj Major error return.
|
||||
* errmin Minor error return.
|
||||
*
|
||||
*/
|
||||
ModuleDescPtr
|
||||
LoadModule(const char *module, const char *path, const char **subdirlist,
|
||||
const char **patternlist, pointer options,
|
||||
const XF86ModReqInfo * modreq, int *errmaj, int *errmin)
|
||||
{
|
||||
return doLoadModule(module, path, subdirlist, patternlist, options,
|
||||
modreq, errmaj, errmin, LD_FLAG_GLOBAL);
|
||||
}
|
||||
|
||||
ModuleDescPtr
|
||||
LoadDriver(const char *module, const char *path, int handle, pointer options,
|
||||
int *errmaj, int *errmin)
|
||||
|
|
|
|||
Loading…
Reference in a new issue