This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 4/4] Move the shdr check from readelf to debugscn_p()


Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
---
 backends/ChangeLog      |    1 +
 backends/i386_symbol.c  |    2 ++
 libebl/ChangeLog        |    1 +
 libebl/eblopenbackend.c |    2 ++
 src/ChangeLog           |    1 +
 src/readelf.c           |    2 +-
 6 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/backends/ChangeLog b/backends/ChangeLog
index dee3540..03da036 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -2,6 +2,7 @@
 
 	* libebl_CPU.h (generic_debugscn_p): Add shdr param
 	* i386_symbol.c (i386_debugscn_p): Add shdr param
+	* i386_symbol.c (i386_debugscn_p): Check the shdr param
 
 2011-03-09  Mark Wielaard  <mjw@redhat.com>
 
diff --git a/backends/i386_symbol.c b/backends/i386_symbol.c
index 521325a..5b4d710 100644
--- a/backends/i386_symbol.c
+++ b/backends/i386_symbol.c
@@ -69,6 +69,8 @@ bool (*generic_debugscn_p) (const char *, const GElf_Shdr *);
 bool
 i386_debugscn_p (const char *name, const GElf_Shdr *shdr)
 {
+  if (shdr && shdr->sh_type != SHT_PROGBITS)
+    return false;
   return (generic_debugscn_p (name, shdr)
 	  || strcmp (name, ".stab") == 0
 	  || strcmp (name, ".stabstr") == 0);
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 3851a0a..799ddc0 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -7,6 +7,7 @@
 	* eblopenbackend.c (default_debugscn_p): Add shdr as parameter
 	* eblsectionstripp.c (ebl_section_strip_p): Call ebl_debugscn_p with
 	shdr param
+	* blopenbackend.c (default_debugscn_p): Check the shdr param
 
 2011-06-26  Mark Wielaard  <mjw@redhat.com>
 
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 86c00b5..2e74970 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -656,6 +656,8 @@ default_debugscn_p (const char *name, const GElf_Shdr *shdr)
     };
   const size_t ndwarf_scn_names = (sizeof (dwarf_scn_names)
 				   / sizeof (dwarf_scn_names[0]));
+  if (shdr && shdr->sh_type != SHT_PROGBITS)
+    return false;
   for (size_t cnt = 0; cnt < ndwarf_scn_names; ++cnt)
     if (strcmp (name, dwarf_scn_names[cnt]) == 0
 #if USE_ZLIB
diff --git a/src/ChangeLog b/src/ChangeLog
index e9c4b65..657dac7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -4,6 +4,7 @@
 	* ldscript.y: Pass shdr to ebl_debugscn_p()
 	* strip.c (handle_elf) Pass shdr to ebl_debugscn_p()
 	* readelf.c (print_debug): Pass shdr to ebl_debugscn_p()
+	* print_debug (print_debug): Don't check shdr anymore
 
 2012-06-27  Mark Wielaard  <mjw@redhat.com>
 
diff --git a/src/readelf.c b/src/readelf.c
index d16fb3f..7db57a2 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7788,7 +7788,7 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr)
       GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
       const char *name = elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
 
-      if (ebl_debugscn_p(ebl, name, shdr) && shdr != NULL && shdr->sh_type == SHT_PROGBITS)
+      if (ebl_debugscn_p(ebl, name, shdr))
 	{
 	  static const struct
 	  {
-- 
1.7.10.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]