diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2003-06-01 16:19:01 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2003-06-01 16:19:01 +0000 |
commit | df3e6a52b1014ae1a0bfae59ab7b5808c84b9f48 (patch) | |
tree | acb9647b7094710adb8b1b0b09fe60bb05c2cb79 /sys/ddb/db_elf.c | |
parent | c1b5e4353daf6f1929dad2fc6e04853b6ee139ae (diff) |
When searching for the symbol table and string table we were looking
for ".symtab" and ".strtab" in the section names. Instead of doing that,
look for section type SHT_SYMTAB for the symbol table and follow the link
in sh_link to find the corresponding string table. This is a more correct
way of doing things and will work better when the toolchain doesn't
generate ".symtab" and ".strtab" names and it will work when there are
multiple symbol tables.
noone objected to this diff for at least a week.
Diffstat (limited to 'sys/ddb/db_elf.c')
-rw-r--r-- | sys/ddb/db_elf.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/sys/ddb/db_elf.c b/sys/ddb/db_elf.c index bcdc8dc0aa0..16ff6d43a21 100644 --- a/sys/ddb/db_elf.c +++ b/sys/ddb/db_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_elf.c,v 1.5 2002/03/14 03:16:03 millert Exp $ */ +/* $OpenBSD: db_elf.c,v 1.6 2003/06/01 16:19:00 art Exp $ */ /* $NetBSD: db_elf.c,v 1.13 2000/07/07 21:55:18 jhawk Exp $ */ /*- @@ -158,6 +158,28 @@ db_elf_sym_init(symsize, symtab, esymtab, name) shp = (Elf_Shdr *)((char *)symtab + elf->e_shoff); shstrtab = (char *)symtab + shp[elf->e_shstrndx].sh_offset; for (i = 0; i < elf->e_shnum; i++) { + if (shp[i].sh_type == SHT_SYMTAB) { + int j; + + if (shp[i].sh_offset == 0) + continue; + symtab_start = (Elf_Sym *)((char *)symtab + + shp[i].sh_offset); + symtab_end = (Elf_Sym *)((char *)symtab + + shp[i].sh_offset + shp[i].sh_size); + j = shp[i].sh_link; + if (shp[j].sh_offset == 0) + continue; + strtab_start = (char *)symtab + shp[j].sh_offset; + strtab_end = (char *)symtab + shp[j].sh_offset + + shp[j].sh_size; + break; + } + + /* + * This is the old way of doing things. + * XXX - verify that it's not needed. + */ if (strcmp(".strtab", shstrtab+shp[i].sh_name) == 0) { strtab_start = (char *)symtab + shp[i].sh_offset; strtab_end = (char *)symtab + shp[i].sh_offset + @@ -218,6 +240,8 @@ db_elf_find_strtab(stab) shstrtab = (char *)elf + shp[elf->e_shstrndx].sh_offset; for (i = 0; i < elf->e_shnum; i++) { + if (shp[i].sh_type == SHT_SYMTAB) + return ((char *)elf + shp[shp[i].sh_link].sh_offset); if (strcmp(".strtab", shstrtab+shp[i].sh_name) == 0) return ((char *)elf + shp[i].sh_offset); } |