[git commit] dl: fix dlsym lookups with RTLD_NEXT
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Wed Jan 9 09:10:09 UTC 2013
commit: http://git.uclibc.org/uClibc/commit/?id=df3a5fcc8d1c3402289375c92df705e978fab58d
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master
The current code for dlsym() when invoked with RTLD_NEXT lookup
searches for the module where it's being called from, and executes the
_dl_find_hash only for the next module in the chain. However, if the
looked symbol is not there, the rest of the modules are not checked.
Generally this is not a problem as symbols are merged for the parent
modules; so this affects only RTLD_NEXT.
This patch adds a loop iterating through all the following modules.
Signed-off-by: Timo Teräs <timo.teras at iki.fi>
Reviewed-by: Filippo ARCIDIACONO <filippo.arcidiacono at st.com>
Tested-by: Florian Fainelli <florian at openwrt.org>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
ldso/libdl/libdl.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 8bc3071..2337223 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -671,7 +671,7 @@ static void *do_dlsym(void *vhandle, const char *name, void *caller_address)
{
struct elf_resolve *tpnt, *tfrom;
struct dyn_elf *handle;
- ElfW(Addr) from;
+ ElfW(Addr) from = 0;
struct dyn_elf *rpnt;
void *ret;
struct symbol_ref sym_ref = { NULL, NULL };
@@ -729,7 +729,13 @@ static void *do_dlsym(void *vhandle, const char *name, void *caller_address)
tpnt = NULL;
if (handle == _dl_symbol_tables)
tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */
- ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref);
+
+ do {
+ ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref);
+ if (ret != NULL)
+ break;
+ handle = handle->next;
+ } while (from && handle);
#if defined(USE_TLS) && USE_TLS && defined SHARED
if (sym_ref.sym && (ELF_ST_TYPE(sym_ref.sym->st_info) == STT_TLS) && (sym_ref.tpnt)) {
More information about the uClibc-cvs
mailing list