This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Handle multiple .debug_info sections
- From: Cary Coutant <ccoutant at google dot com>
- To: binutils at sourceware dot org
- Date: Fri, 20 Feb 2009 12:13:50 -0800
- Subject: Re: Handle multiple .debug_info sections
- References: <20080905145304.GA14634@caradoc.them.org>
> * 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.
I was happy to see this patch -- I had a similar patch already in
progress when you posted this. Since your patch didn't address
objdump.c, I reworked my patch for that file to use the same approach
you did in readelf.c.
(Sorry I've been sitting on this for so long -- I meant to send it a
long time ago and just forgot about it.)
Tested on i686/x86_64 with gcc -feliminate-dwarf2-dups, which also
generates multiple debug_info sections (as comdats), and with the
experimental -gdwarf-4, which puts each type in a separate
.debug_types section.
OK?
-cary
* objdump.c (load_specific_debug_section): New function, from
load_debug_section.
(load_debug_section): Use load_specific_debug_section.
(dump_dwarf_section): Likewise.
Index: objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.154
diff -u -p -r1.154 objdump.c
--- objdump.c 9 Feb 2009 09:14:15 -0000 1.154
+++ objdump.c 20 Feb 2009 20:00:41 -0000
@@ -2122,12 +2122,12 @@ disassemble_data (bfd *abfd)
free (sorted_syms);
}
-int
-load_debug_section (enum dwarf_section_display_enum debug, void *file)
+static int
+load_specific_debug_section (enum dwarf_section_display_enum debug,
+ asection *sec, void *file)
{
struct dwarf_section *section = &debug_displays [debug].section;
bfd *abfd = file;
- asection *sec;
bfd_boolean ret;
int section_is_compressed;
@@ -2135,18 +2135,6 @@ load_debug_section (enum dwarf_section_d
if (section->start != NULL)
return 1;
- /* Locate the debug section. */
- sec = bfd_get_section_by_name (abfd, section->uncompressed_name);
- if (sec != NULL)
- section->name = section->uncompressed_name;
- else
- {
- sec = bfd_get_section_by_name (abfd, section->compressed_name);
- if (sec != NULL)
- section->name = section->compressed_name;
- }
- if (sec == NULL)
- return 0;
section_is_compressed = section->name == section->compressed_name;
section->address = 0;
@@ -2182,7 +2170,34 @@ load_debug_section (enum dwarf_section_d
section->size = size;
}
- return ret;
+ return 1;
+}
+
+int
+load_debug_section (enum dwarf_section_display_enum debug, void *file)
+{
+ struct dwarf_section *section = &debug_displays [debug].section;
+ bfd *abfd = file;
+ asection *sec;
+
+ /* If it is already loaded, do nothing. */
+ if (section->start != NULL)
+ return 1;
+
+ /* Locate the debug section. */
+ sec = bfd_get_section_by_name (abfd, section->uncompressed_name);
+ if (sec != NULL)
+ section->name = section->uncompressed_name;
+ else
+ {
+ sec = bfd_get_section_by_name (abfd, 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
@@ -2222,7 +2237,11 @@ dump_dwarf_section (bfd *abfd, asection
{
struct dwarf_section *sec = &debug_displays [i].section;
- if (load_debug_section (i, abfd))
+ if (strcmp (sec->uncompressed_name, match) == 0)
+ sec->name = sec->uncompressed_name;
+ else
+ sec->name = sec->compressed_name;
+ if (load_specific_debug_section (i, section, abfd))
{
debug_displays [i].display (sec, abfd);