From d296b73620d0ea069b8a30c0bb77f52e32618c6a Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 5 Mar 2021 12:56:24 +0000 Subject: Fix the dislay of .debug_macro.dwo sections. PR 27387 * dwarf.c (display_debug_macro): Handle the displaying of DW_MACRO_define_strp and DW_MACRO_undef_strp in v4 .debug_macro.dwo sections. --- binutils/dwarf.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'binutils/dwarf.c') diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 15f0bd0..74f28f5 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -690,7 +690,7 @@ fetch_indirect_string (dwarf_vma offset) if (offset >= section->size) { - warn (_("DW_FORM_strp offset too big: %s\n"), + warn (_("DW_FORM_strp offset too big: 0x%s\n"), dwarf_vmatoa ("x", offset)); return (const unsigned char *) _(""); } @@ -718,7 +718,7 @@ fetch_indirect_line_string (dwarf_vma offset) if (offset >= section->size) { - warn (_("DW_FORM_line_strp offset too big: %s\n"), + warn (_("DW_FORM_line_strp offset too big: 0x%s\n"), dwarf_vmatoa ("x", offset)); return (const unsigned char *) _(""); } @@ -803,7 +803,7 @@ fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set, if (index_offset >= length) { - warn (_("DW_FORM_GNU_str_index offset too big: %s vs %s\n"), + warn (_("DW_FORM_GNU_str_index offset too big: 0x%s vs 0x%s\n"), dwarf_vmatoa ("x", index_offset), dwarf_vmatoa ("x", length)); return _(""); @@ -813,7 +813,7 @@ fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set, str_offset -= str_section->address; if (str_offset >= str_section->size) { - warn (_("DW_FORM_GNU_str_index indirect offset too big: %s\n"), + warn (_("DW_FORM_GNU_str_index indirect offset too big: 0x%s\n"), dwarf_vmatoa ("x", str_offset)); return _(""); } @@ -839,7 +839,7 @@ fetch_indexed_value (dwarf_vma offset, dwarf_vma bytes) if (offset + bytes > section->size) { - warn (_("Offset into section %s too big: %s\n"), + warn (_("Offset into section %s too big: 0x%s\n"), section->name, dwarf_vmatoa ("x", offset)); return ""; } @@ -6045,17 +6045,22 @@ display_debug_macro (struct dwarf_section *section, unsigned char *end = start + section->size; unsigned char *curr = start; unsigned char *extended_op_buf[256]; + bfd_boolean is_dwo = FALSE; + const char *suffix = strrchr (section->name, '.'); + + if (suffix && strcmp (suffix, ".dwo") == 0) + is_dwo = TRUE; load_debug_section_with_follow (str, file); load_debug_section_with_follow (line, file); load_debug_section_with_follow (str_index, file); - + introduce (section, FALSE); while (curr < end) { unsigned int lineno, version, flags; - unsigned int offset_size = 4; + unsigned int offset_size; const unsigned char *string; dwarf_vma line_offset = 0, sec_offset = curr - start, offset; unsigned char **extended_ops = NULL; @@ -6069,8 +6074,7 @@ display_debug_macro (struct dwarf_section *section, } SAFE_BYTE_GET_AND_INC (flags, curr, 1, end); - if (flags & 1) - offset_size = 8; + offset_size = (flags & 1) ? 8 : 4; printf (_(" Offset: 0x%lx\n"), (unsigned long) sec_offset); printf (_(" Version: %d\n"), version); @@ -6202,7 +6206,10 @@ display_debug_macro (struct dwarf_section *section, case DW_MACRO_define_strp: READ_ULEB (lineno, curr, end); - SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); + if (version == 4 && is_dwo) + READ_ULEB (offset, curr, end); + else + SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); string = fetch_indirect_string (offset); printf (_(" DW_MACRO_define_strp - lineno : %d macro : %s\n"), lineno, string); @@ -6210,7 +6217,10 @@ display_debug_macro (struct dwarf_section *section, case DW_MACRO_undef_strp: READ_ULEB (lineno, curr, end); - SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); + if (version == 4 && is_dwo) + READ_ULEB (offset, curr, end); + else + SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); string = fetch_indirect_string (offset); printf (_(" DW_MACRO_undef_strp - lineno : %d macro : %s\n"), lineno, string); -- cgit v1.1