From be179c8a36fc171acff0634ac50ad31269ad4742 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Mon, 18 Feb 2013 18:00:17 +0530 Subject: New function _dl_find_dso_for_object Consolidate code to search for an address within a DSO. --- elf/dl-sym.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'elf/dl-sym.c') diff --git a/elf/dl-sym.c b/elf/dl-sym.c index d2b4db7ec0..05de6c1c06 100644 --- a/elf/dl-sym.c +++ b/elf/dl-sym.c @@ -91,20 +91,10 @@ do_sym (void *handle, const char *name, void *who, lookup_t result; ElfW(Addr) caller = (ElfW(Addr)) who; + struct link_map *l = _dl_find_dso_for_object (caller); /* If the address is not recognized the call comes from the main program (we hope). */ - struct link_map *match = GL(dl_ns)[LM_ID_BASE]._ns_loaded; - - /* Find the highest-addressed object that CALLER is not below. */ - for (Lmid_t ns = 0; ns < GL(dl_nns); ++ns) - for (struct link_map *l = GL(dl_ns)[ns]._ns_loaded; l != NULL; - l = l->l_next) - if (caller >= l->l_map_start && caller < l->l_map_end - && (l->l_contiguous || _dl_addr_inside_object (l, caller))) - { - match = l; - break; - } + struct link_map *match = l ? l : GL(dl_ns)[LM_ID_BASE]._ns_loaded; if (handle == RTLD_DEFAULT) { -- cgit v1.2.1