From 9b87f84a3513c852eca395e3aa47081ef2f12e60 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Tue, 9 Feb 2021 14:27:28 +0100 Subject: [PATCH] [binutils] Handle DW_UT_skeleton/split_compile in process_debug_info With this exec: ... $ gcc -gsplit-dwarf hello.c -gdwarf-5 ... we run into: ... $ readelf -w a.out > READELF readelf: Warning: CU at offset c7 contains corrupt or unsupported unit type: 4. readelf: Warning: CU at offset c7 contains corrupt or unsupported unit type: 4. ... Fix this by handling DW_UT_skeleton and DW_UT_split_compile in process_debug_info. Note that this just adds the parsing of DWO_id, but not yet any printing of it. Tested on x86_64-linux. binutils/ChangeLog: 2021-02-09 Tom de Vries PR binutils/27386 * dwarf.c (process_debug_info): Handling DW_UT_skeleton and DW_UT_split_compile. --- binutils/ChangeLog | 6 ++++++ binutils/dwarf.c | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 4da4636e961..0f07cd42eaf 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2021-02-09 Tom de Vries + + PR binutils/27386 + * dwarf.c (process_debug_info): Handling DW_UT_skeleton and + DW_UT_split_compile. + 2021-02-09 Alan Modra * testsuite/lib/binutils-common.exp (supports_gnu_osabi): Remove diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 19475e6cec3..6797dd158d6 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -3581,6 +3581,13 @@ process_debug_info (struct dwarf_section * section, SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end); + if (compunit.cu_unit_type == DW_UT_split_compile + || compunit.cu_unit_type == DW_UT_skeleton) + { + uint64_t dwo_id; + SAFE_BYTE_GET_AND_INC (dwo_id, hdrptr, 8, end); + } + if (this_set == NULL) { abbrev_base = 0; @@ -3684,6 +3691,13 @@ process_debug_info (struct dwarf_section * section, if (compunit.cu_version < 5) SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end); + if (compunit.cu_unit_type == DW_UT_split_compile + || compunit.cu_unit_type == DW_UT_skeleton) + { + uint64_t dwo_id; + SAFE_BYTE_GET_AND_INC (dwo_id, hdrptr, 8, end); + } + /* PR 17512: file: 001-108546-0.001:0.1. */ if (compunit.cu_pointer_size < 2 || compunit.cu_pointer_size > 8) { @@ -3800,7 +3814,9 @@ process_debug_info (struct dwarf_section * section, if (compunit.cu_unit_type != DW_UT_compile && compunit.cu_unit_type != DW_UT_partial - && compunit.cu_unit_type != DW_UT_type) + && compunit.cu_unit_type != DW_UT_type + && compunit.cu_unit_type != DW_UT_split_compile + && compunit.cu_unit_type != DW_UT_skeleton) { warn (_("CU at offset %s contains corrupt or " "unsupported unit type: %d.\n"), -- 2.30.2