summaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorH.J. Lu <hjl@lucon.org>2005-09-30 14:57:52 +0000
committerH.J. Lu <hjl@lucon.org>2005-09-30 14:57:52 +0000
commit090ae2866d264b513d6df7b94cf5e61e66ea0b36 (patch)
tree51a88c17a9ec3306a3043d59a7c03ff98e2358ae /binutils
parent0c94be59bbe2e9bf749643b46441bb9bef8f16cb (diff)
downloadbinutils-redhat-090ae2866d264b513d6df7b94cf5e61e66ea0b36.tar.gz
2005-09-30 H.J. Lu <hongjiu.lu@intel.com>
* dwarf.c (fetch_indirect_string): Adjust for section address. (process_debug_info): Likewise. (display_debug_loc): Likewise. (display_debug_ranges): Likewise. * objdump.c (mach_o_dwarf_sections): New. (generic_dwarf_sections): Likewise. (check_mach_o_dwarf): Likewise. (dump_dwarf): Call check_mach_o_dwarf.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog12
-rw-r--r--binutils/dwarf.c19
-rw-r--r--binutils/objdump.c47
3 files changed, 72 insertions, 6 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index a5cba760f3..1c02a0736e 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,17 @@
2005-09-30 H.J. Lu <hongjiu.lu@intel.com>
+ * dwarf.c (fetch_indirect_string): Adjust for section address.
+ (process_debug_info): Likewise.
+ (display_debug_loc): Likewise.
+ (display_debug_ranges): Likewise.
+
+ * objdump.c (mach_o_dwarf_sections): New.
+ (generic_dwarf_sections): Likewise.
+ (check_mach_o_dwarf): Likewise.
+ (dump_dwarf): Call check_mach_o_dwarf.
+
+2005-09-30 H.J. Lu <hongjiu.lu@intel.com>
+
* Makefile.am (objdump_SOURCES): Add dwarf.c.
* Makefile.in: Regenerated.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index a874d84447..b47a5bbbf5 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -287,6 +287,8 @@ fetch_indirect_string (unsigned long offset)
if (section->start == NULL)
return _("<no .debug_str section>");
+ /* DWARF sections under Mach-O have non-zero addresses. */
+ offset -= section->address;
if (offset > section->size)
{
warn (_("DW_FORM_strp offset too big: %lx\n"), offset);
@@ -1645,10 +1647,11 @@ process_debug_info (struct dwarf_section *section, void *file,
free_abbrevs ();
- /* Process the abbrevs used by this compilation unit. */
+ /* Process the abbrevs used by this compilation unit. DWARF
+ sections under Mach-O have non-zero addresses. */
process_abbrev_section
((unsigned char *) debug_displays [abbrev].section.start
- + compunit.cu_abbrev_offset,
+ + compunit.cu_abbrev_offset - debug_displays [abbrev].section.address,
(unsigned char *) debug_displays [abbrev].section.start
+ debug_displays [abbrev].section.size);
@@ -2371,7 +2374,8 @@ display_debug_loc (struct dwarf_section *section, void *file)
if (!seen_first_offset)
error (_("No location lists in .debug_info section!\n"));
- if (debug_information [first].loc_offsets [0] != 0)
+ /* DWARF sections under Mach-O have non-zero addresses. */
+ if (debug_information [first].loc_offsets [0] != section->address)
warn (_("Location lists in %s section start at 0x%lx\n"),
section->name, debug_information [first].loc_offsets [0]);
@@ -2397,7 +2401,8 @@ display_debug_loc (struct dwarf_section *section, void *file)
for (j = 0; j < debug_information [i].num_loc_offsets; j++)
{
has_frame_base = debug_information [i].have_frame_base [j];
- offset = debug_information [i].loc_offsets [j];
+ /* DWARF sections under Mach-O have non-zero addresses. */
+ offset = debug_information [i].loc_offsets [j] - section->address;
next = section_begin + offset;
base_address = debug_information [i].base_address;
@@ -2726,7 +2731,8 @@ display_debug_ranges (struct dwarf_section *section,
if (!seen_first_offset)
error (_("No range lists in .debug_info section!\n"));
- if (debug_information [first].range_lists [0] != 0)
+ /* DWARF sections under Mach-O have non-zero addresses. */
+ if (debug_information [first].range_lists [0] != section->address)
warn (_("Range lists in %s section start at 0x%lx\n"),
section->name, debug_information [first].range_lists [0]);
@@ -2746,7 +2752,8 @@ display_debug_ranges (struct dwarf_section *section,
for (j = 0; j < debug_information [i].num_range_lists; j++)
{
- offset = debug_information [i].range_lists [j];
+ /* DWARF sections under Mach-O have non-zero addresses. */
+ offset = debug_information [i].range_lists [j] - section->address;
next = section_begin + offset;
base_address = debug_information [i].base_address;
diff --git a/binutils/objdump.c b/binutils/objdump.c
index e49f0aecfc..513308e01d 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -2055,6 +2055,51 @@ dump_dwarf_section (bfd *abfd, asection *section,
}
}
+static const char *mach_o_dwarf_sections [] = {
+ "LC_SEGMENT.__DWARFA.__debug_abbrev", /* .debug_abbrev */
+ "LC_SEGMENT.__DWARFA.__debug_aranges", /* .debug_aranges */
+ "LC_SEGMENT.__DWARFA.__debug_frame", /* .debug_frame */
+ "LC_SEGMENT.__DWARFA.__debug_info", /* .debug_info */
+ "LC_SEGMENT.__DWARFA.__debug_line", /* .debug_line */
+ "LC_SEGMENT.__DWARFA.__debug_pubnames", /* .debug_pubnames */
+ ".eh_frame", /* .eh_frame */
+ "LC_SEGMENT.__DWARFA.__debug_macinfo", /* .debug_macinfo */
+ "LC_SEGMENT.__DWARFA.__debug_str", /* .debug_str */
+ "LC_SEGMENT.__DWARFA.__debug_loc", /* .debug_loc */
+ "LC_SEGMENT.__DWARFA.__debug_pubtypes", /* .debug_pubtypes */
+ "LC_SEGMENT.__DWARFA.__debug_ranges", /* .debug_ranges */
+ "LC_SEGMENT.__DWARFA.__debug_static_func", /* .debug_static_func */
+ "LC_SEGMENT.__DWARFA.__debug_static_vars", /* .debug_static_vars */
+ "LC_SEGMENT.__DWARFA.__debug_types", /* .debug_types */
+ "LC_SEGMENT.__DWARFA.__debug_weaknames" /* .debug_weaknames */
+};
+
+static const char *generic_dwarf_sections [max];
+
+static void
+check_mach_o_dwarf (bfd *abfd)
+{
+ static enum bfd_flavour old_flavour = bfd_target_unknown_flavour;
+ enum bfd_flavour current_flavour = bfd_get_flavour (abfd);
+ enum dwarf_section_display_enum i;
+
+ if (generic_dwarf_sections [0] == NULL)
+ for (i = 0; i < max; i++)
+ generic_dwarf_sections [i] = debug_displays[i].section.name;
+
+ if (old_flavour != current_flavour)
+ {
+ if (current_flavour == bfd_target_mach_o_flavour)
+ for (i = 0; i < max; i++)
+ debug_displays[i].section.name = mach_o_dwarf_sections [i];
+ else if (old_flavour == bfd_target_mach_o_flavour)
+ for (i = 0; i < max; i++)
+ debug_displays[i].section.name = generic_dwarf_sections [i];
+
+ old_flavour = current_flavour;
+ }
+}
+
/* Dump the dwarf debugging information. */
static void
@@ -2074,6 +2119,8 @@ dump_dwarf (bfd *abfd)
else
abort ();
+ check_mach_o_dwarf (abfd);
+
bfd_map_over_sections (abfd, dump_dwarf_section, NULL);
free_debug_memory ();