]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Handle SHT_NOBITS sections when checking for section overruns. This
authorJulian Seward <jseward@acm.org>
Fri, 21 Oct 2005 02:37:40 +0000 (02:37 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 21 Oct 2005 02:37:40 +0000 (02:37 +0000)
fixes a problem where debug info was sometimes not being read on
ppc32.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4962

coregrind/m_debuginfo/symtab.c

index 8ee1c4d4e920e5ec2ff3c007da9875998245e22e..e50f1e8c5c952a9b034dfb07c55b2023109b1b7b 100644 (file)
@@ -1622,6 +1622,7 @@ Bool read_lib_symbols ( SegInfo* si )
       for (i = 0; i < ehdr->e_shnum; i++) {
 #        define FIND(sec_name, sec_data, sec_size, sec_addr, in_exec, type) \
          if (0 == VG_(strcmp)(sec_name, sh_strtab + shdr[i].sh_name)) { \
+            Bool nobits; \
             if (0 != sec_data) \
                VG_(core_panic)("repeated section!\n"); \
             if (in_exec) \
@@ -1629,10 +1630,12 @@ Bool read_lib_symbols ( SegInfo* si )
             else \
                sec_data = (type)(oimage + shdr[i].sh_offset); \
             sec_size = shdr[i].sh_size; \
+            nobits = shdr[i].sh_type == SHT_NOBITS; \
             sec_addr = si->offset + shdr[i].sh_addr; \
             TRACE_SYMTAB( "%18s: %p .. %p\n", \
                           sec_name, sec_data, sec_data + sec_size - 1); \
-            if ( shdr[i].sh_offset + sec_size > n_oimage ) { \
+            /* SHT_NOBITS sections have zero size in the file. */ \
+            if ( shdr[i].sh_offset + (nobits ? 0 : sec_size) > n_oimage ) { \
                ML_(symerr)("   section beyond image end?!"); \
                goto out; \
             } \
@@ -1692,13 +1695,16 @@ Bool read_lib_symbols ( SegInfo* si )
                for (i = 0; i < ehdr->e_shnum; i++) {
 #                 define FIND(sec_name, sec_data, sec_size, type) \
                   if (0 == VG_(strcmp)(sec_name, sh_strtab + shdr[i].sh_name)) { \
+                     Bool nobits; \
                      if (0 != sec_data) \
                         VG_(core_panic)("repeated section!\n"); \
                      sec_data = (type)(dimage + shdr[i].sh_offset); \
                      sec_size = shdr[i].sh_size; \
+                     nobits = shdr[i].sh_type == SHT_NOBITS; \
                      TRACE_SYMTAB( "%18s: %p .. %p\n", \
                                    sec_name, sec_data, sec_data + sec_size - 1); \
-                     if ( shdr[i].sh_offset + sec_size > n_dimage ) { \
+                     /* SHT_NOBITS sections have zero size in the file. */ \
+                     if ( shdr[i].sh_offset + (nobits ? 0 : sec_size) > n_dimage ) { \
                         ML_(symerr)("   section beyond image end?!"); \
                         goto out; \
                      } \