1 # RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
2 # RUN: llvm-dwarfdump -v -debug-info %t.o 2> %t.err | FileCheck %s
3 # RUN: FileCheck %s --input-file %t.err --check-prefix=ERR
4 # RUN: llvm-dwarfdump -lookup 10 %t.o 2> %t2.err
5 # RUN: FileCheck %s --input-file %t2.err --check-prefix=ERR
7 # Test object to verify dwarfdump handles v5 range lists in 64-bit DWARF format.
8 # This is similar to 'dwarfdump-rnglists.s', which uses 32-bit DWARF format.
9 # We use very simplified compile unit dies.
10 # There are 2 full CUs with DW_AT_rnglists_base, one with a DW_AT_ranges
11 # attribute using DW_FORM_sec_offset, the other with DW_AT_ranges using
14 .section .debug_abbrev,"",@progbits
15 .byte 0x01 # Abbrev code
16 .byte 0x11 # DW_TAG_compile_unit
17 .byte 0x00 # DW_CHILDREN_no
18 .byte 0x74 # DW_AT_rnglists_base
19 .byte 0x17 # DW_FORM_sec_offset
20 .byte 0x55 # DW_AT_ranges
21 .byte 0x17 # DW_FORM_sec_offset
24 .byte 0x02 # Abbrev code
25 .byte 0x11 # DW_TAG_compile_unit
26 .byte 0x00 # DW_CHILDREN_no
27 .byte 0x74 # DW_AT_rnglists_base
28 .byte 0x17 # DW_FORM_sec_offset
29 .byte 0x55 # DW_AT_ranges
30 .byte 0x23 # DW_FORM_rnglistx
35 # The split CU uses DW_FORM_rnglistx (the only correct option).
36 # There is no DW_AT_rnglists_base in split units.
37 .section .debug_abbrev.dwo,"",@progbits
38 .byte 0x01 # Abbrev code
39 .byte 0x11 # DW_TAG_compile_unit
40 .byte 0x00 # DW_CHILDREN_no
41 .byte 0x55 # DW_AT_ranges
42 .byte 0x23 # DW_FORM_rnglistx
47 .section .debug_info,"",@progbits
48 .long 0xffffffff # DWARF64 mark
49 .quad CU1_5_64_end - CU1_5_64_version # Length of Unit
51 .short 5 # DWARF version number
52 .byte 1 # DWARF Unit Type
53 .byte 4 # Address Size (in bytes)
54 .quad .debug_abbrev # Offset Into Abbrev. Section
55 # The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
56 .byte 1 # Abbreviation code
57 .quad Rnglist_Table0_base # DW_AT_rnglists_base
58 .quad Rnglist_Table0_Rnglist0 # DW_AT_ranges
61 .long 0xffffffff # DWARF64 mark
62 .quad CU2_5_64_end - CU2_5_64_version # Length of Unit
64 .short 5 # DWARF version number
65 .byte 1 # DWARF Unit Type
66 .byte 4 # Address Size (in bytes)
67 .quad .debug_abbrev # Offset Into Abbrev. Section
68 # The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
69 .byte 2 # Abbreviation code
70 .quad Rnglist_Table0_base # DW_AT_rnglists_base
71 .uleb128 1 # DW_AT_ranges
74 # A CU with an invalid DW_AT_rnglists_base attribute
75 .long 0xffffffff # DWARF64 mark
76 .quad CU3_5_64_end - CU3_5_64_version # Length of Unit
78 .short 5 # DWARF version number
79 .byte 1 # DWARF Unit Type
80 .byte 4 # Address Size (in bytes)
81 .quad .debug_abbrev # Offset Into Abbrev. Section
82 # The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
83 .byte 2 # Abbreviation code
84 .quad 0x8 # DW_AT_rnglists_base
85 .uleb128 0 # DW_AT_ranges
88 # A CU DIE with an incorrect DW_AT_ranges attribute
89 .long 0xffffffff # DWARF64 mark
90 .quad CU4_5_64_end - CU4_5_64_version # Length of Unit
92 .short 5 # DWARF version number
93 .byte 1 # DWARF Unit Type
94 .byte 4 # Address Size (in bytes)
95 .quad .debug_abbrev # Offset Into Abbrev. Section
96 # The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
97 .byte 1 # Abbreviation code
98 .quad Rnglist_Table0_base # DW_AT_rnglists_base
99 .quad 4000 # DW_AT_ranges
102 .section .debug_info.dwo,"",@progbits
104 # DWARF v5 split CU header.
105 .long 0xffffffff # DWARF64 mark
106 .quad CU_split_5_64_end-CU_split_5_64_version # Length of Unit
107 CU_split_5_64_version
:
108 .short 5 # DWARF version number
109 .byte 5 # DWARF Unit Type
110 .byte 4 # Address Size (in bytes)
111 .quad 0 # Offset Into Abbrev Section
112 # The compile-unit DIE, which has DW_AT_rnglists_base and DW_AT_ranges.
113 .byte 1 # Abbreviation code
114 .uleb128 1 # DW_AT_ranges
117 .section .debug_rnglists,"",@progbits
118 # A rnglist table with 2 range lists. The first one uses DW_RLE_start_end
119 # and DW_RLE_start_length. The second one uses DW_RLE_base_address and
120 # DW_RLE_offset_pair. The range lists have entries in the offset table.
121 .long 0xffffffff # DWARF64 mark
122 .quad Rnglist_Table0_end - Rnglist_Table0 # table length
125 .byte 4 # address size
126 .byte 0 # segment selector size
127 .long 2 # offset entry count
129 # 2 offset entries which can be used by DW_FORM_rnglistx.
130 .quad Rnglist_Table0_Rnglist0 - Rnglist_Table0_base
131 .quad Rnglist_Table0_Rnglist1 - Rnglist_Table0_base
132 Rnglist_Table0_Rnglist0
:
133 .byte 6 # DW_RLE_start_end
136 .byte 7 # DW_RLE_start_length
138 .uleb128 Range1_end - Range1_start
139 .byte 0 # DW_RLE_end_of_list
140 Rnglist_Table0_Rnglist1
:
141 .byte 5 # DW_RLE_base_address
143 .byte 4 # DW_RLE_offset_pair
144 .uleb128 Range1_start - Range0_start
145 .uleb128 Range1_end - Range0_start
146 .byte 0 # DW_RLE_end_of_list
149 # A rnglist table for the split unit with an empty rangelist and one that
150 # uses DW_RLE_base_address and DW_RLE_offset_pair. The ranges have entries
151 # in the offset table. We use the empty range list so we can test
152 # DW_FORM_rnglistx with an index other than 0.
153 .section .debug_rnglists.dwo,"",@progbits
154 .long 0xffffffff # DWARF64 mark
155 .quad Rnglist_Table0_dwo_end - Rnglist_Table0_dwo # table length
158 .byte 4 # address size
159 .byte 0 # segment selector size
160 .long 2 # offset entry count
161 Rnglist_Table0_base_dwo
:
162 # 2 offset entries which can be used by DW_FORM_rnglistx.
163 .quad Rnglist_Table0_Rnglist0_dwo - Rnglist_Table0_base_dwo
164 .quad Rnglist_Table0_Rnglist1_dwo - Rnglist_Table0_base_dwo
165 Rnglist_Table0_Rnglist0_dwo
:
166 .byte 0 # DW_RLE_start_end
167 Rnglist_Table0_Rnglist1_dwo
:
168 .byte 5 # DW_RLE_base_address
169 .long Range0_start - .text
170 .byte 4 # DW_RLE_offset_pair
171 .uleb128 Range1_start - Range0_start
172 .uleb128 Range1_end - Range0_start
173 .byte 0 # DW_RLE_end_of_list
174 Rnglist_Table0_dwo_end
:
178 Range0_start
: # Range0: 0x14 - 0x1c
182 Range1_start
: # Range1: 0x2a - 0x34
186 # CHECK: .debug_info contents:
187 # CHECK: Compile Unit:
188 # CHECK-NOT: Compile Unit:
189 # CHECK: DW_TAG_compile_unit
190 # CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000014)
191 # CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000024
192 # CHECK-NEXT: [0x00000014, 0x0000001e) ".text"
193 # CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
195 # CHECK: Compile Unit:
196 # CHECK-NOT: Compile Unit:
197 # CHECK: DW_TAG_compile_unit
198 # CHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000014)
199 # CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000020
200 # CHECK-NEXT: [0x0000002a, 0x00000034) ".text")
202 # CHECK: .debug_info.dwo contents:
203 # CHECK: Compile Unit:
204 # CHECK-NOT: contents:
205 # CHECK: DW_TAG_compile_unit
206 # CHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000011
207 # CHECK-NEXT: [0x0000002a, 0x00000034))
209 #ERR: error: parsing a range list table: Did not detect a valid range list table with base = 0x8
210 #ERR: error: decoding address ranges: missing or invalid range list table
211 #ERR: error: decoding address ranges: invalid range list offset 0xfa0