From: Mark Wielaard Date: Fri, 12 Feb 2021 15:42:44 +0000 (+0100) Subject: readelf: Type DIE offset is from start of CU. X-Git-Tag: elfutils-0.184~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4019aa8148b3871111b8a6687bd9f9a62cba8539;p=thirdparty%2Felfutils.git readelf: Type DIE offset is from start of CU. While inspecting some type units I noticed the type offset seemed off. We were printing the offset as is, but it should include the offset of the unit. There was actually a testcase for this, run-readelf-types.sh but that had the same bug in the expected output. Fixed both. Signed-off-by: Mark Wielaard --- diff --git a/src/ChangeLog b/src/ChangeLog index 61cd98f46..918bf4411 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2021-02-12 Mark Wielaard + + * readelf.c (print_debug_units): Type DIE offset is from start CU. + 2021-02-12 Mark Wielaard * readelf.c (attr_callback): Don't handle blocks as expression diff --git a/src/readelf.c b/src/readelf.c index 9d2a25a44..715af3b3e 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -7794,7 +7794,8 @@ print_debug_units (Dwfl_Module *dwflmod, { Dwarf_Die typedie; Dwarf_Off dieoffset; - dieoffset = dwarf_dieoffset (dwarf_offdie_types (dbg, subdie_off, + dieoffset = dwarf_dieoffset (dwarf_offdie_types (dbg, cu->start + + subdie_off, &typedie)); printf (_(" Type unit at offset %" PRIu64 ":\n" " Version: %" PRIu16 diff --git a/tests/ChangeLog b/tests/ChangeLog index bc94512e2..533f5d232 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2021-02-12 Mark Wielaard + + * run-readelf-types.sh: Add CU start to type offset reference. + 2021-02-07 Alexander Miller * Makefile.am (TESTS_ENVIRONMENT): Quote variables. diff --git a/tests/run-readelf-types.sh b/tests/run-readelf-types.sh index a7af57342..4f3126970 100755 --- a/tests/run-readelf-types.sh +++ b/tests/run-readelf-types.sh @@ -97,7 +97,7 @@ DWARF section [32] '.debug_types' at offset 0x1260: specification (ref4) [ 34] Type unit at offset 67: Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4 - Type signature: 0x18763953736e2de0, Type offset: 0x25 [25] + Type signature: 0x18763953736e2de0, Type offset: 0x25 [68] [ 5a] type_unit abbrev: 1 language (data1) C_plus_plus (4) GNU_odr_signature (data8) 16005269134005989797