Add PR check to suggest alternatives to using undef (#118506)
[llvm-project.git] / llvm / test / tools / yaml2obj / ELF / DWARF / debug-info.yaml
blob218e1837af73ee0969499eaa6c50e7075cef97cb
1 ## Test that yaml2obj emits .debug_info section.
3 ## a) Generate the .debug_info section from the "DWARF" entry.
5 ## Generate and verify a DWARF32 little endian .debug_info (DWARFv5) section.
7 # RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB %s -o %t1.le.o
8 # RUN: llvm-readobj --sections --section-data %t1.le.o | \
9 # RUN:   FileCheck -DINDEX=2 -DNAME=15 -DOFFSET=0x9B -DSIZE=179 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-LE-CONTENT
11 #                    SHDR: Index: [[INDEX]]
12 #               SHDR-NEXT: Name: .debug_info ([[NAME]])
13 #               SHDR-NEXT: Type: SHT_PROGBITS (0x1)
14 #               SHDR-NEXT: Flags [ (0x0)
15 #               SHDR-NEXT: ]
16 #               SHDR-NEXT: Address: 0x0
17 #               SHDR-NEXT: Offset: [[OFFSET]]
18 #               SHDR-NEXT: Size: [[SIZE]]
19 #               SHDR-NEXT: Link: 0
20 #               SHDR-NEXT: Info: 0
21 #               SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]
22 #               SHDR-NEXT: EntrySize: 0
23 # DWARF32-LE-CONTENT-NEXT: SectionData (
24 # DWARF32-LE-CONTENT-NEXT:   0000: 34120000 05000304 34120000 01785634
25 ##                                 ^-------                            unit_length (4-byte)
26 ##                                          ^---                       version (2-byte)
27 ##                                              ^-                     unit_type (1-byte) DW_UT_type
28 ##                                                ^-                   address_size (1-byte)
29 ##                                                   ^-------          debug_abbrev_offset (4-byte)
30 ##                                                            ^-       abbreviation code (LEB128) 0x01
31 ##                                                              ^----- Form: DW_FORM_addr (4-byte)
32 # DWARF32-LE-CONTENT-NEXT:   0010: 12020012 34020000 00123434 12785634
33 ##                                 --
34 ##                                   ^---                              Form: DW_FORM_block2 size (2-byte)
35 ##                                       ^- ^-                         Form: DW_FORM_block2 body (2-byte)
36 ##                                            ^--------                Form: DW_FORM_block4 size (4-byte)
37 ##                                                     ^-^-            Form: DW_FORM_block4 body (2-byte)
38 ##                                                         ^----       Form: DW_FORM_data2 (2-byte)
39 ##                                                              ^----- Form: DW_FORM_data4 (4-byte)
40 # DWARF32-LE-CONTENT-NEXT:   0020: 12F0DEBC 9A785634 12616263 64000212
41 ##                                 --
42 ##                                   ^-----------------                Form: DW_FORM_data8 (8-byte)
43 ##                                                     ^----------     Form: DW_FORM_string "abcd\0"
44 ##                                                                ^-   Form: DW_FORM_block size (ULEB128)
45 ##                                                                  ^- Form: DW_FORM_block body (2-byte)
46 # DWARF32-LE-CONTENT-NEXT:   0030: 34021234 1201B424 78563412 B4247856
47 ##                                 ^-                                  Form: DW_FORM_block body
48 ##                                   ^-                                Form: DW_FORM_block1 size (1-byte)
49 ##                                     ^-^-                            Form: DW_FORM_block1 body (2-byte)
50 ##                                          ^-                         Form: DW_FORM_data1 (1-byte)
51 ##                                            ^-                       Form: DW_FORM_flag (1-byte)
52 ##                                              ^---                   Form: DW_FORM_sdata (SLEB128) 0x1234
53 ##                                                   ^-------          Form: DW_FORM_strp (4-byte)
54 ##                                                            ^---     Form: DW_FORM_udata (ULEB128) 0x1234
55 ##                                                                ^--- Form: DW_FORM_ref_addr (4-byte)
56 # DWARF32-LE-CONTENT-NEXT:   0040: 34121234 12785634 12F0DEBC 9A785634
57 ##                                 ----
58 ##                                     ^-                              Form: DW_FORM_ref1 (1-byte)
59 ##                                       ^----                         Form: DW_FORM_ref2 (2-byte)
60 ##                                            ^--------                Form: DW_FORM_ref4 (4-byte)
61 ##                                                     ^-------------- Form: DW_FORM_ref8 (8-byte)
62 # DWARF32-LE-CONTENT-NEXT:   0050: 12B42408 65666768 00341200 00021234
63 ##                                 --
64 ##                                   ^---                              Form: DW_FORM_ref_udata (ULEB128) 0x1234
65 ##                                       ^-                            Form: DW_FORM_indirect (ULEB128) DW_FORM_string
66 ##                                          ^----------                "efgh\0"
67 ##                                                     ^--------       Form: DW_FORM_sec_offset (4-byte)
68 ##                                                              ^-     Form: DW_FORM_exprloc size (ULEB128) 0x02
69 ##                                                                ^-^- Form: DW_FORM_exprloc body (2-byte)
70 # DWARF32-LE-CONTENT-NEXT:   0060: B424B424 78563412 78563412 78563412
71 ##                                 ^---                                Form: DW_FORM_strx (ULEB128)
72 ##                                     ^---                            Form: DW_FORM_addrx (ULEB128)
73 ##                                          ^-------                   Form: DW_FORM_ref_sup4 (4-byte)
74 ##                                                   ^-------          Form: DW_FORM_strp_sup (4-byte)
75 ##                                                            ^------- Form: DW_FORM_line_strp (4-byte)
76 # DWARF32-LE-CONTENT-NEXT:   0070: F0DEBC9A 78563412 B424B424 F0DEBC9A
77 ##                                 ^----------------                   Form: DW_FORM_ref_sig8 (8-byte)
78 ##                                                   ^---              Form: DW_FORM_loclistx (ULEB128)
79 ##                                                       ^---          Form: DW_FORM_rnglistx (ULEB128)
80 ##                                                            ^------- Form: DW_FORM_ref_sup8 (8-byte)
81 # DWARF32-LE-CONTENT-NEXT:   0080: 78563412 12341278 56341212 34127856
82 ##                                 --------
83 ##                                          ^-                         Form: DW_FORM_strx1 (1-byte)
84 ##                                            ^---                     Form: DW_FORM_strx2 (2-byte)
85 ##                                                ^--------            Form: DW_FORM_strx4 (4-byte)
86 ##                                                         ^-          Form: DW_FORM_addrx1 (1-byte)
87 ##                                                            ^---     Form: DW_FORM_addrx2 (1-byte)
88 ##                                                                ^--- Form: DW_FORM_addrx4 (4-byte)
89 # DWARF32-LE-CONTENT-NEXT:   0090: 34123412 00000500 01043412 00000078
90 ##                                 ----
91 ##                                     ^--------                       unit_length (4-byte)
92 ##                                              ^---                   version (2-byte)
93 ##                                                   ^-                unit_type (1-byte)
94 ##                                                     ^-              address_size (1-byte)
95 ##                                                       ^--------     debug_abbrev_offset (4-byte)
96 ##                                                                ^-   abbrev code (ULEB128) 0x00
97 ##                                                                  ^- unit_length (4-byte)
98 # DWARF32-LE-CONTENT-NEXT:   00A0: 56000004 00785600 00040178 56341202
99 ##                                 ------
100 ##                                       ^----                         version (2-byte)
101 ##                                            ^--------                debug_abbrev_offset (4-byte)
102 ##                                                     ^-              address_size (1-byte)
103 ##                                                       ^-            abbrev code (ULEB128) 0x01
104 ##                                                         ^--------   Form: DW_FORM_addr
105 ##                                                                  ^- Form: DW_FORM_block2 size (2-byte)
106 # DWARF32-LE-CONTENT-NEXT:   00B0: 001234
107 ##                                 --
108 ##                                   ^-^-                              Form: DW_FORM_block2 body (2-byte)
109 # DWARF32-LE-CONTENT-NEXT: )
111 --- !ELF
112 FileHeader:
113   Class: ELFCLASS64
114   Data:  [[ENDIAN]]
115   Type:  ET_EXEC
116 DWARF:
117   debug_abbrev:
118     - Table:
119         - Code:     1
120           Tag:      DW_TAG_compile_unit
121           Children: DW_CHILDREN_no
122           Attributes:
123             - Attribute: 0x01
124               Form:      DW_FORM_addr           ## 0x01
125             - Attribute: 0x01
126               Form:      DW_FORM_block2         ## 0x03
127             - Attribute: 0x01
128               Form:      DW_FORM_block4         ## 0x04
129             - Attribute: 0x01
130               Form:      DW_FORM_data2          ## 0x05
131             - Attribute: 0x01
132               Form:      DW_FORM_data4          ## 0x06
133             - Attribute: 0x01
134               Form:      DW_FORM_data8          ## 0x07
135             - Attribute: 0x01
136               Form:      DW_FORM_string         ## 0x08
137             - Attribute: 0x01
138               Form:      DW_FORM_block          ## 0x09
139             - Attribute: 0x01
140               Form:      DW_FORM_block1         ## 0x0a
141             - Attribute: 0x01
142               Form:      DW_FORM_data1          ## 0x0b
143             - Attribute: 0x01
144               Form:      DW_FORM_flag           ## 0x0c
145             - Attribute: 0x01
146               Form:      DW_FORM_sdata          ## 0x0d
147             - Attribute: 0x01
148               Form:      DW_FORM_strp           ## 0x0e
149             - Attribute: 0x01
150               Form:      DW_FORM_udata          ## 0x0f
151             - Attribute: 0x01
152               Form:      DW_FORM_ref_addr       ## 0x10
153             - Attribute: 0x01
154               Form:      DW_FORM_ref1           ## 0x11
155             - Attribute: 0x01
156               Form:      DW_FORM_ref2           ## 0x12
157             - Attribute: 0x01
158               Form:      DW_FORM_ref4           ## 0x13
159             - Attribute: 0x01
160               Form:      DW_FORM_ref8           ## 0x14
161             - Attribute: 0x01
162               Form:      DW_FORM_ref_udata      ## 0x15
163             - Attribute: 0x01
164               Form:      DW_FORM_indirect       ## 0x16
165             - Attribute: 0x01
166               Form:      DW_FORM_sec_offset     ## 0x17
167             - Attribute: 0x01
168               Form:      DW_FORM_exprloc        ## 0x18
169             - Attribute: 0x01
170               Form:      DW_FORM_strx           ## 0x1a
171             - Attribute: 0x01
172               Form:      DW_FORM_addrx          ## 0x1b
173             - Attribute: 0x01
174               Form:      DW_FORM_ref_sup4       ## 0x1c
175             - Attribute: 0x01
176               Form:      DW_FORM_strp_sup       ## 0x1d
177             - Attribute: 0x01
178               Form:      DW_FORM_data16         ## 0x1e
179             - Attribute: 0x01
180               Form:      DW_FORM_line_strp      ## 0x1f
181             - Attribute: 0x01
182               Form:      DW_FORM_ref_sig8       ## 0x20
183             - Attribute: 0x01
184               Form:      DW_FORM_implicit_const ## 0x21
185               Value:     0x01
186             - Attribute: 0x01
187               Form:      DW_FORM_loclistx       ## 0x22
188             - Attribute: 0x01
189               Form:      DW_FORM_rnglistx       ## 0x23
190             - Attribute: 0x01
191               Form:      DW_FORM_ref_sup8       ## 0x24
192             - Attribute: 0x01
193               Form:      DW_FORM_strx1          ## 0x25
194             - Attribute: 0x01
195               Form:      DW_FORM_strx2          ## 0x26
196             - Attribute: 0x01
197               Form:      DW_FORM_strx3          ## 0x27
198             - Attribute: 0x01
199               Form:      DW_FORM_strx4          ## 0x28
200             - Attribute: 0x01
201               Form:      DW_FORM_addrx1         ## 0x29
202             - Attribute: 0x01
203               Form:      DW_FORM_addrx2         ## 0x2a
204             - Attribute: 0x01
205               Form:      DW_FORM_addrx3         ## 0x2b
206             - Attribute: 0x01
207               Form:      DW_FORM_addrx4         ## 0x2c
208   debug_info:
209     - Length:     0x1234
210       Version:    5
211       UnitType:   DW_UT_partial
212       AbbrOffset: 0x1234
213       AddrSize:   4
214       Entries:
215         - AbbrCode: 1
216           Values:
217             - Value: 0x12345678         ## DW_FORM_addr
218             - BlockData:                ## DW_FORM_block2
219                 - 0x12
220                 - 0x34
221             - BlockData:                ## DW_FORM_block4
222                 - 0x12
223                 - 0x34
224             - Value: 0x1234             ## DW_FORM_data2
225             - Value: 0x12345678         ## DW_FORM_data4
226             - Value: 0x123456789abcdef0 ## DW_FORM_data8
227             - CStr:  abcd               ## DW_FORM_string
228             - BlockData:                ## DW_FORM_block
229                 - 0x12
230                 - 0x34
231             - BlockData:                ## DW_FORM_block1
232                 - 0x12
233                 - 0x34
234             - Value: 0x12               ## DW_FORM_data1
235             - Value: 0x01               ## DW_FORM_flag
236             - Value: 0x1234             ## DW_FORM_sdata
237             - Value: 0x12345678         ## DW_FORM_strp
238             - Value: 0x1234             ## DW_FORM_udata
239             - Value: 0x12345678         ## DW_FORM_ref_addr
240             - Value: 0x12               ## DW_FORM_ref1
241             - Value: 0x1234             ## DW_FORM_ref2
242             - Value: 0x12345678         ## DW_FORM_ref4
243             - Value: 0x123456789abcdef0 ## DW_FORM_ref8
244             - Value: 0x1234             ## DW_FORM_ref_udata
245             - Value: 0x08               ## DW_FORM_indirect. The following value's form is 0x08, which is DW_FORM_string.
246             - CStr:  efgh
247             - Value: 0x1234             ## DW_FORM_sec_offset
248             - BlockData:                ## DW_FORM_exprloc
249                 - 0x12
250                 - 0x34
251             - Value: 0x1234             ## DW_FORM_strx
252             - Value: 0x1234             ## DW_FORM_addrx
253             - Value: 0x12345678         ## DW_FORM_ref_sup4
254             - Value: 0x12345678         ## DW_FORM_strp_sup
255             - Value: 0x1234             ## DW_FORM_data16 (unimplemented)
256             - Value: 0x12345678         ## DW_FORM_line_strp
257             - Value: 0x123456789abcdef0 ## DW_FORM_ref_sig8
258             - Value: 0x1234             ## DW_FORM_implicit_const (unimplemented)
259             - Value: 0x1234             ## DW_FORM_loclistx
260             - Value: 0x1234             ## DW_FORM_rnglistx
261             - Value: 0x123456789abcdef0 ## DW_FORM_ref_sup8
262             - Value: 0x12               ## DW_FORM_strx1
263             - Value: 0x1234             ## DW_FORM_strx2
264             - Value: 0x123456           ## DW_FORM_strx3 (unimplemented)
265             - Value: 0x12345678         ## DW_FORM_strx4
266             - Value: 0x12               ## DW_FORM_addrx1
267             - Value: 0x1234             ## DW_FORM_addrx2
268             - Value: 0x123456           ## DW_FORM_addrx3 (unimplemented)
269             - Value: 0x12345678         ## DW_FORM_addrx4
270     - Length:        0x1234
271       Version:       5
272       ## Test another unit type.
273       UnitType:      DW_UT_compile
274       AbbrOffset:    0x1234
275       AddrSize:      4
276       Entries:
277         - AbbrCode: 0
278           Values:   []
279     - Length:        0x5678
280       ## Test DWARFv4
281       Version:       4
282       AbbrevTableID: 0
283       AbbrOffset:    0x5678
284       AddrSize:      4
285       Entries:
286         - AbbrCode: 1
287           Values:
288             - Value: 0x12345678 ## DW_FORM_addr
289             - BlockData:        ## DW_FORM_block2
290                 - 0x12
291                 - 0x34
293 ## Generate and verify a DWARF32 big endian .debug_info (DWARFv4) section.
295 # RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.be.o
296 # RUN: llvm-readobj --sections --section-data %t1.be.o | \
297 # RUN:   FileCheck -DINDEX=2 -DNAME=15 -DOFFSET=0x9B -DSIZE=179 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-BE-CONTENT
299 # DWARF32-BE-CONTENT-NEXT: SectionData (
300 # DWARF32-BE-CONTENT-NEXT:   0000: 00001234 00050304 00001234 01123456
301 ##                                 ^-------                            unit_length (4-byte)
302 ##                                          ^---                       version (2-byte)
303 ##                                              ^-                     unit_type (1-byte) DW_UT_type
304 ##                                                ^-                   address_size (1-byte)
305 ##                                                   ^-------          debug_abbrev_offset (4-byte)
306 ##                                                            ^-       abbreviation code (LEB128) 0x01
307 ##                                                              ^----- Form: DW_FORM_addr (4-byte)
308 # DWARF32-BE-CONTENT-NEXT:   0010: 78000212 34000000 02123412 34123456
309 ##                                 --
310 ##                                   ^---                              Form: DW_FORM_block2 size (2-byte)
311 ##                                       ^- ^-                         Form: DW_FORM_block2 body (2-byte)
312 ##                                            ^--------                Form: DW_FORM_block4 size (4-byte)
313 ##                                                     ^-^-            Form: DW_FORM_block4 body (2-byte)
314 ##                                                         ^----       Form: DW_FORM_data2 (2-byte)
315 ##                                                              ^----- Form: DW_FORM_data4 (4-byte)
316 # DWARF32-BE-CONTENT-NEXT:   0020: 78123456 789ABCDE F0616263 64000212
317 ##                                 --
318 ##                                   ^-----------------                Form: DW_FORM_data8 (8-byte)
319 ##                                                     ^----------     Form: DW_FORM_string "abcd\0"
320 ##                                                                ^-   Form: DW_FORM_block size (ULEB128)
321 ##                                                                  ^- Form: DW_FORM_block body (2-byte)
322 # DWARF32-BE-CONTENT-NEXT:   0030: 34021234 1201B424 12345678 B4241234
323 ##                                 ^-                                  Form: DW_FORM_block body
324 ##                                   ^-                                Form: DW_FORM_block1 size (1-byte)
325 ##                                     ^-^-                            Form: DW_FORM_block1 body (2-byte)
326 ##                                          ^-                         Form: DW_FORM_data1 (1-byte)
327 ##                                            ^-                       Form: DW_FORM_flag (1-byte)
328 ##                                              ^---                   Form: DW_FORM_sdata (SLEB128) 0x1234
329 ##                                                   ^-------          Form: DW_FORM_strp (4-byte)
330 ##                                                            ^---     Form: DW_FORM_udata (ULEB128) 0x1234
331 ##                                                                ^--- Form: DW_FORM_ref_addr (4-byte)
332 # DWARF32-BE-CONTENT-NEXT:   0040: 56781212 34123456 78123456 789ABCDE
333 ##                                 ----
334 ##                                     ^-                              Form: DW_FORM_ref1 (1-byte)
335 ##                                       ^----                         Form: DW_FORM_ref2 (2-byte)
336 ##                                            ^--------                Form: DW_FORM_ref4 (4-byte)
337 ##                                                     ^-------------- Form: DW_FORM_ref8 (8-byte)
338 # DWARF32-BE-CONTENT-NEXT:   0050: F0B42408 65666768 00000012 34021234
339 ##                                 --
340 ##                                   ^---                              Form: DW_FORM_ref_udata (ULEB128) 0x1234
341 ##                                       ^-                            Form: DW_FORM_indirect (ULEB128) DW_FORM_string
342 ##                                          ^----------                "efgh\0"
343 ##                                                     ^--------       Form: DW_FORM_sec_offset (4-byte)
344 ##                                                              ^-     Form: DW_FORM_exprloc size (ULEB128) 0x02
345 ##                                                                ^-^- Form: DW_FORM_exprloc body (2-byte)
346 # DWARF32-BE-CONTENT-NEXT:   0060: B424B424 12345678 12345678 12345678
347 ##                                 ^---                                Form: DW_FORM_strx (ULEB128)
348 ##                                     ^---                            Form: DW_FORM_addrx (ULEB128)
349 ##                                          ^-------                   Form: DW_FORM_ref_sup4 (4-byte)
350 ##                                                   ^-------          Form: DW_FORM_strp_sup (4-byte)
351 ##                                                            ^------- Form: DW_FORM_line_strp (4-byte)
352 # DWARF32-BE-CONTENT-NEXT:   0070: 12345678 9ABCDEF0 B424B424 12345678
353 ##                                 ^----------------                   Form: DW_FORM_ref_sig8 (8-byte)
354 ##                                                   ^---              Form: DW_FORM_loclistx (ULEB128)
355 ##                                                       ^---          Form: DW_FORM_rnglistx (ULEB128)
356 ##                                                            ^------- Form: DW_FORM_ref_sup8 (8-byte)
357 # DWARF32-BE-CONTENT-NEXT:   0080: 9ABCDEF0 12123412 34567812 12341234
358 ##                                 --------
359 ##                                          ^-                         Form: DW_FORM_strx1 (1-byte)
360 ##                                            ^---                     Form: DW_FORM_strx2 (2-byte)
361 ##                                                ^--------            Form: DW_FORM_strx4 (4-byte)
362 ##                                                         ^-          Form: DW_FORM_addrx1 (1-byte)
363 ##                                                            ^---     Form: DW_FORM_addrx2 (1-byte)
364 ##                                                                ^--- Form: DW_FORM_addrx4 (4-byte)
365 # DWARF32-BE-CONTENT-NEXT:   0090: 56780000 12340005 01040000 12340000
366 ##                                 ----
367 ##                                     ^--------                       unit_length (4-byte)
368 ##                                              ^---                   version (2-byte)
369 ##                                                   ^-                unit_type (1-byte)
370 ##                                                     ^-              address_size (1-byte)
371 ##                                                       ^--------     debug_abbrev_offset (4-byte)
372 ##                                                                ^-   abbrev code (ULEB128) 0x00
373 ##                                                                  ^- unit_length (4-byte)
374 # DWARF32-BE-CONTENT-NEXT:   00A0: 00567800 04000056 78040112 34567800
375 ##                                 ------
376 ##                                       ^----                         version (2-byte)
377 ##                                            ^--------                debug_abbrev_offset (4-byte)
378 ##                                                     ^-              address_size (1-byte)
379 ##                                                       ^-            abbrev code (ULEB128) 0x01
380 ##                                                         ^--------   Form: DW_FORM_addr
381 ##                                                                  ^- Form: DW_FORM_block2 size (2-byte)
382 # DWARF32-BE-CONTENT-NEXT:   00B0: 021234
383 ##                                 --
384 ##                                   ^-^-                              Form: DW_FORM_block2 body (2-byte)
385 # DWARF32-BE-CONTENT-NEXT: )
387 ## b) Generate the .debug_info section from raw section content.
389 # RUN: yaml2obj --docnum=2 %s -o %t2.o
390 # RUN: llvm-readobj --sections --section-data %t2.o | \
391 # RUN:   FileCheck -DINDEX=1 -DNAME=1 -DOFFSET=0x40 -DSIZE=3 -DADDRALIGN=0 %s --check-prefixes=SHDR,ARBITRARY-CONTENT
393 # ARBITRARY-CONTENT-NEXT: SectionData (
394 # ARBITRARY-CONTENT-NEXT:   0000: 112233
395 # ARBITRARY-CONTENT-NEXT: )
397 --- !ELF
398 FileHeader:
399   Class: ELFCLASS64
400   Data:  ELFDATA2LSB
401   Type:  ET_EXEC
402 Sections:
403   - Name:    .debug_info
404     Type:    SHT_PROGBITS
405     Content: "112233"
407 ## c) Generate the .debug_info section when the "Size" is specified.
409 # RUN: yaml2obj --docnum=3 %s -o %t3.o
410 # RUN: llvm-readobj --sections --section-data %t3.o | \
411 # RUN:   FileCheck -DINDEX=1 -DNAME=1 -DOFFSET=0x40 -DSIZE=16 -DADDRALIGN=0 %s --check-prefixes=SHDR,SIZE
413 # SIZE-NEXT: SectionData (
414 # SIZE-NEXT:   0000: 00000000 00000000 00000000 00000000
415 # SIZE-NEXT: )
417 --- !ELF
418 FileHeader:
419   Class: ELFCLASS64
420   Data:  ELFDATA2LSB
421   Type:  ET_EXEC
422 Sections:
423   - Name: .debug_info
424     Type: SHT_PROGBITS
425     Size: 0x10
427 ## d) Test that yaml2obj emits an error message when both the "Size" and the
428 ## "debug_info" entry are specified at the same time.
430 # RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=AMBIGUOUS-CONTENT
432 # AMBIGUOUS-CONTENT: yaml2obj: error: cannot specify section '.debug_info' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time
434 --- !ELF
435 FileHeader:
436   Class: ELFCLASS64
437   Data:  ELFDATA2LSB
438   Type:  ET_EXEC
439 Sections:
440   - Name: .debug_info
441     Type: SHT_PROGBITS
442     Size: 0x10
443 DWARF:
444   debug_abbrev:
445     - Table:
446         - Code:       1
447           Tag:        DW_TAG_compile_unit
448           Children:   DW_CHILDREN_no
449   debug_info:
450     - Length:     0x1234
451       Version:    5
452       UnitType:   DW_UT_compile
453       AbbrOffset: 0x1234
454       Entries:    []
456 ## e) Test that yaml2obj emits an error message when both the "Content" and the
457 ## "debug_info" entry are specified at the same time.
459 # RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=AMBIGUOUS-CONTENT
461 --- !ELF
462 FileHeader:
463   Class: ELFCLASS64
464   Data:  ELFDATA2LSB
465   Type:  ET_EXEC
466 Sections:
467   - Name: .debug_info
468     Type: SHT_PROGBITS
469     Content: "00"
470 DWARF:
471   debug_abbrev:
472     - Table:
473         - Code:       1
474           Tag:        DW_TAG_compile_unit
475           Children:   DW_CHILDREN_no
476   debug_info:
477     - Length:     0x1234
478       Version:    5
479       UnitType:   DW_UT_compile
480       AbbrOffset: 0x1234
481       Entries:    []
483 ## f) Test that all the properties can be overridden by the section header when
484 ## the "debug_info" entry doesn't exist.
486 # RUN: yaml2obj --docnum=6 %s -o %t6.o
487 # RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN
489 #      OVERRIDDEN: [Nr] Name        Type   Address          Off    Size   ES Flg Lk Inf Al
490 #      OVERRIDDEN: [ 1] .debug_info STRTAB 0000000000002020 000050 00000d 01   A  2   1  2
491 # OVERRIDDEN-NEXT: [ 2] .sec        STRTAB 0000000000000000 00005d 000000 00      0   0  0
493 --- !ELF
494 FileHeader:
495   Class: ELFCLASS64
496   Data:  ELFDATA2LSB
497   Type:  ET_EXEC
498 Sections:
499   - Name:         .debug_info
500     Type:         SHT_STRTAB  ## SHT_PROGBITS by default.
501     Flags:        [SHF_ALLOC] ## 0 by default.
502     Link:         .sec        ## 0 by default.
503     EntSize:      1           ## 0 by default.
504     Info:         1           ## 0 by default.
505     AddressAlign: 2           ## 0 by default.
506     Address:      0x2020      ## 0x00 by default.
507     Offset:       0x50        ## 0x40 for the first section.
508     Size:         0x0d        ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".
509   - Name:         .sec        ## Linked by .debug_info.
510     Type:         SHT_STRTAB
512 ## g) Test that all the properties can be overridden by the section header when
513 ## the "debug_info" entry exists.
515 # RUN: yaml2obj --docnum=7 %s -o %t7.o
516 # RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN
518 --- !ELF
519 FileHeader:
520   Class: ELFCLASS64
521   Data:  ELFDATA2LSB
522   Type:  ET_EXEC
523 Sections:
524   - Name:         .debug_info
525     Type:         SHT_STRTAB  ## SHT_PROGBITS by default.
526     Flags:        [SHF_ALLOC] ## 0 by default.
527     Link:         .sec        ## 0 by default.
528     EntSize:      1           ## 0 by default.
529     Info:         1           ## 0 by default.
530     AddressAlign: 2           ## 0 by default.
531     Address:      0x2020      ## 0x00 by default.
532     Offset:       0x50        ## 0x40 for the first section.
533   - Name:         .sec        ## Linked by .debug_info.
534     Type:         SHT_STRTAB
535 DWARF:
536   debug_abbrev:
537     - Table:
538         - Code:       1
539           Tag:        DW_TAG_compile_unit
540           Children:   DW_CHILDREN_no
541   debug_info:
542     - Length:     0x1234
543       Version:    5
544       UnitType:   DW_UT_compile
545       AbbrOffset: 0x1234
546       Entries:
547         - AbbrCode: 0
548           Values:   []
550 ## h) Test that yaml2obj doesn't crash when the 'Entries' of a compilation unit is empty.
552 # RUN: yaml2obj --docnum=8 %s -o %t8.o
553 # RUN: llvm-readelf --hex-dump=.debug_info %t8.o | \
554 # RUN:   FileCheck %s --check-prefix=EMPTY-ENTRIES --match-full-lines
556 #       EMPTY-ENTRIES: Hex dump of section '.debug_info':
557 #  EMPTY-ENTRIES-NEXT: 0x00000000 34120000 05000104 34120000 4.......4...
558 # EMPTY-ENTRIES-EMPTY:
559 ##                                ^- 'Entries' is empty
561 --- !ELF
562 FileHeader:
563   Class: ELFCLASS32
564   Data:  ELFDATA2LSB
565   Type:  ET_EXEC
566 DWARF:
567   debug_info:
568     - Length:     0x1234
569       Version:    5
570       UnitType:   DW_UT_compile
571       AbbrOffset: 0x1234
572       Entries:    []
574 ## h) Test that yaml2obj emits values in the DIE according to the abbreviation whose
575 ## index is equal to the value in 'AbbrevCode'.
577 # RUN: yaml2obj --docnum=9 %s -o %t9.o
578 # RUN: llvm-readelf --hex-dump=.debug_info %t9.o | \
579 # RUN:   FileCheck %s --check-prefix=FORM --match-full-lines
581 #       FORM: Hex dump of section '.debug_info':
582 #  FORM-NEXT: 0x00000000 34120000 05000104 34120000 02341221 4.......4....4.!
583 ##                       ^-------                            unit_length (4-byte)
584 ##                                                  ^-       abbreviation code (ULEB128)
585 ##                                                    ^---   Form: DW_FORM_data2 (2-byte)
586 ##                                                        ^- Form: DW_FORM_data4 (4-byte)
587 #  FORM-NEXT: 0x00000010 43658701 21436587 341200            Ce..!Ce.4..
588 ##                       ------
589 ##                             ^-                            abbreviation code (ULEB128)
590 ##                                ^-------                   Form: DW_FORM_data4 (4-byte)
591 ##                                         ^---              Form: DW_FORM_data2 (2-byte)
592 ##                                             ^-            abbreviation code (ULEB128)
593 # FORM-EMPTY:
595 --- !ELF
596 FileHeader:
597   Class: ELFCLASS32
598   Data:  ELFDATA2LSB
599   Type:  ET_EXEC
600 DWARF:
601   debug_abbrev:
602     - Table:
603         - Tag:        DW_TAG_compile_unit
604           Children:   DW_CHILDREN_yes
605           Attributes:
606             - Attribute: DW_AT_low_pc
607               Form:      DW_FORM_data4
608             - Attribute: DW_AT_high_pc
609               Form:      DW_FORM_data2
610         - Tag:        DW_TAG_subprogram
611           Children:   DW_CHILDREN_no
612           Attributes:
613             - Attribute: DW_AT_low_pc
614               Form:      DW_FORM_data2
615             - Attribute: DW_AT_high_pc
616               Form:      DW_FORM_data4
617   debug_info:
618     - Length:     0x1234
619       Version:    5
620       UnitType:   DW_UT_compile
621       AbbrOffset: 0x1234
622       Entries:
623         ## Test that yaml2obj emits values when the abbrev code is specified.
624         - AbbrCode: 2
625           Values:
626             - Value: 0x1234
627             - Value: 0x87654321
628         ## Test that yaml2obj emits values when the abbrev code is specified to
629         ## be lower than the first abbrev.
630         - AbbrCode: 1
631           Values:
632             - Value: 0x87654321
633             - Value: 0x1234
634         ## Test that yaml2obj ignores the contents of entries with abbrev code 0.
635         - AbbrCode: 0
636           Values:
637             - Value: 0x1234
639 ## i) Test that yaml2obj reports an error when 'debug_info' has values in its
640 ## entries but 'debug_abbrev' doesn't have enough attributes for them.
642 # RUN: not yaml2obj --docnum=10 %s -o %t10.o 2>&1 | \
643 # RUN:   FileCheck %s --check-prefixes=ERROR
645 # ERROR: yaml2obj: error: abbrev code must be less than or equal to the number of entries in abbreviation table
647 --- !ELF
648 FileHeader:
649   Class: ELFCLASS64
650   Data:  ELFDATA2LSB
651   Type:  ET_EXEC
652 DWARF:
653   debug_abbrev:
654     - Table: []
655   debug_info:
656     - Length:     0x1234
657       Version:    5
658       UnitType:   DW_UT_compile
659       AbbrOffset: 0x1234
660       Entries:
661         - AbbrCode: 1
662           Values:
663             - Value: 0x1234
665 ## j) Test that yaml2obj emits the correct DWARFv5 unit headers.
667 # RUN: yaml2obj --docnum=11 %s -o %t11.o
668 # RUN: llvm-readelf --hex-dump=.debug_info %t11.o | \
669 # RUN:   FileCheck %s --check-prefix=DWARFV5-HEADER
671 #      DWARFV5-HEADER: Hex dump of section '.debug_info':
672 # DWARFV5-HEADER-NEXT: 0x00000000 ffffffff 0d000000 00000000 05000108 ................
673 ##                                ^-------------------------          unit_length (12-byte)
674 ##                                                           ^---     version (2-byte)
675 ##                                                               ^-   unit_type (1-byte)
676 ##                                                                 ^- address_size (1-byte)
677 # DWARFV5-HEADER-NEXT: 0x00000010 34120000 00000000 00150000 00050002 4...............
678 ##                                ^----------------                   debug_abbrev_offset (8-byte)
679 ##                                                  ^-                End of children (1-byte)
680 ##                                                    ^--------       unit_length (4-byte)
681 ##                                                             ^---   version (2-byte)
682 ##                                                                 ^- unit_type (1-byte)
683 # DWARFV5-HEADER-NEXT: 0x00000020 08341200 000df0ad baefbead de180000 .4..............
684 ##                                ^-                                  address_size (1-byte)
685 ##                                  ^--------                         debug_abbrev_offset (4-byte)
686 ##                                           ^-----------------       type_signature (8-byte)
687 ##                                \/                           ^----- type_offset (4-byte)
688 # DWARFV5-HEADER-NEXT: 0x00000030 0000ffff ffff1d00 00000000 00000500 ................
689 ##                                  ^-                                End of children (1-byte)
690 ##                                    ^--------------------------     unit_length (12-byte)
691 ##                                                               ^--- version (2-byte)
692 # DWARFV5-HEADER-NEXT: 0x00000040 02083412 00000000 00000df0 adbaefbe ..4.............
693 ##                                ^-                                  unit_type (1-byte)
694 ##                                  ^-                                address_size (1-byte)
695 ##                                    ^-----------------              debug_abbrev_offset (8-byte)
696 ##                                \/--                  ^------------ type_signature (8-byte)
697 # DWARFV5-HEADER-NEXT: 0x00000050 adde2800 00000000 00000011 00000005 ..(.............
698 ##                                    ^-----------------              type_offset (8-byte)
699 ##                                                      ^-            End of children (1-byte)
700 ##                                                        ^--------   unit_length (4-byte)
701 ##                                \/                               ^- version (2-byte)
702 # DWARFV5-HEADER-NEXT: 0x00000060 00040834 1200000d f0adbaef beadde00 ...4............
703 ##                                  ^-                                  unit_type (1-byte)
704 ##                                    ^-                                address_size (1-byte)
705 ##                                      ^--------                       debug_abbrev_offset (4-byte)
706 ##                                               ^-----------------     type_signature (8-byte)
707 ##                                                                 ^-   End of children (1-byte)
711 --- !ELF
712 FileHeader:
713   Class: ELFCLASS64
714   Data:  ELFDATA2LSB
715   Type:  ET_EXEC
716 DWARF:
717   debug_info:
718     - Format:        DWARF64
719       Version:       5
720       UnitType:      DW_UT_compile
721       AbbrOffset:    0x1234
722       Entries:
723         - AbbrCode: 0
724     - Version:       5
725       UnitType:      DW_UT_type
726       AbbrOffset:    0x1234
727       TypeSignature: 0xdeadbeefbaadf00d
728       TypeOffset:    24
729       Entries:
730         - AbbrCode: 0
731     - Format:     DWARF64
732       Version:       5
733       UnitType:      DW_UT_type
734       AbbrOffset:    0x1234
735       TypeSignature: 0xdeadbeefbaadf00d
736       TypeOffset:    40
737       Entries:
738         - AbbrCode: 0
739     - Version:       5
740       UnitType:      DW_UT_skeleton
741       AbbrOffset:    0x1234
742       DwoID:         0xdeadbeefbaadf00d
743       Entries:
744         - AbbrCode: 0
746 ## DWARFv4 unit header.
748 # RUN: yaml2obj --docnum=12 %s -o %t12.o
749 # RUN: llvm-readelf --hex-dump=.debug_info %t12.o | \
750 # RUN:   FileCheck %s --check-prefix=DWARFV4-HEADER
752 #      DWARFV4-HEADER: Hex dump of section '.debug_info':
753 # DWARFV4-HEADER-NEXT: 0x00000000 ffffffff 0c000000 00000000 04003412 ..............4.
754 ##                                ^-------------------------          unit_length (12-byte)
755 ##                                                           ^---     version (2-byte)
756 ##                                                               ^--- debug_abbrev_offset (8-byte)
757 # DWARFV4-HEADER-NEXT: 0x00000010 00000000 000008                     .......
758 ##                                -------------
759 ##                                             ^-                     address_size (1-byte)
761 --- !ELF
762 FileHeader:
763   Class: ELFCLASS64
764   Data:  ELFDATA2LSB
765   Type:  ET_EXEC
766 DWARF:
767   debug_info:
768     - Format:     DWARF64
769       Length:     0x0c
770       Version:    4
771       AbbrOffset: 0x1234
772       Entries:    []
774 ## k) Test that yaml2obj is able to emit a correct length for compilation units.
776 # RUN: yaml2obj --docnum=13 %s -o %t13.o
777 # RUN: llvm-readelf --hex-dump=.debug_info %t13.o | \
778 # RUN:   FileCheck %s --check-prefix=INFER-LENGTH
780 #      INFER-LENGTH: Hex dump of section '.debug_info':
781 # INFER-LENGTH-NEXT: 0x00000000 37000000 04000000 00000801 00000000 7...............
782 ##                              ^-------                            unit_length (0x37)
783 ##                                       ^---                       version (2-byte)
784 ##                                           ^--------              debug_abbrev_offset (4-byte)
785 ##                                                    ^-            address_size (1-byte)
786 ##                                                      ^-          abbrev code (ULEB128) 0x01
787 ##                                                         ^------- Form: DW_FORM_strp (4-byte)
788 # INFER-LENGTH-NEXT: 0x00000010 0c001600 00000000 00001e00 00002011 .............. .
789 ##                              ^---                                Form: DW_FORM_data2 (2-byte)
790 ##                                  ^--------                       Form: DW_FORM_strp (4-byte)
791 ##                                           ^--------              Form: DW_FORM_sec_offset (4-byte)
792 ##                                                    ^--------     Form: DW_FORM_strp (4-byte)
793 ##                                                             ^--- Form: DW_FORM_addr (8-byte)
794 # INFER-LENGTH-NEXT: 0x00000020 00000000 00003300 00000220 11000000 ......3.... ....
795 ##                              -------------
796 ##                                           ^--------              Form: DW_FORM_data4 (4-byte)
797 ##                                                    ^-            abbrev code (ULEB128) 0x02
798 ##                                                      ^---------- Form: DW_FORM_addr (8-byte)
799 # INFER-LENGTH-NEXT: 0x00000030 00000006 00000038 000000            .......8...
800 ##                              ------
801 ##                                    ^--------                     Form: DW_FORM_data4 (4-byte)
802 ##                                             ^--------            Form: DW_FORM_strp (4-byte)
804 ## The handwritten DIEs should look like:
806 ## 0x0000000b: DW_TAG_compile_unit [1] *
807 ##               DW_AT_producer [DW_FORM_strp]        ( .debug_str[0x00000000] = "clang version 10.0.0 ")
808 ##               DW_AT_language [DW_FORM_data2]       (DW_LANG_C99)
809 ##               DW_AT_name [DW_FORM_strp]            ( .debug_str[0x00000016] = "hello.c")
810 ##               DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
811 ##               DW_AT_comp_dir [DW_FORM_strp]        ( .debug_str[0x0000001e] = "/home/v/x/llvm/playground")
812 ##               DW_AT_low_pc [DW_FORM_addr]          (0x0000000000001120)
813 ##               DW_AT_high_pc [DW_FORM_data4]        (0x00000033)
814 ## 
815 ## 0x0000002a:   DW_TAG_subprogram [2]  
816 ##                 DW_AT_low_pc [DW_FORM_addr]        (0x0000000000001120)
817 ##                 DW_AT_high_pc [DW_FORM_data4]      (0x00000006)
818 ##                 DW_AT_name [DW_FORM_strp]          ( .debug_str[0x00000038] = "main")
820 --- !ELF
821 FileHeader:
822   Class: ELFCLASS64
823   Data:  ELFDATA2LSB
824   Type:  ET_EXEC
825 DWARF:
826   debug_str:
827     - "clang version 10.0.0 "
828     - "hello.c"
829     - "/home/v/x/llvm/playground"
830     - "main"
831   debug_abbrev:
832     - Table:
833         - Code:     1
834           Tag:      DW_TAG_compile_unit
835           Children: DW_CHILDREN_yes
836           Attributes:
837             - Attribute: DW_AT_producer
838               Form:      DW_FORM_strp
839             - Attribute: DW_AT_language
840               Form:      DW_FORM_data2
841             - Attribute: DW_AT_name
842               Form:      DW_FORM_strp
843             - Attribute: DW_AT_stmt_list
844               Form:      DW_FORM_sec_offset
845             - Attribute: DW_AT_comp_dir
846               Form:      DW_FORM_strp
847             - Attribute: DW_AT_low_pc
848               Form:      DW_FORM_addr
849             - Attribute: DW_AT_high_pc
850               Form:      DW_FORM_data4
851         - Code: 2
852           Tag:  DW_TAG_subprogram
853           Children: DW_CHILDREN_no
854           Attributes:
855             - Attribute: DW_AT_low_pc
856               Form:      DW_FORM_addr
857             - Attribute: DW_AT_high_pc
858               Form:      DW_FORM_data4
859             - Attribute: DW_AT_name
860               Form:      DW_FORM_strp
861   debug_info:
862     - Version:    4
863       AbbrOffset: 0x00
864       Entries:
865         - AbbrCode: 1
866           Values:
867             - Value: 0x00   ## DW_AT_producer [DW_FORM_strp]
868             - Value: 0x0c   ## DW_LANG_C99, DW_AT_language [DW_FORM_data2]
869             - Value: 0x16   ## DW_AT_name [DW_FORM_strp]
870             - Value: 0x00   ## DW_AT_stmt_list [DW_FORM_sec_offset]
871             - Value: 0x1e   ## DW_AT_comp_dir [DW_FORM_strp]
872             - Value: 0x1120 ## DW_AT_low_pc [DW_FORM_addr]
873             - Value: 0x33   ## DW_AT_high_pc [DW_FORM_data4]
874         - AbbrCode: 2
875           Values:
876             - Value: 0x1120 ## DW_AT_low_pc [DW_FORM_addr]
877             - Value: 0x06   ## DW_AT_high_pc [DW_FORM_data4]
878             - Value: 0x38   ## DW_AT_name [DW_FORM_strp]
880 ## l) Test that if we don't specify the 'Values' key for an entry, yaml2obj will only emit the abbrev_code.
882 # RUN: yaml2obj --docnum=14 %s -o %t14.o
883 # RUN: llvm-readelf --hex-dump=.debug_info %t14.o | \
884 # RUN:   FileCheck %s --check-prefix=NO-VALUES
886 #      NO-VALUES: Hex dump of section '.debug_info':
887 # NO-VALUES-NEXT: 0x00000000 0a000000 04000000 00000801 0002     ..............
888 ##                           ^-------                            unit_length (4-byte)
889 ##                                    ^---                       version (2-byte)
890 ##                                        ^--------              debug_abbrev_offset (4-byte)
891 ##                                                 ^-            address_size (1-byte)
892 ##                                                   ^-          abbrev_code (ULEB128) 0x01
893 ##                                                      ^-       abbrev_code (ULEB128) 0x00
894 ##                                                        ^-     abbrev_code (ULEB128) 0x02
896 --- !ELF
897 FileHeader:
898   Class: ELFCLASS64
899   Data:  ELFDATA2LSB
900   Type:  ET_EXEC
901 DWARF:
902   debug_info:
903     - Version:    4
904       AbbrOffset: 0x00
905       Entries:
906         - AbbrCode: 1
907         - AbbrCode: 0
908         - AbbrCode: 2
910 ## m) Test that yaml2obj is able to infer the address size from the object file.
912 # RUN: yaml2obj --docnum=15 -DBITS=64 %s -o %t15.64-bit.o
913 # RUN: llvm-readelf --hex-dump=.debug_info %t15.64-bit.o | \
914 # RUN:   FileCheck %s --check-prefix=ADDRSIZE -DADDRSIZE=08
916 #      ADDRSIZE: Hex dump of section '.debug_info':
917 # ADDRSIZE-NEXT: 0x00000000 07000000 04000000 0000[[ADDRSIZE]]            ...........
919 # RUN: yaml2obj --docnum=15 -DBITS=32 %s -o %t15.32-bit.o
920 # RUN: llvm-readelf --hex-dump=.debug_info %t15.32-bit.o | \
921 # RUN:   FileCheck %s --check-prefix=ADDRSIZE -DADDRSIZE=04
923 --- !ELF
924 FileHeader:
925   Class: ELFCLASS[[BITS]]
926   Data:  ELFDATA2LSB
927   Type:  ET_EXEC
928 DWARF:
929   debug_info:
930     - Version:    4
931       AbbrOffset: 0x00
933 ## n) Test that yaml2obj emits an error message when a compilation unit has values but there is no associated abbrev table.
935 ## RUN: not yaml2obj --docnum=16 %s 2>&1 | FileCheck %s --check-prefix=NO-ABBREV
937 # NO-ABBREV: yaml2obj: error: cannot find abbrev table whose ID is 0 for compilation unit with index 0
939 --- !ELF
940 FileHeader:
941   Class:   ELFCLASS64
942   Data:    ELFDATA2LSB
943   Type:    ET_EXEC
944   Machine: EM_X86_64
945 DWARF:
946   debug_info:
947     - Version:    4
948       AbbrOffset: 0x00
949       Entries:
950         - AbbrCode: 1
951           Values:
952             - Value: 0x1234
954 ## o) Test that yaml2obj is able to generate compilation units according to the
955 ## associated abbrev table that is referenced by the 'AbbrevTableID' and infer
956 ## the value of the debug_abbrev_offset field.
958 # RUN: yaml2obj --docnum=17 %s -o %t17.o
959 # RUN: llvm-readelf --hex-dump=.debug_info %t17.o | FileCheck %s --check-prefix=MULTI-TABLES
961 #      MULTI-TABLES: Hex dump of section '.debug_info':
962 # MULTI-TABLES-NEXT: 0x00000000 0c000000 04000800 00000801 34120000 ............4...
963 ##                              ^-------                            unit_length (4-byte)
964 ##                                       ^---                       version (2-byte)
965 ##                                           ^--------              debug_abbrev_offset (4-byte)
966 ##                                                    ^-            address_size (1-byte)
967 ##                                                      ^-          abbrev_code (ULEB128) 0x01
968 ##                                                         ^------- Form: DW_FORM_data4 (4-byte) 0x1234
969 # MULTI-TABLES-NEXT: 0x00000010 0c000000 04000800 00000801 21430000 ............!C..
970 ##                              ^-------                            unit_length (4-byte)
971 ##                                       ^---                       version (2-byte)
972 ##                                           ^--------              debug_abbrev_offset (4-byte)
973 ##                                                    ^-            address_size (1-byte)
974 ##                                                      ^-          abbrev_code (ULEB128) 0x01
975 ##                                                         ^------- Form: DW_FORM_data4 (4-byte) 0x4321
976 # MULTI-TABLES-NEXT: 0x00000020 10000000 04000000 00000801 78560000 ............xV..
977 ##                              ^-------                            unit_length (4-byte)
978 ##                                       ^---                       version (2-byte)
979 ##                                           ^--------              debug_abbrev_offset (4-byte)
980 ##                                                    ^-            address_size (1-byte)
981 ##                                                      ^-          abbrev_code (ULEB128) 0x01
982 ##                                                         ^------- Form: DW_FORM_addr (8-byte) 0x5678
983 # MULTI-TABLES-NEXT: 0x00000030 00000000 0b000000 04001000 00000801 ................
984 ##                              --------
985 ##                                       ^-------                   unit_length (4-byte)
986 ##                                                ^---              version (2-byte)
987 ##                                                    ^--------     debug_abbrev_offset (4-byte)
988 ##                                                             ^-   address_size (1-byte)
989 ##                                                               ^- abbrev_code (ULEB128) 0x01
990 # MULTI-TABLES-NEXT: 0x00000040 e58e02                              ...
991 ##                              ^-----                              Form: DW_FORM_udata (ULEB128) 0x8765
993 --- !ELF
994 FileHeader:
995   Class:   ELFCLASS64
996   Data:    ELFDATA2LSB
997   Type:    ET_EXEC
998 DWARF:
999   debug_abbrev:
1000     - Table:
1001         - Code:     1
1002           Tag:      DW_TAG_compile_unit
1003           Children: DW_CHILDREN_no
1004           Attributes:
1005             - Attribute: DW_AT_low_pc
1006               Form:      DW_FORM_addr
1007     - ID: 2
1008       Table:
1009         - Code:     1
1010           Tag:      DW_TAG_compile_unit
1011           Children: DW_CHILDREN_no
1012           Attributes:
1013             - Attribute: DW_AT_low_pc
1014               Form:      DW_FORM_data4
1015     - ID: 1
1016       Table:
1017         - Code:     1
1018           Tag:      DW_TAG_compile_unit
1019           Children: DW_CHILDREN_no
1020           Attributes:
1021             - Attribute: DW_AT_low_pc
1022               Form:      DW_FORM_udata
1023   debug_info:
1024     - Version:       4
1025       AbbrevTableID: 2
1026       Entries:
1027         - AbbrCode: 1
1028           Values:
1029             - Value: 0x1234
1030     - Version:       4
1031       AbbrevTableID: 2
1032       Entries:
1033         - AbbrCode: 1
1034           Values:
1035             - Value: 0x4321
1036     - Version:       4
1037       AbbrevTableID: 0
1038       Entries:
1039         - AbbrCode: 1
1040           Values:
1041             - Value: 0x5678
1042     - Version:       4
1043       AbbrevTableID: 1
1044       Entries:
1045         - AbbrCode: 1
1046           Values:
1047             - Value: 0x8765
1049 ## p) Test that when the debug_abbrev_offset field isn't specified and there is no associated
1050 ## abbrev table, yaml2obj will assign 0 to the debug_abbrev_offset field.
1052 # RUN: yaml2obj --docnum=18 %s -o %t18.o
1053 # RUN: llvm-readelf --hex-dump=.debug_info %t18.o | FileCheck %s --check-prefix=ZERO-OFFSET
1055 #      ZERO-OFFSET: Hex dump of section '.debug_info':
1056 # ZERO-OFFSET-NEXT: 0x00000000 07000000 04000000 000008            ...........
1057 ##                             ^-------                            unit_length (4-byte)
1058 ##                                      ^---                       version (2-byte)
1059 ##                                          ^--------              debug_abbrev_offset (4-byte)
1060 ##                                                   ^-            address_size (1-byte)
1062 --- !ELF
1063 FileHeader:
1064   Class:   ELFCLASS64
1065   Data:    ELFDATA2LSB
1066   Type:    ET_EXEC
1067 DWARF:
1068   debug_info:
1069     - Version:       4
1070       AbbrevTableID: [[ABBREVID=<none>]]
1072 ## q) Test that when we assign an invalid 'AbbrevTableID' that doesn't point to an abbrev table,
1073 ## yaml2obj will assign 0 to the debug_abbrev_offset field.
1075 # RUN: yaml2obj --docnum=18 -DABBREVID=2 %s -o %t18.o
1076 # RUN: llvm-readelf --hex-dump=.debug_info %t18.o | FileCheck %s --check-prefix=ZERO-OFFSET