bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/28915] New: dwarf2.c doesn't correctly parse DW_UT_skeleton


From: jakub at redhat dot com
Subject: [Bug ld/28915] New: dwarf2.c doesn't correctly parse DW_UT_skeleton
Date: Mon, 21 Feb 2022 10:06:29 +0000

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

            Bug ID: 28915
           Summary: dwarf2.c doesn't correctly parse DW_UT_skeleton
           Product: binutils
           Version: 2.39 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: jakub at redhat dot com
  Target Milestone: ---

In https://bugzilla.redhat.com/show_bug.cgi?id=2052228 ld reports weird
/usr/bin/ld: /usr/bin/ld: DWARF error: could not find abbrev number 62
diagnostics.  The object file in question uses -gsplit-dwarf and 
readelf -wi
obj/third_party/swiftshader/src/Reactor/swiftshader_subzero/IceTargetLoweringX8664.o
Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:        0x2d (32-bit)
   Version:       5
   Unit Type:     DW_UT_skeleton (4)
   Abbrev Offset: 0x0
   Pointer Size:  8
   DWO ID:        0xaff01133f289df3e
 <0><14>: Abbrev Number: 1 (DW_TAG_skeleton_unit)
    <15>   DW_AT_ranges      : 0xc
    <19>   DW_AT_low_pc      : 0x0
    <21>   DW_AT_stmt_list   : 0x0
    <25>   DW_AT_dwo_name    : (indirect string, offset: 0x39):
obj/third_party/swiftshader/src/Reactor/swiftshader_subzero/IceTargetLoweringX8664.dwo
    <29>   DW_AT_comp_dir    : (indirect string, offset: 0x0):
/builddir/build/BUILD/chromium-98.0.4758.80/out/Headless
    <2d>   DW_AT_GNU_pubnames: 1
    <2d>   DW_AT_addr_base   : 0x8
62 is equal to 0x3e, i.e. the first byte of DWO ID.
So, this seems to be a bug in bfd/dwarf2.c (parse_comp_unit) which for
DW_UT_type does:
  if (unit_type == DW_UT_type)
    {
      /* Skip type signature.  */
      info_ptr += 8;

      /* Skip type offset.  */
      info_ptr += offset_size;
    }
but should at least also:
  else if (unit_type == DW_UT_skeleton || unit_type == DW_UT_split_compile)
    /* Skip DWO ID.  */
    info_ptr += 8;
at minimum.

Minimal reproducer would be something like:
cat > test.c <<\EOF
int foo (void);

int
main ()
{
  return foo ();
}
EOF
gcc -gdwarf-5 -gsplit-dwarf -o test{,.c}

The above will just avoid interpreting bytes in the DWO ID as abbrev number
followed by its attribute values etc., for reallly supporting split DWARF more
work would be needed (actually reading the DWO ID, read DW_AT_dwo_name and
DW_AT_comp_dir in the DW_TAG_skeleton_unit, try to find the dwo file and read
it in addition to the skeleton stuff (some sections remain in the .o file like
.debug_addr, others are in the dwo file and others are in both).

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]