This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[comitted]: readelf - do not dump NOBITS debug sections
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sourceware dot org
- Date: Thu, 28 May 2009 12:02:03 +0100
- Subject: [comitted]: readelf - do not dump NOBITS debug sections
Hi Guys,
I am applying the attached patch to fix a problem I encountered
whilst investigating a gcc debug info generation problem. Readelf
was displaying a .eh_frame section as if it contained corrupt data,
when in fact there was no reliable data there at all. What had
happened was that a debug-info-only file had been created by running
"strip --only-keep-debug" on an executable, but this also preserved
the non-debug sections, just changing their type to NOBITS. When
readelf was then run on the debug-info-only file it dumped the
.eh_frame section as if it contained real data.
Tested with no regression on a multitude of toolchains.
Cheers
Nick
readelf/ChangeLog
2009-05-28 Nick Clifton <nickc@redhat.com>
* readelf.c (display_debug_section): Do not display debug sections
with the NOBITS section type.
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.444
diff -c -3 -p -r1.444 readelf.c
*** binutils/readelf.c 30 Apr 2009 15:47:13 -0000 1.444
--- binutils/readelf.c 28 May 2009 10:49:36 -0000
*************** display_debug_section (Elf_Internal_Shdr
*** 8539,8544 ****
--- 8539,8553 ----
printf (_("\nSection '%s' has no debugging data.\n"), name);
return 0;
}
+ if (section->sh_type == SHT_NOBITS)
+ {
+ /* There is no point in dumping the contents of a debugging section
+ which has the NOBITS type - the bits in the file will be random.
+ This can happen when a file containing a .eh_frame section is
+ stripped with the --only-keep-debug command line option. */
+ printf (_("section '%s' has the NOBITS type - its contents are unreliable.\n"), name);
+ return 0;
+ }
if (const_strneq (name, ".gnu.linkonce.wi."))
name = ".debug_info";