From d9ff23789be851983b56d64da17aeaf76b90b641 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 28 May 2009 11:02:22 +0000 Subject: [PATCH] * readelf.c (display_debug_section): Do not display debug sections with the NOBITS section type. --- binutils/ChangeLog | 5 +++++ binutils/readelf.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index ed09c83fd..cf3eaecec 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2009-05-28 Nick Clifton + + * readelf.c (display_debug_section): Do not display debug sections + with the NOBITS section type. + 2009-05-27 Nathan Sidwell * sysdump.c (tab): Use puts rather than two printfs. diff --git a/binutils/readelf.c b/binutils/readelf.c index 30bcf6672..4727a840c 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -8539,6 +8539,15 @@ display_debug_section (Elf_Internal_Shdr * section, FILE * file) 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"; -- 2.11.4.GIT