diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2006-08-10 10:37:59 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2006-08-10 10:37:59 -0700 |
commit | c2535f67923bde0bfb0e72363467110806e2f40f (patch) | |
tree | 86e27df1edccb7318a378a25c1a74c212d10ce85 /hw/xfree86/loader | |
parent | c0cb8d1fb80540e093da54da3ee2f55bdf139274 (diff) | |
parent | db82e12fac5eaa16a39fc1bd0bc31ad95089dc95 (diff) |
Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into XACE-modular
Diffstat (limited to 'hw/xfree86/loader')
-rw-r--r-- | hw/xfree86/loader/Makefile.am | 3 | ||||
-rw-r--r-- | hw/xfree86/loader/dixsym.c | 1 | ||||
-rw-r--r-- | hw/xfree86/loader/dlloader.c | 10 | ||||
-rw-r--r-- | hw/xfree86/loader/dlloader.h | 2 | ||||
-rw-r--r-- | hw/xfree86/loader/loader.c | 181 | ||||
-rw-r--r-- | hw/xfree86/loader/loader.h | 1 | ||||
-rw-r--r-- | hw/xfree86/loader/loaderProcs.h | 7 | ||||
-rw-r--r-- | hw/xfree86/loader/loadmod.c | 137 | ||||
-rw-r--r-- | hw/xfree86/loader/os.c | 6 | ||||
-rw-r--r-- | hw/xfree86/loader/xf86sym.c | 9 |
10 files changed, 94 insertions, 263 deletions
diff --git a/hw/xfree86/loader/Makefile.am b/hw/xfree86/loader/Makefile.am index 0cda5c159..030672389 100644 --- a/hw/xfree86/loader/Makefile.am +++ b/hw/xfree86/loader/Makefile.am @@ -5,7 +5,7 @@ INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(srcdir)/../dixmods/extmod \ -I$(srcdir)/../ddc -I$(srcdir)/../i2c #AM_LDFLAGS = -r -AM_CFLAGS = -DIN_LOADER $(XORG_CFLAGS) @SERVER_DEFINES@ @LOADER_DEFINES@ +AM_CFLAGS = -DIN_LOADER $(XORG_CFLAGS) if XORG_LOADER_SPARC SPARC_SOURCES = SparcMulDiv.S @@ -30,4 +30,5 @@ libloader_a_SOURCES = \ fontsym.c \ misym.c \ xf86sym.c \ + sym.h \ $(SPARC_SOURCES) diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c index 0963bef15..043c1a705 100644 --- a/hw/xfree86/loader/dixsym.c +++ b/hw/xfree86/loader/dixsym.c @@ -244,7 +244,6 @@ _X_HIDDEN void *dixLookupTab[] = { SYMVAR(globalSerialNumber) SYMVAR(lastDeviceEventTime) SYMVAR(monitorResolution) - SYMVAR(permitOldBugs) SYMVAR(screenInfo) SYMVAR(serverClient) SYMVAR(serverGeneration) diff --git a/hw/xfree86/loader/dlloader.c b/hw/xfree86/loader/dlloader.c index 3c62f863b..a0e867056 100644 --- a/hw/xfree86/loader/dlloader.c +++ b/hw/xfree86/loader/dlloader.c @@ -105,6 +105,8 @@ DLFindSymbolLocal(pointer module, const char *name) return p; } +static void *global_scope = NULL; + void * DLFindSymbol(const char *name) { @@ -117,11 +119,17 @@ DLFindSymbol(const char *name) return p; } + if (!global_scope) + global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL); + + if (global_scope) + return dlsym(global_scope, name); + return NULL; } void * -DLLoadModule(loaderPtr modrec, int fd, int flags) +DLLoadModule(loaderPtr modrec, int flags) { DLModulePtr dlfile; DLModuleList *l; diff --git a/hw/xfree86/loader/dlloader.h b/hw/xfree86/loader/dlloader.h index b705a18d0..8ae610f02 100644 --- a/hw/xfree86/loader/dlloader.h +++ b/hw/xfree86/loader/dlloader.h @@ -26,7 +26,7 @@ #ifndef _DLLOADER_H #define _DLLOADER_H -extern void *DLLoadModule(loaderPtr, int, int flags); +extern void *DLLoadModule(loaderPtr, int flags); extern void DLUnloadModule(void *); extern void *DLFindSymbol(const char *name); diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c index a5c5b2c8e..ddd624c2a 100644 --- a/hw/xfree86/loader/loader.c +++ b/hw/xfree86/loader/loader.c @@ -97,22 +97,6 @@ static int refCount[MAX_HANDLE]; */ static int moduleseq = 0; -typedef struct { - int num; - const char **list; -} symlist; - -/* - * List of symbols that may be referenced, and which are allowed to be - * unresolved providing that they don't appear on the "reqired" list. - */ -static symlist refList = { 0, NULL }; - -/* List of symbols that must not be unresolved */ -static symlist reqList = { 0, NULL }; - -static int fatalReqSym = 0; - /* Prototypes for static functions. */ static loaderPtr _LoaderListPush(void); static loaderPtr _LoaderListPop(int); @@ -300,165 +284,25 @@ _LoaderModuleToName(int module) return 0; } -/* - * Add a list of symbols to the referenced list. - */ - -static void -AppendSymbol(symlist * list, const char *sym) -{ - list->list = xnfrealloc(list->list, (list->num + 1) * sizeof(char **)); - /* copy the symbol, since it comes from a module - that can be unloaded later */ - list->list[list->num] = xnfstrdup(sym); - list->num++; -} - -static void -AppendSymList(symlist * list, const char **syms) -{ - while (*syms) { - AppendSymbol(list, *syms); - syms++; - } -} - -static int -SymInList(symlist * list, char *sym) -{ - int i; - - for (i = 0; i < list->num; i++) - if (strcmp(list->list[i], sym) == 0) - return 1; - - return 0; -} - -void -LoaderVRefSymbols(const char *sym0, va_list args) -{ - const char *s; - - if (sym0 == NULL) - return; - - s = sym0; - do { - AppendSymbol(&refList, s); - s = va_arg(args, const char *); - } while (s != NULL); -} - +/* These four are just ABI stubs */ _X_EXPORT void LoaderRefSymbols(const char *sym0, ...) { - va_list ap; - - va_start(ap, sym0); - LoaderVRefSymbols(sym0, ap); - va_end(ap); -} - -void -LoaderVRefSymLists(const char **list0, va_list args) -{ - const char **l; - - if (list0 == NULL) - return; - - l = list0; - do { - AppendSymList(&refList, l); - l = va_arg(args, const char **); - } while (l != NULL); } _X_EXPORT void LoaderRefSymLists(const char **list0, ...) { - va_list ap; - - va_start(ap, list0); - LoaderVRefSymLists(list0, ap); - va_end(ap); -} - -void -LoaderVReqSymLists(const char **list0, va_list args) -{ - const char **l; - - if (list0 == NULL) - return; - - l = list0; - do { - AppendSymList(&reqList, l); - l = va_arg(args, const char **); - } while (l != NULL); } _X_EXPORT void LoaderReqSymLists(const char **list0, ...) { - va_list ap; - - va_start(ap, list0); - LoaderVReqSymLists(list0, ap); - va_end(ap); -} - -void -LoaderVReqSymbols(const char *sym0, va_list args) -{ - const char *s; - - if (sym0 == NULL) - return; - - s = sym0; - do { - AppendSymbol(&reqList, s); - s = va_arg(args, const char *); - } while (s != NULL); } _X_EXPORT void LoaderReqSymbols(const char *sym0, ...) { - va_list ap; - - va_start(ap, sym0); - LoaderVReqSymbols(sym0, ap); - va_end(ap); -} - -/* - * _LoaderHandleUnresolved() decides what to do with an unresolved - * symbol. Symbols that are not on the "referenced" or "required" lists - * get a warning if they are unresolved. Symbols that are on the "required" - * list generate a fatal error if they are unresolved. - */ - -int -_LoaderHandleUnresolved(char *symbol, char *module) -{ - int fatalsym = 0; - - if (xf86ShowUnresolved && !fatalsym) { - if (SymInList(&reqList, symbol)) { - fatalReqSym = 1; - ErrorF("Required symbol %s from module %s is unresolved!\n", - symbol, module); - } - if (!SymInList(&refList, symbol)) { - ErrorF("Symbol %s from module %s is unresolved!\n", - symbol, module); - } - } - return (fatalsym); } /* Public Interface to the loader. */ @@ -469,7 +313,6 @@ LoaderOpen(const char *module, const char *cname, int handle, { loaderPtr tmp; int new_handle; - int fd; #if defined(DEBUG) ErrorF("LoaderOpen(%s)\n", module); @@ -525,16 +368,6 @@ LoaderOpen(const char *module, const char *cname, int handle, freeHandles[new_handle] = HANDLE_USED; refCount[new_handle] = 1; - if ((fd = open(module, O_RDONLY)) < 0) { - xf86Msg(X_ERROR, "Unable to open %s\n", module); - freeHandles[new_handle] = HANDLE_FREE; - if (errmaj) - *errmaj = LDR_NOMODOPEN; - if (errmin) - *errmin = errno; - return -1; - } - tmp = _LoaderListPush(); tmp->name = malloc(strlen(module) + 1); strcpy(tmp->name, module); @@ -543,7 +376,7 @@ LoaderOpen(const char *module, const char *cname, int handle, tmp->handle = new_handle; tmp->module = moduleseq++; - if ((tmp->private = DLLoadModule(tmp, fd, flags)) == NULL) { + if ((tmp->private = DLLoadModule(tmp, flags)) == NULL) { xf86Msg(X_ERROR, "Failed to load %s\n", module); _LoaderListPop(new_handle); freeHandles[new_handle] = HANDLE_FREE; @@ -554,8 +387,6 @@ LoaderOpen(const char *module, const char *cname, int handle, return -1; } - close(fd); - return new_handle; } @@ -578,15 +409,11 @@ LoaderSymbol(const char *sym) return (DLFindSymbol(sym)); } +/* more stub */ _X_EXPORT int LoaderCheckUnresolved(int delay_flag) { - int ret = 0; - - if (fatalReqSym) - FatalError("Some required symbols were unresolved\n"); - - return ret; + return 0; } int diff --git a/hw/xfree86/loader/loader.h b/hw/xfree86/loader/loader.h index c0913849d..46d4c3ed3 100644 --- a/hw/xfree86/loader/loader.h +++ b/hw/xfree86/loader/loader.h @@ -92,7 +92,6 @@ extern unsigned long LoaderOptions; /* Internal Functions */ void LoaderDuplicateSymbol(const char *, const int); -int _LoaderHandleUnresolved(char *, char *); char *_LoaderModuleToName(int); int LoaderOpen(const char *, const char *, int, int *, int *, int *, int); int LoaderHandleOpen(int); diff --git a/hw/xfree86/loader/loaderProcs.h b/hw/xfree86/loader/loaderProcs.h index 0e77e6b3a..ecbd6762d 100644 --- a/hw/xfree86/loader/loaderProcs.h +++ b/hw/xfree86/loader/loaderProcs.h @@ -103,13 +103,6 @@ ModuleDescPtr AddSibling(ModuleDescPtr head, ModuleDescPtr new); void LoaderSetPath(const char *path); void LoaderSortExtensions(void); -void LoaderVReqSymLists(const char **, va_list args); -void LoaderVReqSymbols(const char *, va_list args); -void LoaderVRefSymLists(const char **, va_list args); -void LoaderVRefSymbols(const char *, va_list args); - -void LoaderShowStack(void); -void *LoaderSymbolHandle(const char *, int); int LoaderUnload(int); unsigned long LoaderGetModuleVersion(ModuleDescPtr mod); diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index fd84a924c..12f5dc9cc 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -115,6 +115,17 @@ FreeStringList(char **paths) static char **defaultPathList = NULL; +static Bool +PathIsAbsolute(const char *path) +{ +#ifdef __UNIXOS2__ + return (*path == '/' || (strlen(path) > 2 && isalpha(elem[0]) && + elem[1] == ':' && elem[2] == '/')); +#else + return (*path == '/'); +#endif +} + /* * Convert a comma-separated path into a NULL-terminated array of path * elements, rejecting any that are not full absolute paths, and appending @@ -138,13 +149,7 @@ InitPathList(const char *path) return NULL; elem = strtok(fullpath, ","); while (elem) { - /* Only allow fully specified paths */ -#ifndef __UNIXOS2__ - if (*elem == '/') -#else - if (*elem == '/' || (strlen(elem) > 2 && isalpha(elem[0]) && - elem[1] == ':' && elem[2] == '/')) -#endif + if (PathIsAbsolute(elem)) { len = strlen(elem); addslash = (elem[len - 1] != '/'); @@ -389,23 +394,65 @@ FreeSubdirs(const char **subdirs) } static char * -FindModule(const char *module, const char *dir, const char **subdirlist, +FindModuleInSubdir(const char *dirpath, const char *module) +{ + struct dirent *direntry = NULL; + DIR *dir = NULL; + char *ret = NULL, tmpBuf[PATH_MAX]; + struct stat stat_buf; + + dir = opendir(dirpath); + if (!dir) + return NULL; + + while ((direntry = readdir(dir))) { + if (direntry->d_name[0] == '.') + continue; + if ((stat(direntry->d_name, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) { + snprintf(tmpBuf, PATH_MAX, "%s/%s", dirpath, direntry->d_name); + if ((ret = FindModuleInSubdir(tmpBuf, module))) + break; + continue; + } + + snprintf(tmpBuf, PATH_MAX, "lib%s.so", module); + if (strcmp(direntry->d_name, tmpBuf) == 0) { + ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2); + sprintf(ret, "%s/%s", dirpath, tmpBuf); + break; + } + + snprintf(tmpBuf, PATH_MAX, "%s_drv.so", module); + if (strcmp(direntry->d_name, tmpBuf) == 0) { + ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2); + sprintf(ret, "%s/%s", dirpath, tmpBuf); + break; + } + + snprintf(tmpBuf, PATH_MAX, "%s.so", module); + if (strcmp(direntry->d_name, tmpBuf) == 0) { + ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2); + sprintf(ret, "%s/%s", dirpath, tmpBuf); + break; + } + } + + closedir(dir); + return ret; +} + +static char * +FindModule(const char *module, const char *dirname, const char **subdirlist, PatternPtr patterns) { - char buf[PATH_MAX + 1], tmpBuf[PATH_MAX + 1]; + char buf[PATH_MAX + 1]; char *dirpath = NULL; char *name = NULL; - struct stat stat_buf; int dirlen; const char **subdirs = NULL; const char **s; -#ifndef __EMX__ - dirpath = (char *)dir; -#else - dirpath = xalloc(strlen(dir) + 10); - strcpy(dirpath, (char *)__XOS2RedirRoot(dir)); -#endif + dirpath = (char *)dirname; if (strlen(dirpath) > PATH_MAX) return NULL; @@ -418,38 +465,15 @@ FindModule(const char *module, const char *dir, const char **subdirlist, continue; strcpy(buf, dirpath); strcat(buf, *s); - if ((stat(buf, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) { - if (buf[dirlen - 1] != '/') { - buf[dirlen++] = '/'; - } - - snprintf(tmpBuf, PATH_MAX, "%slib%s.so", buf, module); - if (stat(tmpBuf, &stat_buf) == 0) { - name = tmpBuf; - break; - } - - snprintf(tmpBuf, PATH_MAX, "%s%s_drv.so", buf, module); - if (stat(tmpBuf, &stat_buf) == 0) { - name = tmpBuf; - break; - } - - snprintf(tmpBuf, PATH_MAX, "%s%s.so", buf, module); - if (stat(tmpBuf, &stat_buf) == 0) { - name = tmpBuf; - break; - } - } + if ((name = FindModuleInSubdir(buf, module))) + break; } + FreeSubdirs(subdirs); - if (dirpath != dir) + if (dirpath != dirname) xfree(dirpath); - if (name) { - return xstrdup(name); - } - return NULL; + return name; } _X_EXPORT char ** @@ -731,13 +755,7 @@ LoadSubModule(ModuleDescPtr parent, const char *module, xf86MsgVerb(X_INFO, 3, "Loading 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 - { + if (PathIsAbsolute(module)) { xf86Msg(X_ERROR, "LoadSubModule: Absolute module path not permitted: \"%s\"\n", module); @@ -767,12 +785,7 @@ LoadSubModuleLocal(ModuleDescPtr parent, const char *module, 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 + if (PathIsAbsolute(module)) { xf86Msg(X_ERROR, "LoadSubModule: Absolute module path not permitted: \"%s\"\n", @@ -889,14 +902,8 @@ doLoadModule(const char *module, const char *path, const char **subdirlist, * if the module name is not a full pathname, we need to * check the elements in the path */ -#ifndef __UNIXOS2__ - if (module[0] == '/') - found = xstrdup(module); -#else - /* accept a drive name here */ - if (isalpha(module[0]) && module[1] == ':' && module[2] == '/') - found = xstrdup(module); -#endif + if (PathIsAbsolute(module)) + xstrdup(module); path_elem = pathlist; while (!found && *path_elem != NULL) { found = FindModule(m, *path_elem, subdirlist, patterns); diff --git a/hw/xfree86/loader/os.c b/hw/xfree86/loader/os.c index 42ab0bc70..83fd24787 100644 --- a/hw/xfree86/loader/os.c +++ b/hw/xfree86/loader/os.c @@ -33,10 +33,11 @@ /* * OSNAME is a standard form of the OS name that may be used by the - * loader and by OS-specific modules. + * loader and by OS-specific modules. OSNAME here is different from what's in + * dix-config.h */ -#ifndef OSNAME +#undef OSNAME #if defined(__linux__) #define OSNAME "linux" #elif defined(__FreeBSD__) @@ -66,7 +67,6 @@ #else #define OSNAME "unknown" #endif -#endif /* Return the OS name, and run-time OS version */ diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index ad4f77353..69e11d535 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -356,9 +356,6 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMFUNC(xf86RegisterStateChangeNotificationCallback) SYMFUNC(xf86DeregisterStateChangeNotificationCallback) SYMFUNC(xf86NoSharedResources) -#ifdef async - SYMFUNC(xf86QueueAsyncEvent) -#endif /* Shared Accel Accessor Functions */ SYMFUNC(xf86GetLastScrnFlag) SYMFUNC(xf86SetLastScrnFlag) @@ -372,6 +369,9 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMFUNC(xf86AllocateEntityPrivateIndex) SYMFUNC(xf86GetEntityPrivate) + /* xf86cvt.c */ + SYMFUNC(xf86CVTMode) + /* xf86Configure.c */ SYMFUNC(xf86AddDeviceToConfigure) @@ -1146,9 +1146,6 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMVAR(xf86DummyVar3) #endif -#ifdef async - SYMVAR(xf86CurrentScreen) -#endif /* predefined resource lists from xf86Bus.h */ SYMVAR(resVgaExclusive) SYMVAR(resVgaShared) |