+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.
}
}
-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;
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);
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)
{
|| 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);
}