[binutils/readelf] Fix handling of DW_MACRO_define_strx in dwo file

When printing a DW_MACRO_define_strx entry in a .debug_macro.dwo section, we
run into:
...
 DW_MACRO_define_strx lineno : 0 macro : <no .debug_str_offsets section>
...

Fix this in display_debug_macro by passing the correct dwo argument to a
fetch_indexed_string call.

That works fine for readelf -w, with with readelf -wm we have:
...
 DW_MACRO_define_strx lineno : 0 macro : <no .debug_str_offsets.dwo section>
...

Fix this in display_debug_macro by doing load_debug_section_with_follow for
str_dwo / str_index_dwo sections instead of str / str_index sections when
handling .debug_macro.dwo.

PR 31735
This commit is contained in:
Tom de Vries
2024-05-15 09:45:55 +02:00
parent 7e4f1f4bc7
commit e548840a03
3 changed files with 27 additions and 5 deletions

View File

@@ -6293,9 +6293,17 @@ display_debug_macro (struct dwarf_section *section,
if (suffix && strcmp (suffix, ".dwo") == 0)
is_dwo = true;
load_debug_section_with_follow (str, file);
if (is_dwo)
{
load_debug_section_with_follow (str_dwo, file);
load_debug_section_with_follow (str_index_dwo, file);
}
else
{
load_debug_section_with_follow (str, file);
load_debug_section_with_follow (str_index, file);
}
load_debug_section_with_follow (line, file);
load_debug_section_with_follow (str_index, file);
introduce (section, false);
@@ -6504,7 +6512,7 @@ display_debug_macro (struct dwarf_section *section,
READ_ULEB (lineno, curr, end);
READ_ULEB (offset, curr, end);
string = (const unsigned char *)
fetch_indexed_string (offset, NULL, offset_size, false, 0);
fetch_indexed_string (offset, NULL, offset_size, is_dwo, 0);
if (op == DW_MACRO_define_strx)
printf (" DW_MACRO_define_strx ");
else