This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hi! This has been seen in JDK (still does not work, am looking into linuxthreads right now). Basically, the main object and ld.so have l_map_end set to ~0L, so if _dl_addr is called with an address from some non-dlopened shared library (e.g. void foo(void) { Dl_info i; dladdr(foo, &i); } in a dso), then the test chooses the main program as a match (because foo address is certainly below ~0L and above l_map_start of the main object), fails in the PHDR check and returns 0. 2000-07-17 Jakub Jelinek <jakub@redhat.com> * elf/dl-addr.c (_dl_addr): Keep searching in the _dl_loaded chain if the PHDR check fails. --- libc/elf/dl-addr.c.jj Thu Jun 8 04:34:29 2000 +++ libc/elf/dl-addr.c Mon Jul 17 12:19:16 2000 @@ -36,27 +36,25 @@ _dl_addr (const void *address, Dl_info * for (l = _dl_loaded; l; l = l->l_next) if (addr >= l->l_map_start && addr < l->l_map_end) { + /* We know ADDRESS lies within L if in any shared object. + Make sure it isn't past the end of L's segments. */ + size_t n = l->l_phnum; + if (n > 0) + { + do + --n; + while (l->l_phdr[n].p_type != PT_LOAD); + if (addr >= (l->l_addr + + l->l_phdr[n].p_vaddr + l->l_phdr[n].p_memsz)) + /* Off the end of the highest-addressed shared object. */ + continue; + } + match = l; break; } - if (__builtin_expect (match != NULL, 1)) - { - /* We know ADDRESS lies within MATCH if in any shared object. - Make sure it isn't past the end of MATCH's segments. */ - size_t n = match->l_phnum; - if (n > 0) - { - do - --n; - while (match->l_phdr[n].p_type != PT_LOAD); - if (addr >= (match->l_addr + - match->l_phdr[n].p_vaddr + match->l_phdr[n].p_memsz)) - /* Off the end of the highest-addressed shared object. */ - return 0; - } - } - else + if (match == NULL) return 0; /* Now we know what object the address lies in. */ Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |