]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
merge rev 1.24:
authorJulian Seward <jseward@acm.org>
Sat, 12 Oct 2002 18:32:06 +0000 (18:32 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 12 Oct 2002 18:32:06 +0000 (18:32 +0000)
From "Francis Lebourse" <flebourse@jetmultimedia.fr>:

[re the ELF symbol reader]

This patch tries to exploit the dynamic symbols of a library if the
standard and debug symbols are missing.

This way, I avoid the "object doesn't have a symbol table message"
message and valgrind is able to print meaningful backtraces (else you
have only "in libsomelib.so"), even in the case of stripped libs.

Since the check of the .dynsym/.dynstr sections is done before the
.symtab/.strtab sections, the previous behavior is preseved for
unstripped libraries.

git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_1_0_BRANCH@1212

vg_symtab2.c

index e8a8f0e3e5ce55bd369325634b84acf10f8df802..2367f7fac899ae49c7633819e0aa6223f98aa88f 100644 (file)
@@ -1437,6 +1437,25 @@ void vg_read_lib_symbols ( SegInfo* si )
 
       /* find the .stabstr and .stab sections */
       for (i = 0; i < ehdr->e_shnum; i++) {
+
+         /* As a fallback position, we look first for the dynamic
+            symbols of a library to increase the chances that we can
+            say something helpful even if the standard and debug
+            symbols are missing. */
+
+         if (0 == VG_(strcmp)(".dynsym",sh_strtab + shdr[i].sh_name)) {
+            o_symtab    = (Elf32_Sym*)(oimage + shdr[i].sh_offset);
+            o_symtab_sz = shdr[i].sh_size;
+            vg_assert((o_symtab_sz % sizeof(Elf32_Sym)) == 0);
+            /* check image overrun here */
+         }
+         if (0 == VG_(strcmp)(".dynstr",sh_strtab + shdr[i].sh_name)) {
+            o_strtab    = (UChar*)(oimage + shdr[i].sh_offset);
+            o_strtab_sz = shdr[i].sh_size;
+            /* check image overrun here */
+         }
+
+         /* now look for the main symbol and string tables. */
          if (0 == VG_(strcmp)(".symtab",sh_strtab + shdr[i].sh_name)) {
             o_symtab    = (Elf32_Sym*)(oimage + shdr[i].sh_offset);
             o_symtab_sz = shdr[i].sh_size;