From d966045b7b22448c0c4cdfa90eb1afab34d07c46 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Fri, 5 Sep 2008 14:49:05 +0000 Subject: [PATCH] * 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. --- binutils/ChangeLog | 8 +++++++ binutils/readelf.c | 52 +++++++++++++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 525dbe2287f..eff5d7b3f7d 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,11 @@ +2008-09-05 Daniel Jacobowitz + + * 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 * objdump.c (dump_stabs): Add sections for Darwin. diff --git a/binutils/readelf.c b/binutils/readelf.c index ea48ba1d402..9f1008ccf3a 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -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); } -- 2.30.2