https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86456

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Looks like binutils 2.30 readelf still isn't happy with dwarf5 produced for
LTO.

readelf: Error: Internal error: DWARF version is not 2, 3 or 4.
readelf: Warning: DIE at offset 0x12f refers to abbreviation number 90 which
does not exist
readelf: Error: Internal error: DWARF version is not 2, 3 or 4.
readelf: Warning: DIE at offset 0x12f refers to abbreviation number 90 which
does not exist
readelf: Error: Internal error: DWARF version is not 2, 3 or 4.
readelf: Warning: DIE at offset 0x12f refers to abbreviation number 90 which
does not exist
readelf: Warning: Unable to load/parse the .debug_info section, so cannot
interpret the .debug_loc section.
readelf: Warning: Unable to load/parse the .debug_info section, so cannot
interpret the .debug_ranges section.

the obvious error part is

  Compilation Unit @ offset 0x100:
   Length:        0x47 (32-bit)
   Version:       5
   Abbrev Offset: 0x90
   Pointer Size:  8
 <0><10c>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <10d>   DW_AT_producer    : (indirect string, offset: 0x236): GNU GIMPLE
9.0.0 20180716 (experimental) -mtune=generic -march=x86-64 -mtune=generic
-march=x86-64 -g -gdwarf-5 -fno-openmp -fno-openacc -fltrans
    <111>   DW_AT_language    : 29      (C11)
    <112>   DW_AT_name        : (indirect string, offset: 0x229): <artificial>
    <116>   DW_AT_comp_dir    : (indirect string, offset: 0x1ac):
/abuild/rguenther/obj-sccvn-g/gcc
    <11a>   DW_AT_low_pc      : 0x4004b2
    <122>   DW_AT_high_pc     : 0xb
    <12a>   DW_AT_stmt_list   : 0x11d
 <1><12e>: Abbrev Number: 2 (DW_TAG_imported_unit)
    <12f>   DW_AT_import      : <0x0>   [Abbrev Number: 42]
 <1><12f>: Abbrev Number: 90
Contents of the .debug_abbrev section:

you can see the import looks garbled.

   2      DW_TAG_imported_unit    [no children]
    DW_AT_import       DW_FORM_ref_addr
    DW_AT value: 0     DW_FORM value: 0

but the dwarf-4 variant which looks fine has the same abbrev.

 <1><12c>: Abbrev Number: 2 (DW_TAG_imported_unit)
    <12d>   DW_AT_import      : <0xd9>  [Abbrev Number: 1]

I can see we output the import "offset" with size 4 (but -gdwarf-4 works).
The assembly looks good as far as I can see:

.Ldebug_info0:
        .long   0x47    # Length of Compilation Unit Info
        .value  0x5     # DWARF version number
        .byte   0x1     # DW_UT_compile
        .byte   0x8     # Pointer Size (in bytes)
        .long   .Ldebug_abbrev0 # Offset Into Abbrev. Section
        .uleb128 0x1    # (DIE (0xc) DW_TAG_compile_unit)
        .long   .LASF0  # DW_AT_producer: "GNU GIMPLE 9.0.0 20180716
(experimental) -mtune=generic -march=x86-64 -mtune=generic -march=x86-64 -g
-gdwarf-5 -fno-openmp -fno-openacc -fltrans"
        .byte   0x1d    # DW_AT_language
        .long   .LASF1  # DW_AT_name: "<artificial>"
        .long   .LASF2  # DW_AT_comp_dir: "/abuild/rguenther/obj-sccvn-g/gcc"
        .quad   .Ltext0 # DW_AT_low_pc
        .quad   .Letext0-.Ltext0        # DW_AT_high_pc
        .long   .Ldebug_line0   # DW_AT_stmt_list
        .uleb128 0x2    # (DIE (0x2e) DW_TAG_imported_unit)
        .long   t.c.ca3ae4e6+12 # DW_AT_import
        .uleb128 0x3    # (DIE (0x33) DW_TAG_subprogram)
        .long   t.c.ca3ae4e6+30 # DW_AT_abstract_origin
        .quad   .LFB0   # DW_AT_low_pc
...
.Ldebug_abbrev0:
        .uleb128 0x1    # (abbrev code)
        .uleb128 0x11   # (TAG: DW_TAG_compile_unit)
        .byte   0x1     # DW_children_yes
        .uleb128 0x25   # (DW_AT_producer)
        .uleb128 0xe    # (DW_FORM_strp)
        .uleb128 0x13   # (DW_AT_language)
        .uleb128 0xb    # (DW_FORM_data1)
        .uleb128 0x3    # (DW_AT_name)
        .uleb128 0xe    # (DW_FORM_strp)
        .uleb128 0x1b   # (DW_AT_comp_dir)
        .uleb128 0xe    # (DW_FORM_strp)
        .uleb128 0x11   # (DW_AT_low_pc)
        .uleb128 0x1    # (DW_FORM_addr)
        .uleb128 0x12   # (DW_AT_high_pc)
        .uleb128 0x7    # (DW_FORM_data8)
        .uleb128 0x10   # (DW_AT_stmt_list)
        .uleb128 0x17   # (DW_FORM_sec_offset)
        .byte   0
        .byte   0
        .uleb128 0x2    # (abbrev code)
        .uleb128 0x3d   # (TAG: DW_TAG_imported_unit)
        .byte   0       # DW_children_no
        .uleb128 0x18   # (DW_AT_import)
        .uleb128 0x10   # (DW_FORM_ref_addr)
        .byte   0
        .byte   0
        .uleb128 0x3    # (abbrev code)
        .uleb128 0x2e   # (TAG: DW_TAG_subprogram)

it's somewhat weird.  Even more so since gdb seems to be just happy ...

readelf is happy when not using LTO but -gdwarf-5 though...

Reply via email to