From 622586fbe088fbd0cca0533a046e65114c584526 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 25 Jun 1996 18:22:06 +0000 Subject: Tue Jun 25 10:58:23 1996 Roland McGrath * inet/getrpcent.c: Fix macros. * inet/getrpcent_r.c: Fix macros. * elf/dlsym.c (dlsym): Search the global scope if HANDLE is null. * elf/dl-load.c (_dl_map_object_from_fd): Initialize L. --- elf/dlsym.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'elf/dlsym.c') diff --git a/elf/dlsym.c b/elf/dlsym.c index 7677f2741f..256eba800e 100644 --- a/elf/dlsym.c +++ b/elf/dlsym.c @@ -26,13 +26,25 @@ Cambridge, MA 02139, USA. */ void * dlsym (void *handle, const char *name) { - struct link_map *map = handle; ElfW(Addr) loadbase; const ElfW(Sym) *ref = NULL; void doit (void) { - struct link_map *scope[2] = { map, NULL }; - loadbase = _dl_lookup_symbol (name, &ref, scope, map->l_name, 0, 0); + struct link_map *map = handle, **scope, *mapscope[2] = { map, NULL }; + const char *owner; + + if (map) + { + /* Search the scope of the given object. */ + scope = mapscope; + owner = map->l_name; + } + else + { + scope = &(_dl_global_scope ?: _dl_default_scope)[2]; + owner = NULL; + } + loadbase = _dl_lookup_symbol (name, &ref, scope, owner, 0, 0); } return _dlerror_run (doit) ? NULL : (void *) (loadbase + ref->st_value); -- cgit v1.2.3