summaryrefslogtreecommitdiff
path: root/elf/dl-addr.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-22 17:55:23 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-22 17:55:23 +0000
commit46b05e5d746be53b4102012365a38c50b8719e98 (patch)
tree0d10009ac4187314c91154e44e8ff0b9da9ccfa3 /elf/dl-addr.c
parent2e3e5db6680de463d6e8b43ec8bc5e131a99a700 (diff)
downloadglibc-46b05e5d746be53b4102012365a38c50b8719e98.tar.gz
Update.
2001-08-22 Ulrich Drepper <drepper@redhat.com> * elf/dl-addr.c (_dl_addr): Fix tests to determine dli_sname. * malloc/mtrace.c (tr_where): dli_sname always points to a non-empty string is != NULL. Reported by Tim Janik <timj@gtk.org>.
Diffstat (limited to 'elf/dl-addr.c')
-rw-r--r--elf/dl-addr.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/elf/dl-addr.c b/elf/dl-addr.c
index 0a06525ce9..96fa2e2ebc 100644
--- a/elf/dl-addr.c
+++ b/elf/dl-addr.c
@@ -1,5 +1,5 @@
/* Locate the shared object symbol nearest a given address.
- Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1996-2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -30,6 +30,7 @@ _dl_addr (const void *address, Dl_info *info)
struct link_map *l, *match;
const ElfW(Sym) *symtab, *matchsym;
const char *strtab;
+ ElfW(Word) strtabsize;
/* Find the highest-addressed object that ADDRESS is not below. */
match = NULL;
@@ -70,15 +71,17 @@ _dl_addr (const void *address, Dl_info *info)
symtab = (const void *) D_PTR (match, l_info[DT_SYMTAB]);
strtab = (const void *) D_PTR (match, l_info[DT_STRTAB]);
+ strtabsize = match->l_info[DT_STRSZ]->d_un.d_val;
/* 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))))
+ && addr < match->l_addr + symtab->st_value + symtab->st_size
+ && symtab->st_name < strtabsize
+ && (matchsym == NULL || 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)