summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2017-11-24 19:29:57 +0100
committerMark Wielaard <[email protected]>2018-05-29 12:18:43 +0200
commit7cfe2c16f9ddaa7478a2d97dd893c6b89080020a (patch)
treed3ceaf787ee03c7cb5f22728b1ddd92bca56fdb2 /tests
parent263dbe8ca17f66baa184f489530eb92afa15adfe (diff)
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 <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog4
-rwxr-xr-xtests/run-readelf-loc.sh560
2 files changed, 564 insertions, 0 deletions
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 <[email protected]>
+
+ * run-readelf-loc.sh: Add new testcases.
+
2018-04-06 Mark Wielaard <[email protected]>
* 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 <foo>
+
+ Offset: c, Index: 0
+ offset_pair 0, a
+ 0x0000000000400510 <foo>..
+ 0x0000000000400519 <foo+0x9>
+ [ 0] reg5
+ offset_pair a, 34
+ 0x000000000040051a <foo+0xa>..
+ 0x0000000000400543 <foo+0x33>
+ [ 0] entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ end_of_list
+
+ Offset: 1a, Index: e
+ offset_pair 1b, 2d
+ 0x000000000040052b <foo+0x1b>..
+ 0x000000000040053c <foo+0x2c>
+ [ 0] addr 0x601038 <m>
+ end_of_list
+
+ Offset: 28, Index: 1c
+ offset_pair 1b, 21
+ 0x000000000040052b <foo+0x1b>..
+ 0x0000000000400530 <foo+0x20>
+ [ 0] reg5
+ end_of_list
+
+ Offset: 2e, Index: 22
+ offset_pair 1b, 27
+ 0x000000000040052b <foo+0x1b>..
+ 0x0000000000400536 <foo+0x26>
+ [ 0] reg5
+ offset_pair 29, 2d
+ 0x0000000000400539 <foo+0x29>..
+ 0x000000000040053c <foo+0x2c>
+ [ 0] reg5
+ end_of_list
+
+ Offset: 39, Index: 2d
+ offset_pair 21, 27
+ 0x0000000000400531 <foo+0x21>..
+ 0x0000000000400536 <foo+0x26>
+ [ 0] reg5
+ offset_pair 29, 2d
+ 0x0000000000400539 <foo+0x29>..
+ 0x000000000040053c <foo+0x2c>
+ [ 0] reg5
+ end_of_list
+
+ Offset: 44, Index: 38
+ offset_pair 21, 2d
+ 0x0000000000400531 <foo+0x21>..
+ 0x000000000040053c <foo+0x2c>
+ [ 0] reg5
+ end_of_list
+
+ Offset: 4a, Index: 3e
+ offset_pair 2d, 33
+ 0x000000000040053d <foo+0x2d>..
+ 0x0000000000400542 <foo+0x32>
+ [ 0] reg5
+ end_of_list
+
+ Offset: 50, Index: 44
+ offset_pair 40, 4f
+ 0x0000000000400550 <baz>..
+ 0x000000000040055e <baz+0xe>
+ [ 0] reg5
+ offset_pair 4f, 51
+ 0x000000000040055f <baz+0xf>..
+ 0x0000000000400560 <baz+0x10>
+ [ 0] entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ end_of_list
+
+ Offset: 5e, Index: 52
+ offset_pair 40, 50
+ 0x0000000000400550 <baz>..
+ 0x000000000040055f <baz+0xf>
+ [ 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 <main>
+ offset_pair 0, 14
+ 0x0000000000400410 <main>..
+ 0x0000000000400423 <main+0x13>
+ [ 0] reg5
+ offset_pair 14, 20
+ 0x0000000000400424 <main+0x14>..
+ 0x000000000040042f <main+0x1f>
+ [ 0] entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ end_of_list
+
+ Offset: 87, Index: 17
+ base_address 0x400410
+ 0x0000000000400410 <main>
+ offset_pair 0, 18
+ 0x0000000000400410 <main>..
+ 0x0000000000400427 <main+0x17>
+ [ 0] reg4
+ offset_pair 18, 20
+ 0x0000000000400428 <main+0x18>..
+ 0x000000000040042f <main+0x1f>
+ [ 0] entry_value:
+ [ 0] reg4
+ [ 3] stack_value
+ end_of_list
+
+ Offset: 9e, Index: 2e
+ start_length 0x400421, 7
+ 0x0000000000400421 <main+0x11>..
+ 0x0000000000400427 <main+0x17>
+ [ 0] reg0
+ end_of_list
+
+ Offset: ab, Index: 3b
+ base_address 0x400570
+ 0x0000000000400570 <calc>
+ offset_pair 0, 8
+ 0x0000000000400570 <calc>..
+ 0x0000000000400577 <calc+0x7>
+ [ 0] reg5
+ offset_pair 8, 2b
+ 0x0000000000400578 <calc+0x8>..
+ 0x000000000040059a <calc+0x2a>
+ [ 0] entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ end_of_list
+
+ Offset: c2, Index: 52
+ start_length 0x400588, b
+ 0x0000000000400588 <calc+0x18>..
+ 0x0000000000400592 <calc+0x22>
+ [ 0] reg0
+ end_of_list
+
+ Offset: cf, Index: 5f
+ base_address 0x400588
+ 0x0000000000400588 <calc+0x18>
+ offset_pair 0, 2
+ 0x0000000000400588 <calc+0x18>..
+ 0x0000000000400589 <calc+0x19>
+ [ 0] reg1
+ offset_pair 2, 7
+ 0x000000000040058a <calc+0x1a>..
+ 0x000000000040058e <calc+0x1e>
+ [ 0] reg5
+ offset_pair 7, b
+ 0x000000000040058f <calc+0x1f>..
+ 0x0000000000400592 <calc+0x22>
+ [ 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 <calc+0x18>
+ offset_pair 0, 2
+ 0x0000000000400588 <calc+0x18>..
+ 0x0000000000400589 <calc+0x19>
+ [ 0] reg1
+ offset_pair 2, b
+ 0x000000000040058a <calc+0x1a>..
+ 0x0000000000400592 <calc+0x22>
+ [ 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 <foo>
+ [ 0] range 0, a
+ 0x0000000000400510 <foo>..
+ 0x0000000000400519 <foo+0x9>
+ [ 0] reg5
+ range a, 34
+ 0x000000000040051a <foo+0xa>..
+ 0x0000000000400543 <foo+0x33>
+ [ 0] GNU_entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ [ 39] range 1b, 2d
+ 0x000000000040052b <foo+0x1b>..
+ 0x000000000040053c <foo+0x2c>
+ [ 0] addr 0x601038 <m>
+ [ 64] range 1b, 21
+ 0x000000000040052b <foo+0x1b>..
+ 0x0000000000400530 <foo+0x20>
+ [ 0] reg5
+ [ 87] range 1b, 27
+ 0x000000000040052b <foo+0x1b>..
+ 0x0000000000400536 <foo+0x26>
+ [ 0] reg5
+ range 29, 2d
+ 0x0000000000400539 <foo+0x29>..
+ 0x000000000040053c <foo+0x2c>
+ [ 0] reg5
+ [ bd] range 21, 27
+ 0x0000000000400531 <foo+0x21>..
+ 0x0000000000400536 <foo+0x26>
+ [ 0] reg5
+ range 29, 2d
+ 0x0000000000400539 <foo+0x29>..
+ 0x000000000040053c <foo+0x2c>
+ [ 0] reg5
+ [ f3] range 21, 2d
+ 0x0000000000400531 <foo+0x21>..
+ 0x000000000040053c <foo+0x2c>
+ [ 0] reg5
+ [ 116] range 2d, 33
+ 0x000000000040053d <foo+0x2d>..
+ 0x0000000000400542 <foo+0x32>
+ [ 0] reg5
+ [ 139] range 40, 4f
+ 0x0000000000400550 <baz>..
+ 0x000000000040055e <baz+0xe>
+ [ 0] reg5
+ range 4f, 51
+ 0x000000000040055f <baz+0xf>..
+ 0x0000000000400560 <baz+0x10>
+ [ 0] GNU_entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ [ 172] range 40, 50
+ 0x0000000000400550 <baz>..
+ 0x000000000040055f <baz+0xf>
+ [ 0] reg5
+
+ CU [ 21c] base: 000000000000000000
+ [ 195] range 400410, 400424
+ 0x0000000000400410 <main>..
+ 0x0000000000400423 <main+0x13>
+ [ 0] reg5
+ range 400424, 400430
+ 0x0000000000400424 <main+0x14>..
+ 0x000000000040042f <main+0x1f>
+ [ 0] GNU_entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ [ 1ce] range 400410, 400428
+ 0x0000000000400410 <main>..
+ 0x0000000000400427 <main+0x17>
+ [ 0] reg4
+ range 400428, 400430
+ 0x0000000000400428 <main+0x18>..
+ 0x000000000040042f <main+0x1f>
+ [ 0] GNU_entry_value:
+ [ 0] reg4
+ [ 3] stack_value
+ [ 207] range 400421, 400428
+ 0x0000000000400421 <main+0x11>..
+ 0x0000000000400427 <main+0x17>
+ [ 0] reg0
+ [ 22a] range 400570, 400578
+ 0x0000000000400570 <calc>..
+ 0x0000000000400577 <calc+0x7>
+ [ 0] reg5
+ range 400578, 40059b
+ 0x0000000000400578 <calc+0x8>..
+ 0x000000000040059a <calc+0x2a>
+ [ 0] GNU_entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ [ 263] range 400588, 400593
+ 0x0000000000400588 <calc+0x18>..
+ 0x0000000000400592 <calc+0x22>
+ [ 0] reg0
+ [ 286] range 400588, 40058a
+ 0x0000000000400588 <calc+0x18>..
+ 0x0000000000400589 <calc+0x19>
+ [ 0] reg1
+ range 40058a, 40058f
+ 0x000000000040058a <calc+0x1a>..
+ 0x000000000040058e <calc+0x1e>
+ [ 0] reg5
+ range 40058f, 400593
+ 0x000000000040058f <calc+0x1f>..
+ 0x0000000000400592 <calc+0x22>
+ [ 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 <calc+0x18>..
+ 0x0000000000400589 <calc+0x19>
+ [ 0] reg1
+ range 40058a, 400593
+ 0x000000000040058a <calc+0x1a>..
+ 0x0000000000400592 <calc+0x22>
+ [ 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 <foo>
+
+ 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 <foo>..
+ 0x0000000000401169 <foo+0x9>..
+ [ 0] reg5
+ startx_length 0, 2a
+ 0x000000000040116a <foo+0xa>..
+ 0x0000000000401193 <foo+0x33>..
+ [ 0] entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ end_of_list
+
+ Offset: 3e, Index: 32
+ startx_length 11, 12
+ 0x000000000040117b <foo+0x1b>..
+ 0x000000000040118c <foo+0x2c>..
+ [ 0] addrx [18] 0x404038 <m>
+ end_of_list
+
+ Offset: 45, Index: 39
+ startx_length 11, 6
+ 0x000000000040117b <foo+0x1b>..
+ 0x0000000000401180 <foo+0x20>..
+ [ 0] reg5
+ end_of_list
+
+ Offset: 4b, Index: 3f
+ startx_length 11, c
+ 0x000000000040117b <foo+0x1b>..
+ 0x0000000000401186 <foo+0x26>..
+ [ 0] reg5
+ startx_length 1, 4
+ 0x0000000000401189 <foo+0x29>..
+ 0x000000000040118c <foo+0x2c>..
+ [ 0] reg5
+ end_of_list
+
+ Offset: 56, Index: 4a
+ startx_length 4, 6
+ 0x0000000000401181 <foo+0x21>..
+ 0x0000000000401186 <foo+0x26>..
+ [ 0] reg5
+ startx_length 1, 4
+ 0x0000000000401189 <foo+0x29>..
+ 0x000000000040118c <foo+0x2c>..
+ [ 0] reg5
+ end_of_list
+
+ Offset: 61, Index: 55
+ startx_length 4, c
+ 0x0000000000401181 <foo+0x21>..
+ 0x000000000040118c <foo+0x2c>..
+ [ 0] reg5
+ end_of_list
+
+ Offset: 67, Index: 5b
+ startx_length 2, 6
+ 0x000000000040118d <foo+0x2d>..
+ 0x0000000000401192 <foo+0x32>..
+ [ 0] reg5
+ end_of_list
+
+ Offset: 6d, Index: 61
+ startx_length 9, f
+ 0x00000000004011a0 <baz>..
+ 0x00000000004011ae <baz+0xe>..
+ [ 0] reg5
+ startx_length 5, 2
+ 0x00000000004011af <baz+0xf>..
+ 0x00000000004011b0 <baz+0x10>..
+ [ 0] entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ end_of_list
+
+ Offset: 7b, Index: 6f
+ startx_length 9, 10
+ 0x00000000004011a0 <baz>..
+ 0x00000000004011af <baz+0xf>..
+ [ 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 <main>..
+ 0x0000000000401073 <main+0x13>..
+ [ 0] reg5
+ startx_length 4, c
+ 0x0000000000401074 <main+0x14>..
+ 0x000000000040107f <main+0x1f>..
+ [ 0] entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ end_of_list
+
+ Offset: 36, Index: 2a
+ startx_length 2, 18
+ 0x0000000000401060 <main>..
+ 0x0000000000401077 <main+0x17>..
+ [ 0] reg4
+ startx_length 7, 6
+ 0x0000000000401078 <main+0x18>..
+ 0x000000000040107d <main+0x1d>..
+ [ 0] entry_value:
+ [ 0] reg4
+ [ 3] stack_value
+ end_of_list
+
+ Offset: 44, Index: 38
+ startx_length 3, 7
+ 0x0000000000401071 <main+0x11>..
+ 0x0000000000401077 <main+0x17>..
+ [ 0] reg0
+ end_of_list
+
+ Offset: 4a, Index: 3e
+ startx_length d, 8
+ 0x00000000004011c0 <calc>..
+ 0x00000000004011c7 <calc+0x7>..
+ [ 0] reg5
+ startx_length e, 23
+ 0x00000000004011c8 <calc+0x8>..
+ 0x00000000004011ea <calc+0x2a>..
+ [ 0] entry_value:
+ [ 0] reg5
+ [ 3] stack_value
+ end_of_list
+
+ Offset: 58, Index: 4c
+ startx_length f, b
+ 0x00000000004011d8 <calc+0x18>..
+ 0x00000000004011e2 <calc+0x22>..
+ [ 0] reg0
+ end_of_list
+
+ Offset: 5e, Index: 52
+ startx_length f, 2
+ 0x00000000004011d8 <calc+0x18>..
+ 0x00000000004011d9 <calc+0x19>..
+ [ 0] reg1
+ startx_length 10, 5
+ 0x00000000004011da <calc+0x1a>..
+ 0x00000000004011de <calc+0x1e>..
+ [ 0] reg5
+ startx_length 0, 4
+ 0x00000000004011df <calc+0x1f>..
+ 0x00000000004011e2 <calc+0x22>..
+ [ 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 <calc+0x18>..
+ 0x00000000004011d9 <calc+0x19>..
+ [ 0] reg1
+ startx_length 10, 9
+ 0x00000000004011da <calc+0x1a>..
+ 0x00000000004011e2 <calc+0x22>..
+ [ 0] reg5
+ end_of_list
+
+EOF
+
exit 0