aboutsummaryrefslogtreecommitdiff
path: root/elf/dl-sym.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-08-01 19:24:38 +0000
committerUlrich Drepper <drepper@redhat.com>1999-08-01 19:24:38 +0000
commit4f2793d41f1043cf04f6761b1da00d8741824087 (patch)
tree4438801b2a8444e7c83b62c3bd64ae833dc63ee1 /elf/dl-sym.c
parent7730a3b9d420136fc8a001d1ebd6c68cd0c005a3 (diff)
downloadglibc-4f2793d41f1043cf04f6761b1da00d8741824087.zip
glibc-4f2793d41f1043cf04f6761b1da00d8741824087.tar.gz
glibc-4f2793d41f1043cf04f6761b1da00d8741824087.tar.bz2
Update.
1999-08-01 Ulrich Drepper <drepper@cygnus.com> * elf/dl-sym.c (_dl_sym): Always determine module of the caller to pass it to _dl_lookup_symbol. * elf/dl-error.c (_dl_signal_error): Optimize string generation a bit. Reword message. * dlfcn/dlerror.c: Make code thread-safe.
Diffstat (limited to 'elf/dl-sym.c')
-rw-r--r--elf/dl-sym.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/elf/dl-sym.c b/elf/dl-sym.c
index 91ca127..80be954 100644
--- a/elf/dl-sym.c
+++ b/elf/dl-sym.c
@@ -35,7 +35,7 @@ _dl_sym (void *handle, const char *name, void *who)
if (handle == RTLD_DEFAULT)
/* Search the global scope. */
loadbase = _dl_lookup_symbol (name, NULL, &ref, _dl_global_scope, 0);
- else if (handle == RTLD_NEXT)
+ else
{
struct link_map *l, *match;
ElfW(Addr) caller = (ElfW(Addr)) who;
@@ -46,22 +46,32 @@ _dl_sym (void *handle, const char *name, void *who)
if (caller >= l->l_addr && (!match || match->l_addr < l->l_addr))
match = l;
- if (! match)
- _dl_signal_error (0, NULL, _("\
+ if (handle != RTLD_NEXT)
+ {
+ /* Search the scope of the given object. */
+ struct link_map *map = handle;
+
+ if (match == NULL)
+ /* If the address is not recognized the call comes from the
+ main program (we hope). */
+ match = _dl_loaded;
+
+ loadbase = _dl_lookup_symbol (name, match, &ref, map->l_local_scope,
+ 0);
+ }
+ else
+ {
+ if (! match)
+ _dl_signal_error (0, NULL, _("\
RTLD_NEXT used in code not dynamically loaded"));
- l = match;
- while (l->l_loader)
- l = l->l_loader;
+ l = match;
+ while (l->l_loader)
+ l = l->l_loader;
- loadbase = _dl_lookup_symbol_skip (name, l, &ref, l->l_local_scope,
- match);
- }
- else
- {
- /* Search the scope of the given object. */
- struct link_map *map = handle;
- loadbase = _dl_lookup_symbol (name, map, &ref, map->l_local_scope, 0);
+ loadbase = _dl_lookup_symbol_skip (name, l, &ref, l->l_local_scope,
+ match);
+ }
}
if (loadbase)