|
From: <sv...@va...> - 2005-10-21 02:37:46
|
Author: sewardj
Date: 2005-10-21 03:37:40 +0100 (Fri, 21 Oct 2005)
New Revision: 4962
Log:
Handle SHT_NOBITS sections when checking for section overruns. This
fixes a problem where debug info was sometimes not being read on
ppc32.
Modified:
trunk/coregrind/m_debuginfo/symtab.c
Modified: trunk/coregrind/m_debuginfo/symtab.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_debuginfo/symtab.c 2005-10-20 18:42:26 UTC (rev 496=
1)
+++ trunk/coregrind/m_debuginfo/symtab.c 2005-10-21 02:37:40 UTC (rev 496=
2)
@@ -1622,6 +1622,7 @@
for (i =3D 0; i < ehdr->e_shnum; i++) {
# define FIND(sec_name, sec_data, sec_size, sec_addr, in_exec, ty=
pe) \
if (0 =3D=3D VG_(strcmp)(sec_name, sh_strtab + shdr[i].sh_name)=
) { \
+ Bool nobits; \
if (0 !=3D sec_data) \
VG_(core_panic)("repeated section!\n"); \
if (in_exec) \
@@ -1629,10 +1630,12 @@
else \
sec_data =3D (type)(oimage + shdr[i].sh_offset); \
sec_size =3D shdr[i].sh_size; \
+ nobits =3D shdr[i].sh_type =3D=3D SHT_NOBITS; \
sec_addr =3D 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 @@
for (i =3D 0; i < ehdr->e_shnum; i++) {
# define FIND(sec_name, sec_data, sec_size, type) \
if (0 =3D=3D VG_(strcmp)(sec_name, sh_strtab + shdr[i]=
.sh_name)) { \
+ Bool nobits; \
if (0 !=3D sec_data) \
VG_(core_panic)("repeated section!\n"); \
sec_data =3D (type)(dimage + shdr[i].sh_offset); \
sec_size =3D shdr[i].sh_size; \
+ nobits =3D shdr[i].sh_type =3D=3D SHT_NOBITS; \
TRACE_SYMTAB( "%18s: %p .. %p\n", \
sec_name, sec_data, sec_data + sec_si=
ze - 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; \
} \
|