[COMMITTED] libdwfl: Always try find_dynsym last, also on find_symtab ELF errors.

Mark Wielaard mjw at redhat.com
Fri Dec 19 17:27:11 UTC 2014


An ELF error during find_symtab might be incomplete shdrs or string table
from ELF images read through elf_from_memory. The phdrs and dynsym should
always be complete.

Signed-off-by: Mark Wielaard <mjw at redhat.com>
---
 libdwfl/ChangeLog              | 4 ++++
 libdwfl/dwfl_module_getdwarf.c | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 3d3edc5..69e59a6 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,9 @@
 2014-12-19  Mark Wielaard  <mjw at redhat.com>
 
+	* dwfl_module_getdwarf.c (find_symtab): Always try find_dynsym last.
+
+2014-12-19  Mark Wielaard  <mjw at redhat.com>
+
 	* elf-from-memory.c (handle_segment): Remove palign sanity check.
 
 2014-12-18  Mark Wielaard  <mjw at redhat.com>
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
index ab9bd48..494407d 100644
--- a/libdwfl/dwfl_module_getdwarf.c
+++ b/libdwfl/dwfl_module_getdwarf.c
@@ -1084,7 +1084,7 @@ find_symtab (Dwfl_Module *mod)
     {
     elferr:
       mod->symerr = DWFL_E (LIBELF, elf_errno ());
-      goto aux_cleanup;
+      goto aux_cleanup; /* This cleans up some more and tries find_dynsym.  */
     }
 
   /* Cache the data; MOD->syments and MOD->first_global were set above.  */
@@ -1124,6 +1124,9 @@ find_symtab (Dwfl_Module *mod)
 	  mod->aux_syments = 0;
 	  elf_end (mod->aux_sym.elf);
 	  mod->aux_sym.elf = NULL;
+	  /* We thought we had something through shdrs, but it failed...
+	     Last ditch, look for dynamic symbols without section headers.  */
+	  find_dynsym (mod);
 	  return;
 	}
 
-- 
1.8.3.1



More information about the elfutils-devel mailing list