diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2008-11-05 12:28:44 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2008-11-05 12:28:44 +0000 |
commit | d558f5be79e0de6a7d89d7fac4648de2dddb0a54 (patch) | |
tree | b7518ee0d6028ccc726c9bfc55f2efde5bf1e060 /libexec | |
parent | 1b9a617c7c935c1a8ac29d21880b4b2ef29c99e3 (diff) |
Notes
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/rtld-elf/rtld.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 740bf32db3a55..bbf4bb9c93a4d 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -1891,7 +1891,7 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve, { DoneList donelist; const Obj_Entry *obj, *defobj; - const Elf_Sym *def; + const Elf_Sym *def, *symp; unsigned long hash; int lockstate; @@ -1917,9 +1917,26 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve, if (handle == RTLD_NEXT) obj = obj->next; for (; obj != NULL; obj = obj->next) { - if ((def = symlook_obj(name, hash, obj, ve, flags)) != NULL) { - defobj = obj; - break; + if ((symp = symlook_obj(name, hash, obj, ve, flags)) != NULL) { + if (def == NULL || ELF_ST_BIND(symp->st_info) != STB_WEAK) { + def = symp; + defobj = obj; + if (ELF_ST_BIND(def->st_info) != STB_WEAK) + break; + } + } + } + /* + * Search the dynamic linker itself, and possibly resolve the + * symbol from there. This is how the application links to + * dynamic linker services such as dlopen. Only the values listed + * in the "exports" array can be resolved from the dynamic linker. + */ + if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) { + symp = symlook_obj(name, hash, &obj_rtld, ve, flags); + if (symp != NULL && is_exported(symp)) { + def = symp; + defobj = &obj_rtld; } } } else { |