summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Srb <msrb@suse.com>2012-06-28 17:17:12 +0200
committerJeremy Huddleston Sequoia <jeremyhu@apple.com>2012-08-01 17:40:41 -0700
commit7197c1c571dab1ecef2dc57b8e3bd2689b589f6d (patch)
tree9836fde5104568c0b47e8169646bd63e502bb7c8
parentb0e3696e01ec69e17b74164f4b366baef316f86c (diff)
Look for ModuleData only in appropriate library
LoaderSymbol calls dlsym with RTLD_DEFAULT pseudo handle making it search in every loaded library. In addition glibc adds NODELETE flag to the library containing the symbol. It's used in doLoadModule to locate <modulename>ModuleData symbol, the module's library gets the flag and is kept in memory even after it is unloaded. This patch adds LoaderSymbolFromModule function that looks for symbol only in library specified by handle. That way the NODELETE flag isn't added. This glibc behavior doesn't seem to be documented, but even if other implementations differ, there is no reason to search ModuleData symbol outside the module's library. Signed-off-by: Michal Srb <msrb@suse.com> Reviewed-by: Daniel Stone <daniel@fooishbar.org> v2: Switch LoaderSymbolFromModule arguments order. Correct description. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> (cherry picked from commit 258abbf823f753757e4dddc13ef495f4024680db)
-rw-r--r--hw/xfree86/loader/loader.c6
-rw-r--r--hw/xfree86/loader/loader.h1
-rw-r--r--hw/xfree86/loader/loadmod.c2
3 files changed, 8 insertions, 1 deletions
diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c
index b72b8b89d..483696450 100644
--- a/hw/xfree86/loader/loader.c
+++ b/hw/xfree86/loader/loader.c
@@ -160,6 +160,12 @@ LoaderSymbol(const char *name)
return NULL;
}
+void *
+LoaderSymbolFromModule(void *handle, const char *name)
+{
+ return dlsym(handle, name);
+}
+
void
LoaderUnload(const char *name, void *handle)
{
diff --git a/hw/xfree86/loader/loader.h b/hw/xfree86/loader/loader.h
index 5cadd5ad6..c89c6410a 100644
--- a/hw/xfree86/loader/loader.h
+++ b/hw/xfree86/loader/loader.h
@@ -72,5 +72,6 @@ extern unsigned long LoaderOptions;
/* Internal Functions */
void *LoaderOpen(const char *, int *, int *);
+void *LoaderSymbolFromModule(void *, const char *);
#endif /* _LOADER_H */
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index c6b559072..6fa9554c9 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -938,7 +938,7 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
*errmin = 0;
goto LoadModule_fail;
}
- initdata = LoaderSymbol(p);
+ initdata = LoaderSymbolFromModule(ret->handle, p);
if (initdata) {
ModuleSetupProc setup;
ModuleTearDownProc teardown;