]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Be paranoid about presence of .debug_{info,abbrev,str}
authorPetr Machata <pmachata@redhat.com>
Sun, 11 Jan 2009 19:47:23 +0000 (20:47 +0100)
committerPetr Machata <pmachata@redhat.com>
Sun, 11 Jan 2009 19:47:23 +0000 (20:47 +0100)
src/ChangeLog
src/dwarflint.c

index 2cfe210093a2f613ea6d8a6c5a026f8aba558437..8a48cc5a67826c99200f61fafb0f73466f9de665 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-11  Petr Machata  <pmachata@redhat.com>
+
+       * dwarflint.c (process_file): Handle absence of .debug_info,
+       .debug_abbrev and .debug_str gracefully.
+
 2009-01-11  Petr Machata  <pmachata@redhat.com>
 
        * dwarflint.c: A couple small fixes across the code.
index eba82f51ff0ed1ed0854c1b1cd178e3b2550fb5c..552485a15bb0c020145b3cac695479bd490fe9e9 100644 (file)
@@ -471,12 +471,31 @@ process_file (int fd __attribute__((unused)),
 
   struct read_ctx ctx;
 
-  read_ctx_init (&ctx, dwarf, dwarf->sectiondata[IDX_debug_abbrev]);
-  struct abbrev_table *abbrev_chain = abbrev_table_load (&ctx);
+  /* If we got Dwarf pointer, debug_abbrev and debug_info are present
+     inside the file.  But let's be paranoid.  */
+  Elf_Data *abbrev_data = dwarf->sectiondata[IDX_debug_abbrev];
+  struct abbrev_table *abbrev_chain = NULL;
+  if (likely (abbrev_data != NULL))
+    {
+      read_ctx_init (&ctx, dwarf, abbrev_data);
+      abbrev_chain = abbrev_table_load (&ctx);
+    }
+  else if (!tolerate_nodebug)
+    ERROR (".debug_abbrev data not found.");
 
-  read_ctx_init (&ctx, dwarf, dwarf->sectiondata[IDX_debug_info]);
-  check_debug_info_structural (&ctx, abbrev_chain,
-                              dwarf->sectiondata[IDX_debug_str]);
+  if (abbrev_chain != NULL)
+    {
+      Elf_Data *info_data = dwarf->sectiondata[IDX_debug_info];
+      Elf_Data *str_data = dwarf->sectiondata[IDX_debug_str];
+      /* Same as above...  */
+      if (info_data != NULL && str_data != NULL)
+       {
+         read_ctx_init (&ctx, dwarf, info_data);
+         check_debug_info_structural (&ctx, abbrev_chain, str_data);
+       }
+      else if (!tolerate_nodebug)
+       ERROR (".debug_info or .debug_str data not found.");
+    }
 
   abbrev_table_free (abbrev_chain);
 }