Commit 258abbf8 authored by Michal Srb's avatar Michal Srb Committed by Peter Hutterer
Browse files

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: default avatarMichal Srb <msrb@suse.com>
Reviewed-by: Daniel Stone's avatarDaniel Stone <daniel@fooishbar.org>

v2: Switch LoaderSymbolFromModule arguments order.
    Correct description.
Reviewed-by: Adam Jackson's avatarAdam Jackson <ajax@redhat.com>
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent d84f0f82
......@@ -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)
{
......
......@@ -72,5 +72,6 @@ extern unsigned long LoaderOptions;
/* Internal Functions */
void *LoaderOpen(const char *, int *, int *);
void *LoaderSymbolFromModule(void *, const char *);
#endif /* _LOADER_H */
......@@ -956,7 +956,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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment