* 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>
+
+ * 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.
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);
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);
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]);
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;
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]);
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;
}
}
+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
else
abort ();
+ check_mach_o_dwarf (abfd);
+
bfd_map_over_sections (abfd, dump_dwarf_section, NULL);
free_debug_memory ();