https://sourceware.org/bugzilla/show_bug.cgi?id=31735

            Bug ID: 31735
           Summary: [binutils, readelf] debug_str_offsets used, should use
                    debug_str_offsets.dwo
           Product: binutils
           Version: 2.43 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

[ Using gcc trunk, and the tentative patch for this (
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115066 ) PR. ]

This compilation now generates sane dwarf:
...
$ gcc -gdwarf-4 -gsplit-dwarf /data/vries/hello.c -g3 -save-temps -dA
...

But with readelf -w a.out, we get:
...
Contents of the .debug_macro.dwo section (loaded from
/home/vries/gcc/a-hello.dwo):

  Offset:                      0
  Version:                     4
  Offset size:                 4
  Offset into .debug_line:     0

 DW_MACRO_start_file - lineno: 0 filenum: 1
 DW_MACRO_define_strx lineno : 0 macro : <no .debug_str_offsets section>
 DW_MACRO_define_strx lineno : 0 macro : <no .debug_str_offsets section>
 DW_MACRO_define_strx lineno : 0 macro : <no .debug_str_offsets section>
...

Fixed by:
...
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index c5ccc50dae7..ae3a9d68a5b 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -6504,7 +6504,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
...
after which we get:
...
Contents of the .debug_macro.dwo section (loaded from
/home/vries/gcc/a-hello.dwo):

  Offset:                      0
  Version:                     4
  Offset size:                 4
  Offset into .debug_line:     0

 DW_MACRO_start_file - lineno: 0 filenum: 1
 DW_MACRO_define_strx lineno : 0 macro : __STDC__ 1
 DW_MACRO_define_strx lineno : 0 macro : __STDC_VERSION__ 201710L
 DW_MACRO_define_strx lineno : 0 macro : __STDC_UTF_16__ 1
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to