]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Handle split DWARF in dwarf_entrypc
authorOmar Sandoval <osandov@fb.com>
Wed, 27 Sep 2023 18:20:51 +0000 (11:20 -0700)
committerMark Wielaard <mark@klomp.org>
Tue, 3 Oct 2023 15:15:37 +0000 (17:15 +0200)
If a DIE has no DW_AT_entry_pc attribute, dwarf_entrypc looks for
DW_AT_low_pc in that DIE.  But for a split compilation unit DIE,
DW_AT_low_pc is in the corresponding skeleton DIE, so this fails.
dwarf_lowpc already handles this fallback, so use it instead.

Signed-off-by: Omar Sandoval <osandov@fb.com>
libdw/ChangeLog
libdw/dwarf_entrypc.c
tests/ChangeLog
tests/run-varlocs.sh

index 0014aeb1f21702ef34d292005f9abfcafef24d48..af74ce0d04b0d7e7e231473bef8657c477da575b 100644 (file)
@@ -1,6 +1,7 @@
 2023-09-27  Omar Sandoval  <osandov@fb.com>
 
        * libdw_find_split_unit.c (try_split_file): Make static.
+       * dwarf_entrypc.c (dwarf_entrypc): Call dwarf_lowpc.
 
 2023-02-22  Mark Wielaard  <mark@klomp.org>
 
index 0ef3b0ea35b6f8ccd648c468ebe9707cae00831e..543567d4cc7a652e44b3abd947d3628a28309c38 100644 (file)
 int
 dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr)
 {
-  Dwarf_Attribute attr_mem;
-
-  return INTUSE(dwarf_formaddr) (INTUSE(dwarf_attr) (die, DW_AT_entry_pc,
-                                                    &attr_mem)
-                                ?: INTUSE(dwarf_attr) (die, DW_AT_low_pc,
-                                                       &attr_mem),
-                                return_addr);
+  Dwarf_Attribute attr_mem, *attr;
+  if ((attr = INTUSE(dwarf_attr) (die, DW_AT_entry_pc, &attr_mem)) != NULL)
+    return INTUSE(dwarf_formaddr) (attr, return_addr);
+  else
+    return INTUSE(dwarf_lowpc) (die, return_addr);
 }
 INTDEF(dwarf_entrypc)
index d816873ce083165b50daf4ec0b7e08de65dd7428..f934c114bdc2f625958316f460751eb183cb3328 100644 (file)
@@ -1,3 +1,7 @@
+2023-09-27  Omar Sandoval  <osandov@fb.com>
+
+       * run-varlocs.sh: Add entry PC to split units.
+
 2023-04-21  Frank Ch. Eigler <fche@redhat.com>
 
        * run-debuginfod-IXr.sh: New test.
index b26217760b376bcaa0a70d3232fe2cd8d25e119a..cbbcf6c7b87f015f39dbad079c44c1a72ac0070b 100755 (executable)
@@ -206,7 +206,7 @@ testfiles testfilesplitranges5.debug
 testfiles testfile-ranges-hello5.dwo testfile-ranges-world5.dwo
 testrun_compare ${abs_top_builddir}/tests/varlocs --debug -e testfilesplitranges5.debug <<\EOF
 module 'testfilesplitranges5.debug'
-[14] CU 'hello.c'
+[14] CU 'hello.c'@0
   [1d] function 'no_say'@401160
     frame_base: {call_frame_cfa {...}}
     [33] parameter 'prefix'
@@ -236,7 +236,7 @@ module 'testfilesplitranges5.debug'
     [111] parameter 'count'
       [401150,401160) {reg4}
 module 'testfilesplitranges5.debug'
-[14] CU 'world.c'
+[14] CU 'world.c'@401180
   [1d] function 'no_main'@4011d0
     frame_base: {call_frame_cfa {...}}
     [35] parameter 'argc'
@@ -282,7 +282,7 @@ testfiles testfilesplitranges4.debug
 testfiles testfile-ranges-hello.dwo testfile-ranges-world.dwo
 testrun_compare ${abs_top_builddir}/tests/varlocs --debug -e testfilesplitranges4.debug <<\EOF
 module 'testfilesplitranges4.debug'
-[b] CU 'hello.c'
+[b] CU 'hello.c'@0
   [18] function 'no_say'@4004f0
     frame_base: {call_frame_cfa {...}}
     [2f] parameter 'prefix'
@@ -310,7 +310,7 @@ module 'testfilesplitranges4.debug'
     [102] parameter 'count'
       [4004e0,4004f0) {reg4}
 module 'testfilesplitranges4.debug'
-[b] CU 'world.c'
+[b] CU 'world.c'@400500
   [18] function 'no_main'@400550
     frame_base: {call_frame_cfa {...}}
     [2f] parameter 'argc'
@@ -373,7 +373,7 @@ EOF
 testfiles testfile-addrx_constx-5 addrx_constx-5.dwo
 testrun_compare ${abs_top_builddir}/tests/varlocs --exprlocs -e testfile-addrx_constx-5 <<\EOF
 module 'testfile-addrx_constx-5'
-[14] CU 'addrx_constx.c'
+[14] CU 'addrx_constx.c'@0
   producer (strx)
   language (data1)
   name (strx)
@@ -467,7 +467,7 @@ EOF
 testfiles testfile-addrx_constx-4 addrx_constx-4.dwo
 testrun_compare ${abs_top_builddir}/tests/varlocs --exprlocs -e testfile-addrx_constx-4 <<\EOF
 module 'testfile-addrx_constx-4'
-[b] CU 'addrx_constx.c'
+[b] CU 'addrx_constx.c'@0
   producer (GNU_str_index)
   language (data1)
   name (GNU_str_index)
@@ -565,7 +565,7 @@ testfiles splitdwarf4-not-split4.dwo
 
 testrun_compare ${abs_top_builddir}/tests/varlocs --debug -e testfile-splitdwarf4-not-split4.debug <<\EOF
 module 'testfile-splitdwarf4-not-split4.debug'
-[b] CU 'splitdwarf4-not-split4.c'
+[b] CU 'splitdwarf4-not-split4.c'@0
   [18] function 'main'@401050
     frame_base: {call_frame_cfa {...}}
     [30] parameter 'argc'