* readelf.c (load_specific_debug_section): New function, from
authorDaniel Jacobowitz <drow@false.org>
Fri, 5 Sep 2008 14:49:05 +0000 (14:49 +0000)
committerDaniel Jacobowitz <drow@false.org>
Fri, 5 Sep 2008 14:49:05 +0000 (14:49 +0000)
load_debug_section.
(load_debug_section): Use load_specific_debug_section.
(display_debug_section): Use load_specific_debug_section.  Check for
multiple sections with the same name.

binutils/ChangeLog
binutils/readelf.c

index 525dbe2287f420b0ef3b0776d36b74544bfffd7a..eff5d7b3f7d16ff8702393c5a0e4a79aeb1e1607 100644 (file)
@@ -1,3 +1,11 @@
+2008-09-05  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * readelf.c (load_specific_debug_section): New function, from
+       load_debug_section.
+       (load_debug_section): Use load_specific_debug_section.
+       (display_debug_section): Use load_specific_debug_section.  Check for
+       multiple sections with the same name.
+
 2008-08-28  Tristan Gingold  <gingold@adacore.com>
 
        * objdump.c (dump_stabs): Add sections for Darwin.
index ea48ba1d402c60631a5b023ef7ea046b9b1a5df3..9f1008ccf3a5df213b9600b969874fd16ef2a6a1 100644 (file)
@@ -8486,11 +8486,11 @@ debug_apply_relocations (void *file,
     }
 }
 
-int
-load_debug_section (enum dwarf_section_display_enum debug, void *file)
+static int
+load_specific_debug_section (enum dwarf_section_display_enum debug,
+                            Elf_Internal_Shdr *sec, void *file)
 {
   struct dwarf_section *section = &debug_displays [debug].section;
-  Elf_Internal_Shdr *sec;
   char buf [64];
   int section_is_compressed;
 
@@ -8498,18 +8498,6 @@ load_debug_section (enum dwarf_section_display_enum debug, void *file)
   if (section->start != NULL)
     return 1;
 
-  /* Locate the debug section.  */
-  sec = find_section (section->uncompressed_name);
-  if (sec != NULL)
-    section->name = section->uncompressed_name;
-  else
-    {
-      sec = find_section (section->compressed_name);
-      if (sec != NULL)
-       section->name = section->compressed_name;
-    }
-  if (sec == NULL)
-    return 0;
   section_is_compressed = section->name == section->compressed_name;
 
   snprintf (buf, sizeof (buf), _("%s section data"), section->name);
@@ -8530,6 +8518,28 @@ load_debug_section (enum dwarf_section_display_enum debug, void *file)
   return 1;
 }
 
+int
+load_debug_section (enum dwarf_section_display_enum debug, void *file)
+{
+  struct dwarf_section *section = &debug_displays [debug].section;
+  Elf_Internal_Shdr *sec;
+
+  /* Locate the debug section.  */
+  sec = find_section (section->uncompressed_name);
+  if (sec != NULL)
+    section->name = section->uncompressed_name;
+  else
+    {
+      sec = find_section (section->compressed_name);
+      if (sec != NULL)
+       section->name = section->compressed_name;
+    }
+  if (sec == NULL)
+    return 0;
+
+  return load_specific_debug_section (debug, sec, file);
+}
+
 void
 free_debug_section (enum dwarf_section_display_enum debug)
 {
@@ -8568,12 +8578,20 @@ display_debug_section (Elf_Internal_Shdr *section, FILE *file)
         || streq (debug_displays[i].section.compressed_name, name))
       {
        struct dwarf_section *sec = &debug_displays [i].section;
+       int secondary = (section != find_section (name));
+
+       if (secondary)
+         free_debug_section (i);
 
-       if (load_debug_section (i, file))
+       if (streq (debug_displays[i].section.uncompressed_name, name))
+         sec->name = sec->uncompressed_name;
+       else
+         sec->name = sec->compressed_name;
+       if (load_specific_debug_section (i, section, file))
          {
            result &= debug_displays[i].display (sec, file);
 
-           if (i != info && i != abbrev)
+           if (secondary || (i != info && i != abbrev))
              free_debug_section (i);
          }