uClibc: backport a fix for dlsym(RTLD_NEXT, ...) use
[openwrt/openwrt.git] / toolchain / uClibc / patches-0.9.33.2 / 011-dlsym_rtld_next_fix.patch
1 diff -urN uClibc-0.9.33.2/ldso/libdl/libdl.c uClibc-0.9.33.2.new/ldso/libdl/libdl.c
2 --- uClibc-0.9.33.2/ldso/libdl/libdl.c 2012-05-15 09:20:09.000000000 +0200
3 +++ uClibc-0.9.33.2.new/ldso/libdl/libdl.c 2012-11-10 18:34:56.673501060 +0100
4 @@ -671,7 +671,7 @@
5 {
6 struct elf_resolve *tpnt, *tfrom;
7 struct dyn_elf *handle;
8 - ElfW(Addr) from;
9 + ElfW(Addr) from = 0;
10 struct dyn_elf *rpnt;
11 void *ret;
12 struct symbol_ref sym_ref = { NULL, NULL };
13 @@ -729,7 +729,12 @@
14 tpnt = NULL;
15 if (handle == _dl_symbol_tables)
16 tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */
17 - ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref);
18 + do {
19 + ret = _dl_find_hash(name2, &handle->dyn->symbol_scope, tpnt, ELF_RTYPE_CLASS_DLSYM, &sym_ref);
20 + if (ret != NULL)
21 + break;
22 + handle = handle->next;
23 + } while (from && handle);
24
25 #if defined(USE_TLS) && USE_TLS && defined SHARED
26 if (sym_ref.sym && (ELF_ST_TYPE(sym_ref.sym->st_info) == STT_TLS) && (sym_ref.tpnt)) {