diff options
author | Mark Wielaard <mark@klomp.org> | 2021-02-12 16:42:44 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2021-02-17 16:55:53 +0100 |
commit | 4019aa8148b3871111b8a6687bd9f9a62cba8539 (patch) | |
tree | 110ffa6a02148e58947a69c6b11e046eb2b6a7da | |
parent | ce6a126b01b2c8951dd941a95a92be71e34f2088 (diff) | |
download | elfutils-4019aa8148b3871111b8a6687bd9f9a62cba8539.tar.gz |
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 <mark@klomp.org>
-rw-r--r-- | src/ChangeLog | 4 | ||||
-rw-r--r-- | src/readelf.c | 3 | ||||
-rw-r--r-- | tests/ChangeLog | 4 | ||||
-rwxr-xr-x | tests/run-readelf-types.sh | 2 |
4 files changed, 11 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 61cd98f4..918bf441 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2021-02-12 Mark Wielaard <mark@klomp.org> + * readelf.c (print_debug_units): Type DIE offset is from start CU. + +2021-02-12 Mark Wielaard <mark@klomp.org> + * readelf.c (attr_callback): Don't handle blocks as expression blocks for DWARF version 4 or higher. diff --git a/src/readelf.c b/src/readelf.c index 9d2a25a4..715af3b3 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 bc94512e..533f5d23 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2021-02-12 Mark Wielaard <mark@klomp.org> + + * run-readelf-types.sh: Add CU start to type offset reference. + 2021-02-07 Alexander Miller <alex.miller@gmx.de> * Makefile.am (TESTS_ENVIRONMENT): Quote variables. diff --git a/tests/run-readelf-types.sh b/tests/run-readelf-types.sh index a7af5734..4f312697 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 |