From 7cfe2c16f9ddaa7478a2d97dd893c6b89080020a Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 24 Nov 2017 19:29:57 +0100 Subject: readelf: Handle .debug_loclists. The new DWARF5 .debug_loclists sections are like .debug_rnglists, but plus locations. For Split Dwarf GCC generates the .debug_loclists fully in the split .dwo file. Any references to addresses need to be resolved through the skeleton .debug_addr section. Signed-off-by: Mark Wielaard --- tests/ChangeLog | 4 + tests/run-readelf-loc.sh | 560 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 564 insertions(+) (limited to 'tests') diff --git a/tests/ChangeLog b/tests/ChangeLog index 5eb1e77f..6e366eb3 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2018-04-12 Mark Wielaard + + * run-readelf-loc.sh: Add new testcases. + 2018-04-06 Mark Wielaard * testfileranges5.debug.bz2: New testfile. diff --git a/tests/run-readelf-loc.sh b/tests/run-readelf-loc.sh index e5152df8..622cc196 100755 --- a/tests/run-readelf-loc.sh +++ b/tests/run-readelf-loc.sh @@ -167,4 +167,564 @@ DWARF section [34] '.debug_ranges' at offset 0xd94: range 12, 1a EOF +# .debug_rnglists (DWARF5), see tests/testfile-dwarf-45.source +testfiles testfile-dwarf-5 +testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=loc testfile-dwarf-5<<\EOF + +DWARF section [31] '.debug_loclists' at offset 0x1c0c: +Table at Offset 0x0: + + Length: 96 + DWARF version: 5 + Address size: 8 + Segment size: 0 + Offset entries: 0 + CU [ c] base: 0x0000000000400510 + + Offset: c, Index: 0 + offset_pair 0, a + 0x0000000000400510 .. + 0x0000000000400519 + [ 0] reg5 + offset_pair a, 34 + 0x000000000040051a .. + 0x0000000000400543 + [ 0] entry_value: + [ 0] reg5 + [ 3] stack_value + end_of_list + + Offset: 1a, Index: e + offset_pair 1b, 2d + 0x000000000040052b .. + 0x000000000040053c + [ 0] addr 0x601038 + end_of_list + + Offset: 28, Index: 1c + offset_pair 1b, 21 + 0x000000000040052b .. + 0x0000000000400530 + [ 0] reg5 + end_of_list + + Offset: 2e, Index: 22 + offset_pair 1b, 27 + 0x000000000040052b .. + 0x0000000000400536 + [ 0] reg5 + offset_pair 29, 2d + 0x0000000000400539 .. + 0x000000000040053c + [ 0] reg5 + end_of_list + + Offset: 39, Index: 2d + offset_pair 21, 27 + 0x0000000000400531 .. + 0x0000000000400536 + [ 0] reg5 + offset_pair 29, 2d + 0x0000000000400539 .. + 0x000000000040053c + [ 0] reg5 + end_of_list + + Offset: 44, Index: 38 + offset_pair 21, 2d + 0x0000000000400531 .. + 0x000000000040053c + [ 0] reg5 + end_of_list + + Offset: 4a, Index: 3e + offset_pair 2d, 33 + 0x000000000040053d .. + 0x0000000000400542 + [ 0] reg5 + end_of_list + + Offset: 50, Index: 44 + offset_pair 40, 4f + 0x0000000000400550 .. + 0x000000000040055e + [ 0] reg5 + offset_pair 4f, 51 + 0x000000000040055f .. + 0x0000000000400560 + [ 0] entry_value: + [ 0] reg5 + [ 3] stack_value + end_of_list + + Offset: 5e, Index: 52 + offset_pair 40, 50 + 0x0000000000400550 .. + 0x000000000040055f + [ 0] reg5 + end_of_list + +Table at Offset 0x64: + + Length: 159 + DWARF version: 5 + Address size: 8 + Segment size: 0 + Offset entries: 0 + CU [ 218] base: 000000000000000000 + + Offset: 70, Index: 0 + base_address 0x400410 + 0x0000000000400410
+ offset_pair 0, 14 + 0x0000000000400410
.. + 0x0000000000400423 + [ 0] reg5 + offset_pair 14, 20 + 0x0000000000400424 .. + 0x000000000040042f + [ 0] entry_value: + [ 0] reg5 + [ 3] stack_value + end_of_list + + Offset: 87, Index: 17 + base_address 0x400410 + 0x0000000000400410
+ offset_pair 0, 18 + 0x0000000000400410
.. + 0x0000000000400427 + [ 0] reg4 + offset_pair 18, 20 + 0x0000000000400428 .. + 0x000000000040042f + [ 0] entry_value: + [ 0] reg4 + [ 3] stack_value + end_of_list + + Offset: 9e, Index: 2e + start_length 0x400421, 7 + 0x0000000000400421 .. + 0x0000000000400427 + [ 0] reg0 + end_of_list + + Offset: ab, Index: 3b + base_address 0x400570 + 0x0000000000400570 + offset_pair 0, 8 + 0x0000000000400570 .. + 0x0000000000400577 + [ 0] reg5 + offset_pair 8, 2b + 0x0000000000400578 .. + 0x000000000040059a + [ 0] entry_value: + [ 0] reg5 + [ 3] stack_value + end_of_list + + Offset: c2, Index: 52 + start_length 0x400588, b + 0x0000000000400588 .. + 0x0000000000400592 + [ 0] reg0 + end_of_list + + Offset: cf, Index: 5f + base_address 0x400588 + 0x0000000000400588 + offset_pair 0, 2 + 0x0000000000400588 .. + 0x0000000000400589 + [ 0] reg1 + offset_pair 2, 7 + 0x000000000040058a .. + 0x000000000040058e + [ 0] reg5 + offset_pair 7, b + 0x000000000040058f .. + 0x0000000000400592 + [ 0] entry_value: + [ 0] reg5 + [ 3] deref_size 1 + [ 5] const1u 56 + [ 7] shl + [ 8] const1u 56 + [10] shra + [11] stack_value + end_of_list + + Offset: f3, Index: 83 + base_address 0x400588 + 0x0000000000400588 + offset_pair 0, 2 + 0x0000000000400588 .. + 0x0000000000400589 + [ 0] reg1 + offset_pair 2, b + 0x000000000040058a .. + 0x0000000000400592 + [ 0] reg5 + end_of_list + +EOF + +# Same as above, but for DWARF4, note completely different encoding, but +# the information is the same (check with diff -uwb). +testfiles testfile-dwarf-4 +testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=loc testfile-dwarf-4<<\EOF + +DWARF section [31] '.debug_loc' at offset 0x1c86: + + CU [ b] base: 0x0000000000400510 + [ 0] range 0, a + 0x0000000000400510 .. + 0x0000000000400519 + [ 0] reg5 + range a, 34 + 0x000000000040051a .. + 0x0000000000400543 + [ 0] GNU_entry_value: + [ 0] reg5 + [ 3] stack_value + [ 39] range 1b, 2d + 0x000000000040052b .. + 0x000000000040053c + [ 0] addr 0x601038 + [ 64] range 1b, 21 + 0x000000000040052b .. + 0x0000000000400530 + [ 0] reg5 + [ 87] range 1b, 27 + 0x000000000040052b .. + 0x0000000000400536 + [ 0] reg5 + range 29, 2d + 0x0000000000400539 .. + 0x000000000040053c + [ 0] reg5 + [ bd] range 21, 27 + 0x0000000000400531 .. + 0x0000000000400536 + [ 0] reg5 + range 29, 2d + 0x0000000000400539 .. + 0x000000000040053c + [ 0] reg5 + [ f3] range 21, 2d + 0x0000000000400531 .. + 0x000000000040053c + [ 0] reg5 + [ 116] range 2d, 33 + 0x000000000040053d .. + 0x0000000000400542 + [ 0] reg5 + [ 139] range 40, 4f + 0x0000000000400550 .. + 0x000000000040055e + [ 0] reg5 + range 4f, 51 + 0x000000000040055f .. + 0x0000000000400560 + [ 0] GNU_entry_value: + [ 0] reg5 + [ 3] stack_value + [ 172] range 40, 50 + 0x0000000000400550 .. + 0x000000000040055f + [ 0] reg5 + + CU [ 21c] base: 000000000000000000 + [ 195] range 400410, 400424 + 0x0000000000400410
.. + 0x0000000000400423 + [ 0] reg5 + range 400424, 400430 + 0x0000000000400424 .. + 0x000000000040042f + [ 0] GNU_entry_value: + [ 0] reg5 + [ 3] stack_value + [ 1ce] range 400410, 400428 + 0x0000000000400410
.. + 0x0000000000400427 + [ 0] reg4 + range 400428, 400430 + 0x0000000000400428 .. + 0x000000000040042f + [ 0] GNU_entry_value: + [ 0] reg4 + [ 3] stack_value + [ 207] range 400421, 400428 + 0x0000000000400421 .. + 0x0000000000400427 + [ 0] reg0 + [ 22a] range 400570, 400578 + 0x0000000000400570 .. + 0x0000000000400577 + [ 0] reg5 + range 400578, 40059b + 0x0000000000400578 .. + 0x000000000040059a + [ 0] GNU_entry_value: + [ 0] reg5 + [ 3] stack_value + [ 263] range 400588, 400593 + 0x0000000000400588 .. + 0x0000000000400592 + [ 0] reg0 + [ 286] range 400588, 40058a + 0x0000000000400588 .. + 0x0000000000400589 + [ 0] reg1 + range 40058a, 40058f + 0x000000000040058a .. + 0x000000000040058e + [ 0] reg5 + range 40058f, 400593 + 0x000000000040058f .. + 0x0000000000400592 + [ 0] GNU_entry_value: + [ 0] reg5 + [ 3] deref_size 1 + [ 5] const1u 56 + [ 7] shl + [ 8] const1u 56 + [10] shra + [11] stack_value + [ 2da] range 400588, 40058a + 0x0000000000400588 .. + 0x0000000000400589 + [ 0] reg1 + range 40058a, 400593 + 0x000000000040058a .. + 0x0000000000400592 + [ 0] reg5 +EOF + +# Split DWARF5 variant. Note that the .debug_loclists moved to the .dwo file +# and now uses an index and addrx indirections. +testfiles testfile-splitdwarf-5 testfile-hello5.dwo testfile-world5.dwo +testrun_compare ${abs_top_builddir}/src/readelf --debug-dump=loc --dwarf-skeleton=testfile-splitdwarf-5 testfile-hello5.dwo testfile-world5.dwo <<\EOF + +testfile-hello5.dwo: + + +DWARF section [ 3] '.debug_loclists.dwo' at offset 0x236: +Table at Offset 0x0: + + Length: 125 + DWARF version: 5 + Address size: 8 + Segment size: 0 + Offset entries: 9 + CU [ 14] base: 0x0000000000401160 + + Offsets starting at 0xc: + [ 0] 0x24 + [ 1] 0x32 + [ 2] 0x39 + [ 3] 0x3f + [ 4] 0x4a + [ 5] 0x55 + [ 6] 0x5b + [ 7] 0x61 + [ 8] 0x6f + + Offset: 30, Index: 24 + startx_length f, a + 0x0000000000401160 .. + 0x0000000000401169 .. + [ 0] reg5 + startx_length 0, 2a + 0x000000000040116a .. + 0x0000000000401193 .. + [ 0] entry_value: + [ 0] reg5 + [ 3] stack_value + end_of_list + + Offset: 3e, Index: 32 + startx_length 11, 12 + 0x000000000040117b .. + 0x000000000040118c .. + [ 0] addrx [18] 0x404038 + end_of_list + + Offset: 45, Index: 39 + startx_length 11, 6 + 0x000000000040117b .. + 0x0000000000401180 .. + [ 0] reg5 + end_of_list + + Offset: 4b, Index: 3f + startx_length 11, c + 0x000000000040117b .. + 0x0000000000401186 .. + [ 0] reg5 + startx_length 1, 4 + 0x0000000000401189 .. + 0x000000000040118c .. + [ 0] reg5 + end_of_list + + Offset: 56, Index: 4a + startx_length 4, 6 + 0x0000000000401181 .. + 0x0000000000401186 .. + [ 0] reg5 + startx_length 1, 4 + 0x0000000000401189 .. + 0x000000000040118c .. + [ 0] reg5 + end_of_list + + Offset: 61, Index: 55 + startx_length 4, c + 0x0000000000401181 .. + 0x000000000040118c .. + [ 0] reg5 + end_of_list + + Offset: 67, Index: 5b + startx_length 2, 6 + 0x000000000040118d .. + 0x0000000000401192 .. + [ 0] reg5 + end_of_list + + Offset: 6d, Index: 61 + startx_length 9, f + 0x00000000004011a0 .. + 0x00000000004011ae .. + [ 0] reg5 + startx_length 5, 2 + 0x00000000004011af .. + 0x00000000004011b0 .. + [ 0] entry_value: + [ 0] reg5 + [ 3] stack_value + end_of_list + + Offset: 7b, Index: 6f + startx_length 9, 10 + 0x00000000004011a0 .. + 0x00000000004011af .. + [ 0] reg5 + end_of_list + + +testfile-world5.dwo: + + +DWARF section [ 3] '.debug_loclists.dwo' at offset 0x217: +Table at Offset 0x0: + + Length: 128 + DWARF version: 5 + Address size: 8 + Segment size: 0 + Offset entries: 7 + CU [ 14] base: 000000000000000000 + + Offsets starting at 0xc: + [ 0] 0x1c + [ 1] 0x2a + [ 2] 0x38 + [ 3] 0x3e + [ 4] 0x4c + [ 5] 0x52 + [ 6] 0x6d + + Offset: 28, Index: 1c + startx_length 2, 14 + 0x0000000000401060
.. + 0x0000000000401073 .. + [ 0] reg5 + startx_length 4, c + 0x0000000000401074 .. + 0x000000000040107f .. + [ 0] entry_value: + [ 0] reg5 + [ 3] stack_value + end_of_list + + Offset: 36, Index: 2a + startx_length 2, 18 + 0x0000000000401060
.. + 0x0000000000401077 .. + [ 0] reg4 + startx_length 7, 6 + 0x0000000000401078 .. + 0x000000000040107d .. + [ 0] entry_value: + [ 0] reg4 + [ 3] stack_value + end_of_list + + Offset: 44, Index: 38 + startx_length 3, 7 + 0x0000000000401071 .. + 0x0000000000401077 .. + [ 0] reg0 + end_of_list + + Offset: 4a, Index: 3e + startx_length d, 8 + 0x00000000004011c0 .. + 0x00000000004011c7 .. + [ 0] reg5 + startx_length e, 23 + 0x00000000004011c8 .. + 0x00000000004011ea .. + [ 0] entry_value: + [ 0] reg5 + [ 3] stack_value + end_of_list + + Offset: 58, Index: 4c + startx_length f, b + 0x00000000004011d8 .. + 0x00000000004011e2 .. + [ 0] reg0 + end_of_list + + Offset: 5e, Index: 52 + startx_length f, 2 + 0x00000000004011d8 .. + 0x00000000004011d9 .. + [ 0] reg1 + startx_length 10, 5 + 0x00000000004011da .. + 0x00000000004011de .. + [ 0] reg5 + startx_length 0, 4 + 0x00000000004011df .. + 0x00000000004011e2 .. + [ 0] entry_value: + [ 0] reg5 + [ 3] deref_size 1 + [ 5] const1u 56 + [ 7] shl + [ 8] const1u 56 + [10] shra + [11] stack_value + end_of_list + + Offset: 79, Index: 6d + startx_length f, 2 + 0x00000000004011d8 .. + 0x00000000004011d9 .. + [ 0] reg1 + startx_length 10, 9 + 0x00000000004011da .. + 0x00000000004011e2 .. + [ 0] reg5 + end_of_list + +EOF + exit 0 -- cgit v1.2.3