xref: /llvm-project/llvm/test/DebugInfo/X86/dwarfdump-header.s (revision 585663225287ec9a26ead936a8424fc0e8a175da)
1# Test object to verify dwarfdump handles v4 and v5 CU/TU/line headers.
2# We have a representative set of units: v4 CU, v5 CU, v4 TU, v5 split TU.
3# We have v4 and v5 line-table headers.
4#
5# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
6# RUN: llvm-dwarfdump -v %t.o | FileCheck %s
7# RUN: llvm-dwarfdump -verify %t.o | FileCheck %s --check-prefix=VERIFY
8
9        .section .debug_str,"MS",@progbits,1
10str_producer:
11        .asciz "Handmade DWARF producer"
12str_CU_4:
13        .asciz "V4_compile_unit"
14str_CU_5:
15        .asciz "V5_compile_unit"
16str_TU_4:
17        .asciz "V4_type_unit"
18str_LT_5a:
19        .asciz "Directory5a"
20str_LT_5b:
21        .asciz "Directory5b"
22
23        .section .debug_str.dwo,"MSe",@progbits,1
24dwo_TU_5:
25        .asciz "V5_split_type_unit"
26dwo_producer:
27        .asciz "Handmade DWO producer"
28dwo_CU_5:
29        .asciz "V5_dwo_compile_unit"
30dwo_LT_5a:
31        .asciz "DWODirectory5a"
32dwo_LT_5b:
33        .asciz "DWODirectory5b"
34
35        .section	.debug_str_offsets.dwo,"e",@progbits
36        .long	Lstr_offsets_end-Lstr_offsets_start                              # Length of String Offsets Set
37        Lstr_offsets_start:
38	.short	5
39	.short	0
40	.long	dwo_TU_5-.debug_str.dwo
41	.long	dwo_producer-.debug_str.dwo
42	.long	dwo_CU_5-.debug_str.dwo
43	.long	dwo_LT_5a-.debug_str.dwo
44	.long	dwo_LT_5b-.debug_str.dwo
45        Lstr_offsets_end:
46
47# All CUs/TUs use the same abbrev section for simplicity.
48        .section .debug_abbrev,"",@progbits
49        .byte 0x01  # Abbrev code
50        .byte 0x11  # DW_TAG_compile_unit
51        .byte 0x00  # DW_CHILDREN_no
52        .byte 0x25  # DW_AT_producer
53        .byte 0x0e  # DW_FORM_strp
54        .byte 0x03  # DW_AT_name
55        .byte 0x0e  # DW_FORM_strp
56        .byte 0x10  # DW_AT_stmt_list
57        .byte 0x17  # DW_FORM_sec_offset
58        .byte 0x00  # EOM(1)
59        .byte 0x00  # EOM(2)
60        .byte 0x02  # Abbrev code
61        .byte 0x41  # DW_TAG_type_unit
62        .byte 0x01  # DW_CHILDREN_yes
63        .byte 0x03  # DW_AT_name
64        .byte 0x0e  # DW_FORM_strp
65        .byte 0x00  # EOM(1)
66        .byte 0x00  # EOM(2)
67        .byte 0x03  # Abbrev code
68        .byte 0x13  # DW_TAG_structure_type
69        .byte 0x00  # DW_CHILDREN_no (no members)
70        .byte 0x03  # DW_AT_name
71        .byte 0x0e  # DW_FORM_strp
72        .byte 0x00  # EOM(1)
73        .byte 0x00  # EOM(2)
74        .byte 0x04  # Abbrev code
75        .byte 0x3c  # DW_TAG_partial_unit
76        .byte 0x00  # DW_CHILDREN_no
77        .byte 0x03  # DW_AT_name
78        .byte 0x0e  # DW_FORM_strp
79        .byte 0x00  # EOM(1)
80        .byte 0x00  # EOM(2)
81        .byte 0x00  # EOM(3)
82
83# And a .dwo copy for the .dwo sections.
84        .section .debug_abbrev.dwo,"e",@progbits
85        .byte 0x01  # Abbrev code
86        .byte 0x11  # DW_TAG_compile_unit
87        .byte 0x00  # DW_CHILDREN_no
88        .byte 0x25  # DW_AT_producer
89        .byte 0x25  # DW_FORM_strx1
90        .byte 0x03  # DW_AT_name
91        .byte 0x25  # DW_FORM_strx1
92        .byte 0x10  # DW_AT_stmt_list
93        .byte 0x17  # DW_FORM_sec_offset
94        .byte 0x00  # EOM(1)
95        .byte 0x00  # EOM(2)
96        .byte 0x02  # Abbrev code
97        .byte 0x41  # DW_TAG_type_unit
98        .byte 0x01  # DW_CHILDREN_yes
99        .byte 0x03  # DW_AT_name
100        .byte 0x25  # DW_FORM_strx1
101        .byte 0x00  # EOM(1)
102        .byte 0x00  # EOM(2)
103        .byte 0x03  # Abbrev code
104        .byte 0x13  # DW_TAG_structure_type
105        .byte 0x00  # DW_CHILDREN_no (no members)
106        .byte 0x03  # DW_AT_name
107        .byte 0x25  # DW_FORM_strx1
108        .byte 0x00  # EOM(1)
109        .byte 0x00  # EOM(2)
110        .byte 0x00  # EOM(3)
111
112        .section .debug_info,"",@progbits
113# CHECK-LABEL: .debug_info contents:
114
115# DWARF v4 CU header. V4 CU headers all look the same so we do only one.
116        .long  CU_4_end-CU_4_version  # Length of Unit
117CU_4_version:
118        .short 4               # DWARF version number
119        .long .debug_abbrev    # Offset Into Abbrev. Section
120        .byte 8                # Address Size (in bytes)
121# The compile-unit DIE, with DW_AT_producer, DW_AT_name, DW_AT_stmt_list.
122        .byte 1
123        .long str_producer
124        .long str_CU_4
125        .long LH_4_start
126        .byte 0 # NULL
127CU_4_end:
128
129# CHECK: 0x00000000: Compile Unit: length = 0x00000015, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000019)
130# CHECK: 0x0000000b: DW_TAG_compile_unit
131
132# DWARF v5 normal CU header.
133        .long  CU_5_end-CU_5_version  # Length of Unit
134CU_5_version:
135        .short 5               # DWARF version number
136        .byte 1                # DWARF Unit Type
137        .byte 8                # Address Size (in bytes)
138        .long .debug_abbrev    # Offset Into Abbrev. Section
139# The compile-unit DIE, with DW_AT_producer, DW_AT_name, DW_AT_stmt_list.
140        .byte 1
141        .long str_producer
142        .long str_CU_5
143        .long LH_5_start
144        .byte 0 # NULL
145CU_5_end:
146
147# CHECK: 0x00000019: Compile Unit: length = 0x00000016, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000033)
148# CHECK: 0x00000025: DW_TAG_compile_unit
149
150# DWARF v5 CU header (Unit Type = DW_UT_partial).
151        .long  CU_5_partial_end-CU_5_partial_version  # Length of Unit
152CU_5_partial_version:
153        .short 5               # DWARF version number
154        .byte 3                # DWARF Unit Type
155        .byte 8                # Address Size (in bytes)
156        .long .debug_abbrev    # Offset Into Abbrev. Section
157# The partial-unit DIE, with DW_AT_name
158        .byte 4
159        .long str_CU_5
160        .byte 0 # NULL
161CU_5_partial_end:
162
163# CHECK: 0x00000033: Compile Unit: length = 0x0000000e, format = DWARF32, version = 0x0005, unit_type = DW_UT_partial, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000045)
164# CHECK: 0x0000003f: DW_TAG_partial_unit
165
166        .section .debug_info.dwo,"e",@progbits
167# CHECK-LABEL: .debug_info.dwo
168
169# DWARF v5 split CU header.
170        .long  CU_split_5_end-CU_split_5_version # Length of Unit
171CU_split_5_version:
172        .short 5                # DWARF version number
173        .byte 5                 # DWARF Unit Type
174        .byte 8                 # Address Size (in bytes)
175        .long 0 # Offset Into Abbrev. Section
176        .quad 0x5a              # DWO ID
177# The split compile-unit DIE, with DW_AT_producer, DW_AT_name, DW_AT_stmt_list.
178        .byte 1
179        .byte 1
180        .byte 2
181        .long 0
182        .byte 0 # NULL
183CU_split_5_end:
184
185# CHECK: 0x00000000: Compile Unit: length = 0x00000018, format = DWARF32, version = 0x0005, unit_type = DW_UT_split_compile, abbr_offset = 0x0000, addr_size = 0x08, DWO_id = 0x000000000000005a (next unit at 0x0000001c)
186# CHECK: 0x00000014: DW_TAG_compile_unit
187# CHECK-NEXT: DW_AT_producer {{.*}} "Handmade DWO producer"
188# CHECK-NEXT: DW_AT_name {{.*}} "V5_dwo_compile_unit"
189
190# Now a DWARF v5 type unit, which goes in a .debug_info.dwo comdat.
191# Note there will not be another ".debug_info.dwo contents:" line, even though
192# there is a separate ELF section header; it's dumped along with the previous
193# unit as if they were in a single section.
194
195        .section .debug_info.dwo,"Ge",@progbits,5555,comdat
196# CHECK-NOT: .debug_info.dwo
197
198# DWARF v5 split type unit header.
199TU_split_5_start:
200        .long  TU_split_5_end-TU_split_5_version  # Length of Unit
201TU_split_5_version:
202        .short 5               # DWARF version number
203        .byte 6                # DWARF Unit Type
204        .byte 8                # Address Size (in bytes)
205        .long 0    # Offset Into Abbrev. Section
206        .quad 0x8899aabbccddeeff # Type Signature
207        .long TU_split_5_type-TU_split_5_start  # Type offset
208# The type-unit DIE, which has a name.
209        .byte 2
210        .byte 0
211# The type DIE, which has a name.
212TU_split_5_type:
213        .byte 3
214        .byte 0
215        .byte 0 # NULL
216        .byte 0 # NULL
217TU_split_5_end:
218
219# CHECK: 0x00000000: Type Unit: length = 0x0000001a, format = DWARF32, version = 0x0005, unit_type = DW_UT_split_type, abbr_offset = 0x0000, addr_size = 0x08, name = 'V5_split_type_unit', type_signature = 0x8899aabbccddeeff, type_offset = 0x001a (next unit at 0x0000001e)
220# CHECK: 0x00000018: DW_TAG_type_unit
221
222        .section .debug_types,"",@progbits
223# CHECK-LABEL: .debug_types contents:
224
225# DWARF v4 Type unit header. Normal/split are identical so we do only one.
226TU_4_start:
227        .long  TU_4_end-TU_4_version  # Length of Unit
228TU_4_version:
229        .short 4               # DWARF version number
230        .long .debug_abbrev    # Offset Into Abbrev. Section
231        .byte 8                # Address Size (in bytes)
232        .quad 0x0011223344556677 # Type Signature
233        .long TU_4_type-TU_4_start # Type offset
234# The type-unit DIE, which has a name.
235        .byte 2
236        .long str_TU_4
237# The type DIE, which has a name.
238TU_4_type:
239        .byte 3
240        .long str_TU_4
241        .byte 0 # NULL
242        .byte 0 # NULL
243TU_4_end:
244
245# CHECK: 0x00000000: Type Unit: length = 0x0000001f, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08, name = 'V4_type_unit', type_signature = 0x0011223344556677, type_offset = 0x001c (next unit at 0x00000023)
246# CHECK: 0x00000017: DW_TAG_type_unit
247
248        .section .debug_line,"",@progbits
249# CHECK-LABEL: .debug_line contents:
250
251# DWARF v4 line-table header.
252LH_4_start:
253        .long   LH_4_end-LH_4_version   # Length of Unit
254LH_4_version:
255        .short  4               # DWARF version number
256        .long   LH_4_header_end-LH_4_params     # Length of Prologue
257LH_4_params:
258        .byte   1               # Minimum Instruction Length
259        .byte   1               # Maximum Operations per Instruction
260        .byte   1               # Default is_stmt
261        .byte   -5              # Line Base
262        .byte   14              # Line Range
263        .byte   13              # Opcode Base
264        .byte   0               # Standard Opcode Lengths
265        .byte   1
266        .byte   1
267        .byte   1
268        .byte   1
269        .byte   0
270        .byte   0
271        .byte   0
272        .byte   1
273        .byte   0
274        .byte   0
275        .byte   1
276        # Directory table
277        .asciz  "Directory4a"
278        .asciz  "Directory4b"
279        .byte   0
280        # File table
281        .asciz  "File4a"        # File name 1
282        .byte   1               # Directory index 1
283        .byte   0x41            # Timestamp 1
284        .byte   0x42            # File Size 1
285        .asciz  "File4b"        # File name 2
286        .byte   0               # Directory index 2
287        .byte   0x43            # Timestamp 2
288        .byte   0x44            # File Size 2
289        .byte   0               # End of list
290LH_4_header_end:
291        # Line number program, which is empty.
292LH_4_end:
293
294# CHECK: Line table prologue:
295# CHECK: version: 4
296# CHECK-NOT: address_size
297# CHECK-NOT: seg_select_size
298# CHECK: max_ops_per_inst: 1
299# CHECK: include_directories[  1] = "Directory4a"
300# CHECK: include_directories[  2] = "Directory4b"
301# CHECK-NOT: include_directories
302# CHECK: file_names[  1]:
303# CHECK-NEXT: name: "File4a"
304# CHECK-NEXT: dir_index: 1
305# CHECK-NEXT: mod_time: 0x00000041
306# CHECK-NEXT: length: 0x00000042
307# CHECK: file_names[  2]:
308# CHECK-NEXT: name: "File4b"
309# CHECK-NEXT: dir_index: 0
310# CHECK-NEXT: mod_time: 0x00000043
311# CHECK-NEXT: length: 0x00000044
312# CHECK-NOT: file_names
313
314# DWARF v5 line-table header.
315LH_5_start:
316        .long   LH_5_end-LH_5_version   # Length of Unit
317LH_5_version:
318        .short  5               # DWARF version number
319        .byte   8               # Address Size
320        .byte   0               # Segment Selector Size
321        .long   LH_5_header_end-LH_5_params     # Length of Prologue
322LH_5_params:
323        .byte   1               # Minimum Instruction Length
324        .byte   1               # Maximum Operations per Instruction
325        .byte   1               # Default is_stmt
326        .byte   -5              # Line Base
327        .byte   14              # Line Range
328        .byte   13              # Opcode Base
329        .byte   0               # Standard Opcode Lengths
330        .byte   1
331        .byte   1
332        .byte   1
333        .byte   1
334        .byte   0
335        .byte   0
336        .byte   0
337        .byte   1
338        .byte   0
339        .byte   0
340        .byte   1
341        # Directory table format
342        .byte   1               # One element per directory entry
343        .byte   1               # DW_LNCT_path
344        .byte   0x0e            # DW_FORM_strp (-> .debug_str)
345        # Directory table entries
346        .byte   2               # Two directories
347        .long   str_LT_5a
348        .long   str_LT_5b
349        # File table format
350        .byte   3               # Three elements per file entry
351        .byte   1               # DW_LNCT_path
352        .byte   0x1f            # DW_FORM_line_strp (-> .debug_line_str)
353        .byte   2               # DW_LNCT_directory_index
354        .byte   0x0b            # DW_FORM_data1
355        .byte   5               # DW_LNCT_MD5
356        .byte   0x1e            # DW_FORM_data16
357        # File table entries
358        .byte   2               # Two files
359        .long   lstr_LT_5a
360        .byte   0
361        .quad   0x7766554433221100
362        .quad   0xffeeddccbbaa9988
363        .long   lstr_LT_5b
364        .byte   1
365        .quad   0x8899aabbccddeeff
366        .quad   0x0011223344556677
367LH_5_header_end:
368        # Line number program, which is empty.
369LH_5_end:
370
371# CHECK: Line table prologue:
372# CHECK: version: 5
373# CHECK: address_size: 8
374# CHECK: seg_select_size: 0
375# CHECK: max_ops_per_inst: 1
376# Mixing .debug_str (here) with .debug_line_str (in file_names) is not
377# something a producer would do, but both are legal and we want to test them.
378# CHECK: include_directories[  0] = .debug_str[0x00000045] = "Directory5a"
379# CHECK: include_directories[  1] = .debug_str[0x00000051] = "Directory5b"
380# CHECK-NOT: include_directories
381# CHECK: file_names[  0]:
382# CHECK-NEXT: name: .debug_line_str[0x00000000] = "File5a"
383# CHECK-NEXT: dir_index: 0
384# CHECK-NEXT: md5_checksum: 00112233445566778899aabbccddeeff
385# CHECK: file_names[  1]:
386# CHECK-NEXT: name: .debug_line_str[0x00000007] = "File5b"
387# CHECK-NEXT: dir_index: 1
388# CHECK-NEXT: md5_checksum: ffeeddccbbaa99887766554433221100
389# CHECK-NOT: file_names
390
391        .section .debug_line_str,"MS",@progbits,1
392lstr_LT_5a:
393        .asciz "File5a"
394lstr_LT_5b:
395        .asciz "File5b"
396
397	.section .debug_line.dwo,"e",@progbits
398# CHECK-LABEL: .debug_line.dwo
399
400# DWARF v5 DWO line-table header.
401dwo_LH_5_start:
402        .long   dwo_LH_5_end-dwo_LH_5_version   # Length of Unit
403dwo_LH_5_version:
404        .short  5               # DWARF version number
405        .byte   8               # Address Size
406        .byte   0               # Segment Selector Size
407        .long   dwo_LH_5_header_end-dwo_LH_5_params # Length of Prologue
408dwo_LH_5_params:
409        .byte   1               # Minimum Instruction Length
410        .byte   1               # Maximum Operations per Instruction
411        .byte   1               # Default is_stmt
412        .byte   -5              # Line Base
413        .byte   14              # Line Range
414        .byte   13              # Opcode Base
415        .byte   0               # Standard Opcode Lengths
416        .byte   1
417        .byte   1
418        .byte   1
419        .byte   1
420        .byte   0
421        .byte   0
422        .byte   0
423        .byte   1
424        .byte   0
425        .byte   0
426        .byte   1
427        # Directory table format
428        .byte   1               # One element per directory entry
429        .byte   1               # DW_LNCT_path
430        .byte   0x25            # DW_FORM_strx1 (-> .debug_str.dwo)
431        # Directory table entries
432        .byte   2               # Two directories
433        .byte   3
434        .byte   4
435        # File table format
436        .byte   4               # Four elements per file entry
437        .byte   1               # DW_LNCT_path
438        .byte   0x08            # DW_FORM_string
439        .byte   2               # DW_LNCT_directory_index
440        .byte   0x0b            # DW_FORM_data1
441        .byte   3               # DW_LNCT_timestamp
442        .byte   0x0f            # DW_FORM_udata
443        .byte   4               # DW_LNCT_size
444        .byte   0x0f            # DW_FORM_udata
445        # File table entries
446        .byte   2               # Two files
447        .asciz "DWOFile5a"
448        .byte   0
449        .byte   0x15
450        .byte   0x25
451        .asciz "DWOFile5b"
452        .byte   1
453        .byte   0x35
454        .byte   0x45
455dwo_LH_5_header_end:
456        # Line number program, which is empty.
457dwo_LH_5_end:
458
459# CHECK: Line table prologue:
460# CHECK: version: 5
461# CHECK: address_size: 8
462# CHECK: seg_select_size: 0
463# CHECK: max_ops_per_inst: 1
464# CHECK: include_directories[  0] = indexed (00000003) string = "DWODirectory5a"
465# CHECK: include_directories[  1] = indexed (00000004) string = "DWODirectory5b"
466# CHECK-NOT: include_directories
467# CHECK: file_names[  0]:
468# CHECK-NEXT: name: "DWOFile5a"
469# CHECK-NEXT: dir_index: 0
470# CHECK-NEXT: mod_time: 0x00000015
471# CHECK-NEXT: length: 0x00000025
472# CHECK: file_names[  1]:
473# CHECK-NEXT: name: "DWOFile5b"
474# CHECK-NEXT: dir_index: 1
475# CHECK-NEXT: mod_time: 0x00000035
476# CHECK-NEXT: length: 0x00000045
477# CHECK-NOT: file_names
478
479# VERIFY: Verifying .debug_types
480# VERIFY: No errors.
481