1 # RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
2 # RUN: llvm-dwarfdump -v %t.o | FileCheck %s
4 # Test object to verify that dwarfdump handles dwp files with DWARF v5 string
5 # offset tables. We have 3 CUs and 2 TUs, where it is assumed that
6 # CU1 and TU1 came from one object file, CU2 and TU2 from a second object
7 # file, and CU3 from a third object file that was compiled with
10 .section .debug_str.dwo,"MS",@progbits,1
12 .asciz "Handmade DWARF producer"
14 .asciz "Compile_Unit_1"
16 .asciz "/home/test/CU1"
18 .asciz "Compile_Unit_2"
20 .asciz "/home/test/CU2"
30 .asciz "Compile_Unit_3"
32 .asciz "/home/test/CU3"
34 .section .debug_str_offsets.dwo,"",@progbits
35 # Object files 1's portion of the .debug_str_offsets.dwo section.
36 # CU1 and TU1 share a contribution to the string offsets table.
37 .debug_str_offsets_object_file1_start:
38 .long .debug_str_offsets_object_file1_end-.debug_str_offsets_base_1
39 .short 5 # DWARF version
41 .debug_str_offsets_base_1:
42 .long str_producer-.debug_str.dwo
43 .long str_CU1-.debug_str.dwo
44 .long str_CU1_dir-.debug_str.dwo
45 .long str_TU1-.debug_str.dwo
46 .long str_TU1_type-.debug_str.dwo
47 .debug_str_offsets_object_file1_end:
49 # Object files 2's portion of the .debug_str_offsets.dwo section.
50 # CU2 and TU2 share a contribution to the string offsets table.
51 .debug_str_offsets_object_file2_start:
52 .long .debug_str_offsets_object_file2_end-.debug_str_offsets_base_2
53 .short 5 # DWARF version
55 .debug_str_offsets_base_2:
56 .long str_producer-.debug_str.dwo
57 .long str_CU2-.debug_str.dwo
58 .long str_CU2_dir-.debug_str.dwo
59 .long str_TU2-.debug_str.dwo
60 .long str_TU2_type-.debug_str.dwo
61 .debug_str_offsets_object_file2_end:
63 # Object files 3's portion of the .debug_str_offsets.dwo section.
64 # This file is assumed to have been compiled with -gdwarf-4 and
65 # therefore contains a version 4 CU and a GNU format contribution
66 # to the .debug_str_offsets section.
67 .debug_str_offsets_object_file3_start:
68 .debug_str_offsets_base_3:
69 .long str_producer-.debug_str.dwo
70 .long str_CU3-.debug_str.dwo
71 .long str_CU3_dir-.debug_str.dwo
72 .debug_str_offsets_object_file3_end:
74 # Abbrevs are shared for all compile and type units
75 .section .debug_abbrev.dwo,"",@progbits
76 .byte 0x01 # Abbrev code
77 .byte 0x11 # DW_TAG_compile_unit
78 .byte 0x00 # DW_CHILDREN_no
79 .byte 0x25 # DW_AT_producer
80 .byte 0x1a # DW_FORM_strx
81 .byte 0x03 # DW_AT_name
82 .byte 0x1a # DW_FORM_strx
83 .byte 0x03 # DW_AT_name
84 .byte 0x1a # DW_FORM_strx
87 .byte 0x02 # Abbrev code
88 .byte 0x41 # DW_TAG_type_unit
89 .byte 0x01 # DW_CHILDREN_yes
90 .byte 0x03 # DW_AT_name
91 .byte 0x1a # DW_FORM_strx
94 .byte 0x03 # Abbrev code
95 .byte 0x13 # DW_TAG_structure_type
96 .byte 0x00 # DW_CHILDREN_no (no members)
97 .byte 0x03 # DW_AT_name
98 .byte 0x1a # DW_FORM_strx
101 .byte 0x04 # Abbrev code
102 .byte 0x11 # DW_TAG_compile_unit
103 .byte 0x00 # DW_CHILDREN_no
104 .byte 0x25 # DW_AT_producer
105 .short 0x3e82 # DW_FORM_GNU_str_index
106 .byte 0x03 # DW_AT_name
107 .short 0x3e82 # DW_FORM_GNU_str_index
108 .byte 0x03 # DW_AT_name
109 .short 0x3e82 # DW_FORM_GNU_str_index
115 .section .debug_info.dwo,"",@progbits
117 # DWARF v5 CU header.
119 .long CU1_5_end-CU1_5_version # Length of Unit
121 .short 5 # DWARF version number
122 .byte 1 # DWARF Unit Type
123 .byte 8 # Address Size (in bytes)
124 .long .debug_abbrev.dwo # Offset Into Abbrev. Section
125 # The compile-unit DIE, which has a DW_AT_producer, DW_AT_name
127 .byte 1 # Abbreviation code
128 .byte 0 # The index of the producer string
129 .byte 1 # The index of the CU name string
130 .byte 2 # The index of the comp dir string
135 .long CU2_5_end-CU2_5_version # Length of Unit
137 .short 5 # DWARF version number
138 .byte 1 # DWARF Unit Type
139 .byte 8 # Address Size (in bytes)
140 .long .debug_abbrev.dwo # Offset Into Abbrev. Section
141 # The compile-unit DIE, which has a DW_AT_producer, DW_AT_name
143 .byte 1 # Abbreviation code
144 .byte 0 # The index of the producer string
145 .byte 1 # The index of the CU name string
146 .byte 2 # The index of the comp dir string
151 .long CU3_4_end-CU3_4_version # Length of Unit
153 .short 4 # DWARF version number
154 .long .debug_abbrev.dwo # Offset Into Abbrev. Section
155 .byte 8 # Address Size (in bytes)
156 # The compile-unit DIE, which has a DW_AT_producer, DW_AT_name
158 .byte 4 # Abbreviation code
159 .byte 0 # The index of the producer string
160 .byte 1 # The index of the CU name string
161 .byte 2 # The index of the comp dir string
165 .section .debug_types.dwo,"",@progbits
166 # DWARF v5 Type unit header.
168 .long TU1_5_end-TU1_5_version # Length of Unit
170 .short 5 # DWARF version number
171 .byte 2 # DWARF Unit Type
172 .byte 8 # Address Size (in bytes)
173 .long .debug_abbrev.dwo # Offset Into Abbrev. Section
174 .quad 0x0011223344556677 # Type Signature
175 .long TU1_5_type-TU1_5_start # Type offset
176 # The type-unit DIE, which has a name.
177 .byte 2 # Abbreviation code
178 .byte 3 # Index of the unit type name string
179 # The type DIE, which has a name.
181 .byte 3 # Abbreviation code
182 .byte 4 # Index of the type name string
188 .long TU2_5_end-TU2_5_version # Length of Unit
190 .short 5 # DWARF version number
191 .byte 2 # DWARF Unit Type
192 .byte 8 # Address Size (in bytes)
193 .long .debug_abbrev.dwo # Offset Into Abbrev. Section
194 .quad 0x00aabbccddeeff99 # Type Signature
195 .long TU2_5_type-TU2_5_start # Type offset
196 # The type-unit DIE, which has a name.
197 .byte 2 # Abbreviation code
198 .byte 3 # Index of the unit type name string
199 # The type DIE, which has a name.
201 .byte 3 # Abbreviation code
202 .byte 4 # Index of the type name string
207 .section .debug_cu_index,"",@progbits
210 .long 3 # Columns of contribution matrix
211 .long 3 # number of units
212 .long 3 # number of hash buckets in table
214 # The signatures for all CUs.
215 .quad 0xddeeaaddbbaabbee # signature 1
216 .quad 0xff00ffeeffaaff00 # signature 2
217 .quad 0xf00df00df00df00d # signature 2
218 # The indexes for both CUs.
222 # The sections to which all CUs contribute.
223 .long 1 # DW_SECT_INFO
224 .long 3 # DW_SECT_ABBREV
225 .long 6 # DW_SECT_STR_OFFSETS
227 # The starting offsets of all CU's contributions to info,
228 # abbrev and string offsets table.
229 .long CU1_5_start-.debug_info.dwo
231 .long .debug_str_offsets_object_file1_start-.debug_str_offsets.dwo
232 .long CU2_5_start-.debug_info.dwo
234 .long .debug_str_offsets_object_file2_start-.debug_str_offsets.dwo
235 .long CU3_4_start-.debug_info.dwo
237 .long .debug_str_offsets_object_file3_start-.debug_str_offsets.dwo
239 # The lengths of all CU's contributions to info, abbrev and
240 # string offsets table.
241 .long CU1_5_end-CU1_5_start
242 .long abbrev_end-.debug_abbrev.dwo
243 .long .debug_str_offsets_object_file1_end-.debug_str_offsets_object_file1_start
244 .long CU2_5_end-CU2_5_start
245 .long abbrev_end-.debug_abbrev.dwo
246 .long .debug_str_offsets_object_file2_end-.debug_str_offsets_object_file2_start
247 .long CU3_4_end-CU3_4_start
248 .long abbrev_end-.debug_abbrev.dwo
249 .long .debug_str_offsets_object_file3_end-.debug_str_offsets_object_file3_start
251 .section .debug_tu_index,"",@progbits
254 .long 3 # Columns of contribution matrix
255 .long 2 # number of units
256 .long 2 # number of hash buckets in table
258 # The signatures for both TUs.
259 .quad 0xeeaaddbbaabbeedd # signature 1
260 .quad 0x00ffeeffaaff00ff # signature 2
261 # The indexes for both TUs.
264 # The sections to which both TUs contribute.
265 .long 2 # DW_SECT_TYPES
266 .long 3 # DW_SECT_ABBREV
267 .long 6 # DW_SECT_STR_OFFSETS
269 # The starting offsets of both TU's contributions to info,
270 # abbrev and string offsets table.
271 .long TU1_5_start-.debug_types.dwo
273 .long .debug_str_offsets_object_file1_start-.debug_str_offsets.dwo
274 .long TU2_5_start-.debug_types.dwo
276 .long .debug_str_offsets_object_file2_start-.debug_str_offsets.dwo
278 # The lengths of both TU's contributions to info, abbrev and
279 # string offsets table.
280 .long TU1_5_end-TU1_5_start
281 .long abbrev_end-.debug_abbrev.dwo
282 .long .debug_str_offsets_object_file1_end-.debug_str_offsets_object_file1_start
283 .long TU2_5_end-TU2_5_start
284 .long abbrev_end-.debug_abbrev.dwo
285 .long .debug_str_offsets_object_file2_end-.debug_str_offsets_object_file2_start
288 # Verify that the correct strings from each unit are displayed and that the
289 # index for the .debug_str_offsets section has the right values.
291 # CHECK: Compile Unit
293 # CHECK: DW_TAG_compile_unit
294 # CHECK-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer")
295 # CHECK-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_1")
296 # CHECK-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU1")
299 # CHECK: Compile Unit
301 # CHECK: DW_TAG_compile_unit
302 # CHECK-NEXT: DW_AT_producer [DW_FORM_strx] (indexed (00000000) string = "Handmade DWARF producer")
303 # CHECK-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000001) string = "Compile_Unit_2")
304 # CHECK-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000002) string = "/home/test/CU2")
308 # CHECK: DW_TAG_type_unit
309 # CHECK-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000003) string = "Type_Unit_1")
311 # CHECK: DW_TAG_structure_type
312 # CHECK-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000004) string = "MyStruct_1")
316 # CHECK: DW_TAG_type_unit
317 # CHECK-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000003) string = "Type_Unit_2")
319 # CHECK: DW_TAG_structure_type
320 # CHECK-NEXT: DW_AT_name [DW_FORM_strx] (indexed (00000004) string = "MyStruct_2")
322 # Verify the correct offets of the compile and type units contributions in the
325 # CHECK: .debug_cu_index contents:
326 # CHECK-NOT: contents:
327 # CHECK: 1 0xddeeaaddbbaabbee [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) [{{0x[0-9a-f]*, 0x[0-9a-f]*}})
328 # CHECK-SAME: [0x00000000
329 # CHECK-NEXT: 2 0xff00ffeeffaaff00 [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) [{{0x[0-9a-f]*, 0x[0-9a-f]*}})
330 # CHECK-SAME: [0x0000001c
332 # CHECK: .debug_tu_index contents:
333 # CHECK-NOT: contents:
334 # CHECK: 1 0xeeaaddbbaabbeedd [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) [{{0x[0-9a-f]*, 0x[0-9a-f]*}})
335 # CHECK-SAME: [0x00000000
336 # CHECK-NEXT: 2 0x00ffeeffaaff00ff [{{0x[0-9a-f]*, 0x[0-9a-f]*}}) [{{0x[0-9a-f]*, 0x[0-9a-f]*}})