[PATCH 2/3] [binutils/readelf] Add fixme in display_debug_str_offsets

Tom de Vries tdevries@suse.de
Tue May 14 10:55:21 GMT 2024


While reading display_debug_str_offsets, I realized that the v4 split dwarf
handling bit doesn't assign entry_length, so it can be either 4 (32-bit dwarf)
or 8 (64-bit dwarf).  However, I think the cases for which it'll be 8 are
rare and odd enough to conclude that in practise we default to 32-bit
dwarf.

As mentioned in the fission documentation [1], whether a .debug_str_offsets
section is 32-bit or 64-bit dwarf depends on the compilation unit header in
the .debug_info.dwo section, which is currently not inspected.

For now:
- make an explicit choice for 32-bit dwarf by assiging 4 to entry_length, and
- add a fixme comment.

[1] https://gcc.gnu.org/wiki/DebugFission
---
 binutils/dwarf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 8125c64e1b6..f49989dc536 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -7971,6 +7971,14 @@ display_debug_str_offsets (struct dwarf_section *section,
 	  entries_end = end;
 	  debug_str_offsets_hdr_len = 0;
 
+	  /* FIXME: We assume 32-bit dwarf here.  According to
+	     https://gcc.gnu.org/wiki/DebugFission:
+	     The size of each entry is 4 bytes for DWARF-32 compilation units,
+	     or 8 bytes for DWARF-64 compilation units, as determined by the
+	     unit_length field of the compilation unit header in the
+	     .debug_info.dwo section.  */
+	  entry_length = 4;
+
 	  printf (_("    Length: %#" PRIx64 "\n"), length);
 	  printf (_("       Index   Offset [String]\n"));
 	}
-- 
2.35.3



More information about the Binutils mailing list