xref: /llvm-project/llvm/test/tools/yaml2obj/ELF/DWARF/debug-aranges.yaml (revision a6436b0b3a7fd9f13d7a059a6a78544a7e0b702f)
1## Test that yaml2obj emits .debug_aranges section.
2
3## a) Generate the .debug_aranges section from the "DWARF" entry.
4
5## Generate and verify a big endian DWARF32 .debug_aranges section.
6
7# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB -DFORMAT=DWARF32 %s -o %t.be.o
8# RUN: llvm-readobj --sections --section-data %t.be.o | \
9# RUN:   FileCheck -DADDRALIGN=1 -DSIZE=96 %s --check-prefixes=DWARF-HEADER,DWARF-BE-CONTENT
10
11#          DWARF-HEADER: Index: 1
12#     DWARF-HEADER-NEXT: Name: .debug_aranges (1)
13#     DWARF-HEADER-NEXT: Type: SHT_PROGBITS (0x1)
14#     DWARF-HEADER-NEXT: Flags [ (0x0)
15#     DWARF-HEADER-NEXT: ]
16#     DWARF-HEADER-NEXT: Address: 0x0
17#     DWARF-HEADER-NEXT: Offset: 0x40
18#     DWARF-HEADER-NEXT: Size: [[SIZE]]
19#     DWARF-HEADER-NEXT: Link: 0
20#     DWARF-HEADER-NEXT: Info: 0
21#     DWARF-HEADER-NEXT: AddressAlignment: [[ADDRALIGN]]
22#     DWARF-HEADER-NEXT: EntrySize: 0
23# DWARF-BE-CONTENT-NEXT: SectionData (
24# DWARF-BE-CONTENT-NEXT:   0000: 0000002C 00020000 00000400 00000000
25##                               |        |   |        | |  |
26##                               |        |   |        | |  +------- Padding zeros (4-byte)
27##                               |        |   |        | +- SegSize (1-byte) 0x00
28##                               |        |   |        +- AddrSize (1-byte) 0x04
29##                               |        |   +-------- CuOffset (4-byte) 0x00
30##                               |        +--- Version (2-byte) 0x02
31##                               +------- InitialLength (4-byte) 0x2c
32##
33# DWARF-BE-CONTENT-NEXT:   0010: 00001234 00000020 00000000 00000000
34##                               |        |        |
35##                               |        |        +---------------- Terminating Entry
36##                               |        +------- Length (4-byte) 0x20
37##                               +------- Address (4-byte) 0x1234
38##
39# DWARF-BE-CONTENT-NEXT:   0020: 0000002C 00020000 00650800 00000000
40##                               |        |   |        | |  |
41##                               |        |   |        | |  +------- Padding zeros (4-byte)
42##                               |        |   |        | +- SegSize (1-byte) 0x00
43##                               |        |   |        +- AddrSize (1-byte) 0x08
44##                               |        |   +-------- CuOffset (4-byte) 0x00
45##                               |        +--- Version (2-byte) 0x02
46##                               +------- InitialLength (4-byte) 0x2c
47##
48# DWARF-BE-CONTENT-NEXT:   0030: 00000000 00005678 00000000 00000020
49##                               |                 |
50##                               |                 +---------------- Length (8-byte) 0x20
51##                               +---------------- Address (8-byte) 0x5678
52##
53# DWARF-BE-CONTENT-NEXT:   0040: 00000000 56780000 00000000 00000010
54##                               |                 |
55##                               |                 +---------------- Length (8-byte) 0x10
56##                               +---------------- Address (8-byte) 0x5678
57##
58# DWARF-BE-CONTENT-NEXT:   0050: 00000000 00000000 00000000 00000000
59##                               |
60##                               +---------------------------------- Terminating entry
61##
62# DWARF-BE-CONTENT-NEXT: )
63
64--- !ELF
65FileHeader:
66  Class: ELFCLASS64
67  Data:  [[ENDIAN]]
68  Type:  ET_EXEC
69DWARF:
70  debug_aranges:
71    - Format:               [[FORMAT]]
72      Length:               0x2c
73      Version:              2
74      CuOffset:             0
75      AddressSize:          0x04
76      SegmentSelectorSize:  0x00
77      Descriptors:
78        - Address: 0x00001234
79          Length:  0x20
80    - Format:              [[FORMAT]]
81      Length:              0x2c
82      Version:             2
83      CuOffset:            0x65
84      AddressSize:         0x08
85      SegmentSelectorSize: 0x00
86      Descriptors:
87        - Address: 0x0000000000005678
88          Length:  0x20
89        - Address: 0x0000000056780000
90          Length:  0x10
91
92## Generate and verify a little endian DWARF32 .debug_aranges section.
93
94# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB -DFORMAT=DWARF32 %s -o %t.le.o
95# RUN: llvm-readobj --sections --section-data %t.le.o | \
96# RUN:   FileCheck -DADDRALIGN=1 -DSIZE=96 %s --check-prefixes=DWARF-HEADER,DWARF-LE-CONTENT
97
98# DWARF-LE-CONTENT-NEXT: SectionData (
99# DWARF-LE-CONTENT-NEXT:   0000: 2C000000 02000000 00000400 00000000
100##                               |        |   |        | |  |
101##                               |        |   |        | |  +------- Padding zeros (4-byte)
102##                               |        |   |        | +- SegSize (1-byte) 0x00
103##                               |        |   |        +- AddrSize (1-byte) 0x04
104##                               |        |   +-------- CuOffset (4-byte) 0x00
105##                               |        +--- Version (2-byte) 0x02
106##                               +------- InitialLength (4-byte) 0x2c
107##
108# DWARF-LE-CONTENT-NEXT:   0010: 34120000 20000000 00000000 00000000
109##                               |        |        |
110##                               |        |        +---------------- Terminating Entry
111##                               |        +------- Length (4-byte) 0x20
112##                               +------- Address (4-byte) 0x1234
113##
114# DWARF-LE-CONTENT-NEXT:   0020: 2C000000 02006500 00000800 00000000
115##                               |        |   |        | |  |
116##                               |        |   |        | |  +------- Padding zeros (4-byte)
117##                               |        |   |        | +- SegSize (1-byte) 0x00
118##                               |        |   |        +- AddrSize (1-byte) 0x08
119##                               |        |   +-------- CuOffset (4-byte) 0x00
120##                               |        +--- Version (2-byte) 0x02
121##                               +------- InitialLength (4-byte) 0x2c
122##
123# DWARF-LE-CONTENT-NEXT:   0030: 78560000 00000000 20000000 00000000
124##                               |                 |
125##                               |                 +---------------- Length (8-byte) 0x20
126##                               +---------------- Address (8-byte) 0x5678
127##
128# DWARF-LE-CONTENT-NEXT:   0040: 00007856 00000000 10000000 00000000
129##                               |                 |
130##                               |                 +---------------- Length (8-byte) 0x10
131##                               +---------------- Address (8-byte) 0x5678
132##
133# DWARF-LE-CONTENT-NEXT:   0050: 00000000 00000000 00000000 00000000
134##                               |
135##                               +---------------------------------- Terminating entry
136##
137# DWARF-LE-CONTENT-NEXT: )
138
139## Generate and verify a big endian DWARF64 .debug_aranges section.
140
141# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB -DFORMAT=DWARF64 %s -o %t.be.dwarf64.o
142# RUN: llvm-readobj --sections --section-data %t.be.dwarf64.o | \
143# RUN:   FileCheck -DADDRALIGN=1 -DSIZE=120 %s --check-prefixes=DWARF-HEADER,DWARF64-BE-CONTENT
144
145# DWARF64-BE-CONTENT-NEXT: SectionData (
146# DWARF64-BE-CONTENT-NEXT:   0000: FFFFFFFF 00000000 0000002C 00020000
147##                                 |        |                 |   |
148##                                 |        |                 |   +--- CuOffset (8-byte) 0x00
149##                                 |        |                 +--- Version (2-byte) 0x02
150##                                 |        +---------------- Length (8-byte) 0x2c
151##                                 +------- DWARF64 Prefix (4-byte) UINT32_MAX
152##
153# DWARF64-BE-CONTENT-NEXT:   0010: 00000000 00000400 00001234 00000020
154##                                 |            | |  |        |
155##                                 |            | |  |        +------- Length (4-byte) 0x20
156##                                 |            | |  +------- Address (4-byte) 0x1234
157##                                 |            | +- SegSize (1-byte) 0x00
158##                                 |            +- AddrSize (1-byte) 0x04
159##                                 +------------ Lower bytes of CuOffset
160##
161# DWARF64-BE-CONTENT-NEXT:   0020: 00000000 00000000 FFFFFFFF 00000000
162##                                 |                 |        +------- Length (8-byte) 0x2c
163##                                 |                 +------- DWARF64 Prefix
164##                                 +---------------- Terminating Entry (8-byte) 0x00
165##
166# DWARF64-BE-CONTENT-NEXT:   0030: 0000002C 00020000 00000000 00650800
167##                                 |        |   |                 | |
168##                                 |        |   |                 | +- SegSize (1-byte) 0x00
169##                                 |        |   |                 +- AddrSize (1-byte) 0x08
170##                                 |        |   +----------------- CuOffset (8-byte) 0x65
171##                                 |        +--- Version (2-byte) 0x02
172##                                 +------- Lower bytes of Length
173##
174# DWARF64-BE-CONTENT-NEXT:   0040: 00000000 00000000 00000000 00005678
175##                                 |                 |
176##                                 |                 +---------------- Address (8-byte) 0x5678
177##                                 +---------------- Padding zeros (8-byte)
178##
179# DWARF64-BE-CONTENT-NEXT:   0050: 00000000 00000020 00000000 56780000
180##                                 |                 |
181##                                 |                 +---------------- Address (8-byte) 0x56780000
182##                                 +---------------- Length (8-byte) 0x20
183##
184# DWARF64-BE-CONTENT-NEXT:   0060: 00000000 00000010 00000000 00000000
185##                                 |                 |
186##                                 |                 +---------------- Terminating Entry (16-byte) 0x00
187##                                 +---------------- Length (8-byte) 0x10
188##
189# DWARF64-BE-CONTENT-NEXT:   0070: 00000000 00000000
190##                                 |
191##                                 +---------------- The last bytes of terminating entry.
192# DWARF64-BE-CONTENT-NEXT: )
193
194## Generate and verify a little endian DWARF64 .debug_aranges section.
195
196# RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB -DFORMAT=DWARF64 %s -o %t.le.dwarf64.o
197# RUN: llvm-readobj --sections --section-data %t.le.dwarf64.o | \
198# RUN:   FileCheck -DADDRALIGN=1 -DSIZE=120 %s --check-prefixes=DWARF-HEADER,DWARF64-LE-CONTENT
199
200# DWARF64-LE-CONTENT-NEXT: SectionData (
201# DWARF64-LE-CONTENT-NEXT:   0000: FFFFFFFF 2C000000 00000000 02000000
202##                                 |        |                 |   |
203##                                 |        |                 |   +--- CuOffset (8-byte) 0x00
204##                                 |        |                 +--- Version (2-byte) 0x02
205##                                 |        +---------------- Length (8-byte) 0x2c
206##                                 +------- DWARF64 Prefix (4-byte) UINT32_MAX
207##
208# DWARF64-LE-CONTENT-NEXT:   0010: 00000000 00000400 34120000 20000000
209##                                 |            | |  |        |
210##                                 |            | |  |        +------- Length (4-byte) 0x20
211##                                 |            | |  +------- Address (4-byte) 0x1234
212##                                 |            | +- SegSize (1-byte) 0x00
213##                                 |            +- AddrSize (1-byte) 0x04
214##                                 +------------ Lower bytes of CuOffset
215##
216# DWARF64-LE-CONTENT-NEXT:   0020: 00000000 00000000 FFFFFFFF 2C000000
217##                                 |                 |        +------- Length (8-byte) 0x2c
218##                                 |                 +------- DWARF64 Prefix
219##                                 +---------------- Terminating Entry (8-byte) 0x00
220##
221# DWARF64-LE-CONTENT-NEXT:   0030: 00000000 02006500 00000000 00000800
222##                                 |        |   |                 | |
223##                                 |        |   |                 | +- SegSize (1-byte) 0x00
224##                                 |        |   |                 +- AddrSize (1-byte) 0x08
225##                                 |        |   +----------------- CuOffset (8-byte) 0x65
226##                                 |        +--- Version (2-byte) 0x02
227##                                 +------- Lower bytes of Length
228##
229# DWARF64-LE-CONTENT-NEXT:   0040: 00000000 00000000 78560000 00000000
230##                                 |                 |
231##                                 |                 +---------------- Address (8-byte) 0x5678
232##                                 +---------------- Padding zeros (8-byte)
233##
234# DWARF64-LE-CONTENT-NEXT:   0050: 20000000 00000000 00007856 00000000
235##                                 |                 |
236##                                 |                 +---------------- Address (8-byte) 0x56780000
237##                                 +---------------- Length (8-byte) 0x20
238##
239# DWARF64-LE-CONTENT-NEXT:   0060: 10000000 00000000 00000000 00000000
240##                                 |                 |
241##                                 |                 +---------------- Terminating Entry (16-byte) 0x00
242##                                 +---------------- Length (8-byte) 0x10
243##
244# DWARF64-LE-CONTENT-NEXT:   0070: 00000000 00000000
245##                                 |
246##                                 +---------------- The last bytes of terminating entry.
247# DWARF64-LE-CONTENT-NEXT: )
248
249## b) Generate the .debug_aranges section from raw section content.
250
251# RUN: yaml2obj --docnum=2 %s -o %t2.o
252# RUN: llvm-readobj --sections --section-data %t2.o | \
253# RUN:   FileCheck %s -DADDRALIGN=0 -DSIZE=3 --check-prefixes=DWARF-HEADER,ARBITRARY-CONTENT
254
255#      ARBITRARY-CONTENT: SectionData (
256# ARBITRARY-CONTENT-NEXT:   0000: 112233
257# ARBITRARY-CONTENT-NEXT: )
258
259--- !ELF
260FileHeader:
261  Class: ELFCLASS64
262  Data:  ELFDATA2MSB
263  Type:  ET_EXEC
264Sections:
265  - Name:    .debug_aranges
266    Type:    SHT_PROGBITS
267    Content: "112233"
268
269## c) Generate the .debug_aranges section when the "Size" is specified.
270
271# RUN: yaml2obj --docnum=3 %s -o %t3.o
272# RUN: llvm-readobj --hex-dump=.debug_aranges %t3.o | FileCheck %s --check-prefix=SIZE
273
274#       SIZE: Hex dump of section '.debug_aranges':
275#  SIZE-NEXT: 0x00000000 00000000 00000000 00000000 00000000 ................
276# SIZE-EMPTY:
277
278--- !ELF
279FileHeader:
280  Class: ELFCLASS64
281  Data:  ELFDATA2MSB
282  Type:  ET_EXEC
283Sections:
284  - Name: .debug_aranges
285    Type: SHT_PROGBITS
286    Size: 0x10
287
288## d) Test that yaml2obj emits an error message when both the "Size" and the
289## "debug_aranges" entry are specified at the same time.
290
291# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR
292
293# ERROR: yaml2obj: error: cannot specify section '.debug_aranges' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time
294
295--- !ELF
296FileHeader:
297  Class: ELFCLASS64
298  Data:  ELFDATA2MSB
299  Type:  ET_EXEC
300Sections:
301  - Name: .debug_aranges
302    Type: SHT_PROGBITS
303    Size: 0x10
304DWARF:
305  debug_aranges:
306    - Length:              0x2c
307      Version:             2
308      CuOffset:            0
309      AddressSize:         0x08
310      SegmentSelectorSize: 0x00
311      Descriptors:
312        - Address: 0x0000000000001234
313          Length:  0x20
314
315## e) Test that yaml2obj emits an error message when both the "Content" and the
316## "debug_aranges" entry are specified at the same time.
317
318# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR
319
320--- !ELF
321FileHeader:
322  Class: ELFCLASS64
323  Data:  ELFDATA2MSB
324  Type:  ET_EXEC
325Sections:
326  - Name:    .debug_aranges
327    Type:    SHT_PROGBITS
328    Content: "00"
329DWARF:
330  debug_aranges:
331    - Length:              0x2c
332      Version:             2
333      CuOffset:            0
334      AddressSize:         0x08
335      SegmentSelectorSize: 0x00
336      Descriptors:
337        - Address: 0x0000000000001234
338          Length:  0x20
339
340## f) Test that all the properties can be overridden by the section header when
341## the "debug_aranges" entry doesn't exist.
342
343# RUN: yaml2obj --docnum=6 %s -o %t6.o
344# RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN
345
346#      OVERRIDDEN: [Nr] Name           Type   Address          Off    Size   ES Flg Lk Inf Al
347#      OVERRIDDEN: [ 1] .debug_aranges STRTAB 0000000000002020 000050 000030 01   A  2   1  2
348# OVERRIDDEN-NEXT: [ 2] .sec           STRTAB 0000000000000000 000080 000000 00      0   0  0
349
350--- !ELF
351FileHeader:
352  Class: ELFCLASS64
353  Data:  ELFDATA2MSB
354  Type:  ET_EXEC
355Sections:
356  - Name:         .debug_aranges
357    Type:         SHT_STRTAB         # SHT_PROGBITS by default.
358    Flags:        [SHF_ALLOC]        # 0 by default.
359    Link:         .sec               # 0 by default.
360    EntSize:      1                  # 0 by default.
361    Info:         1                  # 0 by default.
362    AddressAlign: 2                  # 0 by default.
363    Address:      0x0000000000002020 # 0x00 by default.
364    Offset:       0x00000050         # 0x40 for the first section.
365    Size:         0x30               # Set the "Size" so that we can reuse the check tag "OVERRIDDEN".
366  - Name:         .sec               # Linked by .debug_aranges.
367    Type:         SHT_STRTAB
368
369## g) Test that all the properties can be overridden by the section header when
370## the "debug_aranges" entry exists.
371
372# RUN: yaml2obj --docnum=7 %s -o %t7.o
373# RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN
374
375--- !ELF
376FileHeader:
377  Class: ELFCLASS64
378  Data:  ELFDATA2MSB
379  Type:  ET_EXEC
380Sections:
381  - Name:         .debug_aranges
382    Type:         SHT_STRTAB         # SHT_PROGBITS by default.
383    Flags:        [SHF_ALLOC]        # 0 by default.
384    Link:         .sec               # 0 by default.
385    EntSize:      1                  # 0 by default.
386    Info:         1                  # 0 by default.
387    AddressAlign: 2                  # 1 by default.
388    Address:      0x0000000000002020 # 0x00 by default.
389    Offset:       0x00000050         # 0x40 for the first section.
390  - Name:         .sec               # Linked by .debug_aranges.
391    Type:         SHT_STRTAB
392DWARF:
393  debug_aranges:
394    - Length:              0x2c
395      Version:             2
396      CuOffset:            0
397      AddressSize:         0x08
398      SegmentSelectorSize: 0x00
399      Descriptors:
400        - Address: 0x0000000000001234
401          Length:  0x20
402
403## h) Test that yaml2obj still generates a .debug_aranges section if we assign an invalid value
404## to 'AddrSize' when the 'Descriptors' list is empty.
405
406# RUN: yaml2obj --docnum=8 %s -o %t8.o
407# RUN: llvm-readelf --hex-dump=.debug_aranges %t8.o | \
408# RUN:   FileCheck %s --check-prefix=ADDR-SIZE
409
410#      ADDR-SIZE: Hex dump of section '.debug_aranges':
411# ADDR-SIZE-NEXT: 0x00000000 2c000000 02000000 00000700 00000000
412##                                                 ^~ address_size (1-byte) 0x07
413# ADDR-SIZE-NEXT: 0x00000010 00000000 00000000 00000000
414
415--- !ELF
416FileHeader:
417  Class: ELFCLASS64
418  Data:  ELFDATA2LSB
419  Type:  ET_EXEC
420DWARF:
421  debug_aranges:
422    - Length:              0x2c
423      Version:             2
424      CuOffset:            0
425      AddressSize:         0x07 ## Invalid address_size.
426      SegmentSelectorSize: 0
427      Descriptors:         []
428
429## i) Test that yaml2obj emits an error message if we try to assign an invalid value to
430## 'AddrSize' when the 'Descriptors' list isn't empty.
431
432# RUN: not yaml2obj --docnum=9 %s 2>&1 | \
433# RUN:   FileCheck %s --check-prefix=INVALID-SIZE
434
435# INVALID-SIZE: yaml2obj: error: unable to write debug_aranges address: invalid integer write size: 7
436
437--- !ELF
438FileHeader:
439  Class: ELFCLASS64
440  Data:  ELFDATA2LSB
441  Type:  ET_EXEC
442DWARF:
443  debug_aranges:
444    - Length:              0x2c
445      Version:             2
446      CuOffset:            0
447      AddressSize:         0x07 ## Invalid address_size.
448      SegmentSelectorSize: 0
449      Descriptors:
450        - Address: 0x1234
451          Length:  0x1000
452
453## j) Test the default value of address_size and segment_selector_size in a 64/32-bit object file.
454
455# RUN: yaml2obj --docnum=10 -DCLASS=ELFCLASS64 %s -o %t10.64-bit.o
456# RUN: llvm-readelf --hex-dump=.debug_aranges %t10.64-bit.o | \
457# RUN:   FileCheck %s --check-prefix=DEFAULT64
458
459#      DEFAULT64: Hex dump of section '.debug_aranges':
460# DEFAULT64-NEXT: 0x00000000 2c000000 02000000 00000800 00000000 ,...............
461##                           ^-------                            unit_length (4-byte)
462##                                    ^---                       version (2-byte)
463##                                        ^--------              debug_info_offset (4-byte)
464##                                                 ^-            address_size (1-byte)
465##                                                   ^-          segment_selector_size (1-byte)
466##                                                      ^------- padding (4-byte)
467# DEFAULT64-NEXT: 0x00000010 34120000 00000000 00100000 00000000 4...............
468##                           ^----------------                   address (8-byte)
469##                                             ^---------------- length (8-byte)
470# DEFAULT64-NEXT: 0x00000020 00000000 00000000 00000000 00000000 ................
471##                           ^---------------------------------- terminating entry (16-byte)
472
473# RUN: yaml2obj --docnum=10 -DCLASS=ELFCLASS32 %s -o %t10.32-bit.o
474# RUN: llvm-readelf --hex-dump=.debug_aranges %t10.32-bit.o | \
475# RUN:   FileCheck %s --check-prefix=DEFAULT32
476
477#      DEFAULT32: Hex dump of section '.debug_aranges':
478# DEFAULT32-NEXT: 0x00000000 2c000000 02000000 00000400 00000000 ,...............
479##                           ^-------                            unit_length (4-byte)
480##                                    ^---                       version (2-byte)
481##                                        ^--------              debug_info_offset (4-byte)
482##                                                 ^-            address_size (1-byte)
483##                                                   ^-          segment_selector_size (1-byte)
484##                                                      ^------- padding (4-byte)
485# DEFAULT32-NEXT: 0x00000010 34120000 00100000 00000000 00000000 4...............
486##                           ^-------                            address (4-byte)
487##                                    ^-------                   length (4-byte)
488##                                             ^---------------- terminating entry (8-byte)
489
490--- !ELF
491FileHeader:
492  Class: [[CLASS]]
493  Data:  ELFDATA2LSB
494  Type:  ET_EXEC
495DWARF:
496  debug_aranges:
497    - Length:              0x2c
498      Version:             2
499      CuOffset:            0
500      Descriptors:
501        - Address: 0x1234
502          Length:  0x1000
503
504## k) Test that yaml2obj is able to determine the correct length for the address range table
505## if the 'Length' field isn't specified.
506
507# RUN: yaml2obj --docnum=11 -DCLASS=ELFCLASS64 -DADDRSIZE=4 %s -o %t11.64-bit.o
508# RUN: llvm-readelf --hex-dump=.debug_aranges %t11.64-bit.o | \
509# RUN:   FileCheck %s --check-prefix=LENGTH64
510
511#      LENGTH64: Hex dump of section '.debug_aranges':
512# LENGTH64-NEXT: 0x00000000 2c000000 02000000 00000800 00000000 ,...............
513##                          ^-------                            unit_length (4-byte)
514##                                   ^---                       version (2-byte)
515##                                       ^--------              debug_info_offset (4-byte)
516##                                                ^-            address_size (1-byte)
517##                                                  ^-          segment_selector_size (1-byte)
518##                                                     ^------- padding (4-byte)
519# LENGTH64-NEXT: 0x00000010 34120000 00000000 00100000 00000000 4...............
520##                          ^----------------                   address (8-byte)
521##                                            ^---------------- length (8-byte)
522# LENGTH64-NEXT: 0x00000020 00000000 00000000 00000000 00000000 ................
523##                          ^---------------------------------- terminating entry (16-byte)
524# LENGTH64-NEXT: 0x00000030 ffffffff 1c000000 00000000 02000000 ................
525##                          ^-------------------------          unit_length (12-byte)
526##                                                     ^---     version (2-byte)
527##                                                         ^--- debug_info_offset (8-byte)
528# LENGTH64-NEXT: 0x00000040 00000000 00000400 34120000 21430000 ........4...!C..
529##                          -------------
530##                                       ^-                     address_size (1-byte)
531##                                         ^-                   segment_selector_size (1-byte)
532##                                            ^-------          address (4-byte)
533##                                                     ^------- length (4-byte)
534# LENGTH64-NEXT: 0x00000050 00000000 00000000                   ........
535##                          ^----------------                   terminating entry (8-byte)
536
537# RUN: yaml2obj --docnum=11 -DCLASS=ELFCLASS32 -DADDRSIZE=8 %s -o %t11.32-bit.o
538# RUN: llvm-readelf --hex-dump=.debug_aranges %t11.32-bit.o | \
539# RUN:   FileCheck %s --check-prefix=LENGTH32
540
541#      LENGTH32: Hex dump of section '.debug_aranges':
542# LENGTH32-NEXT: 0x00000000 1c000000 02000000 00000400 00000000 ................
543##                          ^-------                            unit_length (4-byte)
544##                                   ^---                       version (2-byte)
545##                                       ^--------              debug_info_offset (4-byte)
546##                                                ^-            address_size (1-byte)
547##                                                  ^-          segment_selector_size (1-byte)
548##                                                     ^------- padding (4-byte)
549# LENGTH32-NEXT: 0x00000010 34120000 00100000 00000000 00000000 4...............
550##                          ^-------                            address (4-byte)
551##                                   ^-------                   length (4-byte)
552##                                            ^---------------- terminating entry (8-byte)
553# LENGTH32-NEXT: 0x00000020 ffffffff 34000000 00000000 02000000 ....4...........
554##                          ^-------------------------          unit_length (12-byte)
555##                                                     ^---     version (2-byte)
556##                                                         ^--- debug_info_offset (8-byte)
557# LENGTH32-NEXT: 0x00000030 00000000 00000800 00000000 00000000 ................
558##                          -------------
559##                                       ^-                     address_size (1-byte)
560##                                         ^-                   segment_selector_size (1-byte)
561##                                            ^---------------- padding (8-byte)
562# LENGTH32-NEXT: 0x00000040 34120000 00000000 21430000 00000000 4.......!C......
563##                          ^----------------                   address (8-byte)
564##                                            ^---------------- length (8-byte)
565# LENGTH32-NEXT: 0x00000050 00000000 00000000 00000000 00000000 ................
566##                          ^---------------------------------- terminating entry (16-byte)
567
568--- !ELF
569FileHeader:
570  Class: [[CLASS]]
571  Data:  ELFDATA2LSB
572  Type:  ET_EXEC
573DWARF:
574  debug_aranges:
575    - Version:  2
576      CuOffset: 0
577      Descriptors:
578        - Address: 0x1234
579          Length:  0x1000
580    - Format:      DWARF64
581      Version:     2
582      AddressSize: [[ADDRSIZE]]
583      CuOffset:    0
584      Descriptors:
585        - Address: 0x1234
586          Length:  0x4321
587
588## l) Test that the .debug_aranges section header is emitted if the "debug_aranges"
589## entry is empty.
590
591# RUN: yaml2obj --docnum=12 %s -o %t12.o
592# RUN: llvm-readobj --sections --section-data %t12.o | \
593# RUN:   FileCheck -DSIZE=0 -DADDRALIGN=1 %s --check-prefixes=DWARF-HEADER,EMPTY-CONTENT
594
595# EMPTY-CONTENT-NEXT: SectionData (
596# EMPTY-CONTENT-NEXT: )
597
598--- !ELF
599FileHeader:
600  Class: ELFCLASS64
601  Data:  ELFDATA2LSB
602  Type:  ET_EXEC
603DWARF:
604  debug_aranges: []
605