Calling dlsym with handle of the module library instead of RTLD_DEFAULT prevents increasing reference counter of the library and so allows it to be really unloaded if UnloadModule is called on it later. --- hw/xfree86/loader/loader.c | 8 +++++++- hw/xfree86/loader/loader.h | 1 + hw/xfree86/loader/loadmod.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c index b72b8b8..4e56e9e 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(const char *name, void *handle) +{ + 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 5cadd5a..1d07cdb 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(const char *, void *); #endif /* _LOADER_H */ diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index 706b9b3..b6fc394 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -956,7 +956,7 @@ doLoadModule(const char *module, const char *path, const char **subdirlist, *errmin = 0; goto LoadModule_fail; } - initdata = LoaderSymbol(p); + initdata = LoaderSymbolFromModule(p, ret->handle); if (initdata) { ModuleSetupProc setup; ModuleTearDownProc teardown; -- 1.7.7 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel