From d8f3c5894ee8053ea9f6049a5a0689c9efba1685 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 27 Feb 1998 18:00:37 +0000 Subject: [PATCH] (_dl_addr): Fix search algorithms in dladdr(); don't assume that the number of program headers is >0 (which is wrong for the loader itself). --- elf/dladdr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/elf/dladdr.c b/elf/dladdr.c index f3d63f76f2a..868a0ed893f 100644 --- a/elf/dladdr.c +++ b/elf/dladdr.c @@ -68,10 +68,11 @@ dladdr (void *address, Dl_info *info) /* We assume that the string table follows the symbol table, because there is no way in ELF to know the size of the dynamic symbol table!! */ for (matchsym = NULL; (void *) symtab < (void *) strtab; ++symtab) - if (addr >= match->l_addr + symtab->st_value && !matchsym || - matchsym->st_value < symtab->st_value && - ELFW(ST_BIND) (symtab->st_info) == STB_GLOBAL || - ELFW(ST_BIND) (symtab->st_info) == STB_WEAK) + if (addr >= match->l_addr + symtab->st_value + && (!matchsym + || (matchsym->st_value < symtab->st_value + && (ELFW(ST_BIND) (symtab->st_info) == STB_GLOBAL + || ELFW(ST_BIND) (symtab->st_info) == STB_WEAK)))) matchsym = symtab; if (matchsym) -- 2.47.2