]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: Type DIE offset is from start of CU.
authorMark Wielaard <mark@klomp.org>
Fri, 12 Feb 2021 15:42:44 +0000 (16:42 +0100)
committerMark Wielaard <mark@klomp.org>
Wed, 17 Feb 2021 15:55:53 +0000 (16:55 +0100)
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
src/readelf.c
tests/ChangeLog
tests/run-readelf-types.sh

index 61cd98f46bc7076b03c694dfb89b60845dd40fdc..918bf441147d94885a54702debbf5447a7339b86 100644 (file)
@@ -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-12  Mark Wielaard  <mark@klomp.org>
 
        * readelf.c (attr_callback): Don't handle blocks as expression
index 9d2a25a44cea243de0a43c9ca55ca6aa45e8c581..715af3b3e616a3d29b5b8bb66983be629bfb5a9e 100644 (file)
@@ -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
index bc94512e2d41508399fbb97ee967f1760479f560..533f5d232aa2657cd45c9d3e265c656864c5a33e 100644 (file)
@@ -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.
index a7af57342720fac68a42b4ced7796f4d79c0dab4..4f3126970305036e4fa82e712d7d9e64c2d67222 100755 (executable)
@@ -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