[PATCH] readelf: Type DIE offset is from start of CU.
Mark Wielaard
mark@klomp.org
Fri Feb 12 15:47:37 GMT 2021
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>
---
src/ChangeLog | 4 ++++
src/readelf.c | 3 ++-
tests/ChangeLog | 4 ++++
tests/run-readelf-types.sh | 2 +-
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index e65620fd..552002b0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2021-02-12 Mark Wielaard <mark@klomp.org>
+
+ * readelf.c (print_debug_units): Type DIE offset is from start CU.
+
2021-02-03 Timm Bäder <tbaeder@redhat.com>
* ar.c (do_oper_extract): Extract should_truncate_fname function
diff --git a/src/readelf.c b/src/readelf.c
index 11692bb5..ccd59e39 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7792,7 +7792,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 e22fa455..27827ed3 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-08 Érico Nogueira <ericonr@disroot.org>
* run-debuginfod-find.sh: Check for cpio availability.
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
--
2.20.1
More information about the Elfutils-devel
mailing list