1 ## Test how we dump the .debug_aranges section.
3 ## a) Test dumping the DWARF32/64 address range table from 32/64-bit, little/big endian object files.
4 ## The .debug_aranges should be written to the 'DWARF' entry and the 'Sections' entry should remain empty.
6 # RUN: yaml2obj --docnum=1 -DBITS=32 -DENDIAN=LSB %s | obj2yaml | \
7 # RUN: FileCheck %s --check-prefix=BASIC --implicit-check-not=Sections \
8 # RUN: -DLENGTH1=24 -DLENGTH2=24 -DADDRSIZE=0x4 \
9 # RUN: -DVARADDR=0x1234 -DVARLEN=0x5678
11 # RUN: yaml2obj --docnum=1 -DBITS=32 -DENDIAN=MSB %s | obj2yaml | \
12 # RUN: FileCheck %s --check-prefix=BASIC --implicit-check-not=Sections \
13 # RUN: -DLENGTH1=24 -DLENGTH2=24 -DADDRSIZE=0x4 \
14 # RUN: -DVARADDR=0x1234 -DVARLEN=0x5678
16 # RUN: yaml2obj --docnum=1 -DBITS=64 -DENDIAN=LSB %s | obj2yaml | \
17 # RUN: FileCheck %s --check-prefix=BASIC --implicit-check-not=Sections \
18 # RUN: -DLENGTH1=3C -DLENGTH2=44 -DADDRSIZE=0x8 \
19 # RUN: -DVARADDR=0x1234 -DVARLEN=0x5678
21 # RUN: yaml2obj --docnum=1 -DBITS=64 -DENDIAN=MSB %s | obj2yaml | \
22 # RUN: FileCheck %s --check-prefix=BASIC --implicit-check-not=Sections \
23 # RUN: -DLENGTH1=3C -DLENGTH2=44 -DADDRSIZE=0x8 \
24 # RUN: -DVARADDR=0x1234 -DVARLEN=0x5678
27 # BASIC-NEXT: debug_aranges:
28 # BASIC-NEXT: - Length: 0x[[LENGTH1]]
29 # BASIC-NEXT: Version: 2
30 # BASIC-NEXT: CuOffset: 0x1234
31 # BASIC-NEXT: AddressSize: [[ADDRSIZE]]
32 # BASIC-NEXT: Descriptors:
33 # BASIC-NEXT: - Address: 0x1234
34 # BASIC-NEXT: Length: 0x5678
35 # BASIC-NEXT: - Address: 0x1234
36 # BASIC-NEXT: Length: 0x5678
37 # BASIC-NEXT: - Format: DWARF64
38 # BASIC-NEXT: Length: 0x[[LENGTH2]]
39 # BASIC-NEXT: Version: 2
40 # BASIC-NEXT: CuOffset: 0x1234567890ABCDEF
41 # BASIC-NEXT: AddressSize: [[ADDRSIZE]]
42 # BASIC-NEXT: Descriptors:
43 # BASIC-NEXT: - Address: [[VARADDR]]
44 # BASIC-NEXT: Length: [[VARLEN]]
45 # BASIC-NEXT: - Address: 0x1234
46 # BASIC-NEXT: Length: 0x5678
51 Class: ELFCLASS[[BITS]]
52 Data: ELFDATA2[[ENDIAN]]
65 CuOffset: 0x1234567890abcdef
67 - Address: [[ADDR=0x1234]]
68 Length: [[LENGTH=0x5678]]
72 ## b) Test dumping an .debug_aranges section whose section header properties are overridden.
74 # RUN: yaml2obj --docnum=2 -DTYPE=SHT_STRTAB %s | obj2yaml | FileCheck %s -DTYPE=STRTAB --check-prefixes=ARANGE,SHDR
75 # RUN: yaml2obj --docnum=2 -DFLAGS=[SHF_ALLOC] %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,FLAGS
76 # RUN: yaml2obj --docnum=2 -DLINK='.sec' %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,LINK
77 # RUN: yaml2obj --docnum=2 -DENTSIZE=3 %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,ENTSIZE
78 # RUN: yaml2obj --docnum=2 -DINFO=3 %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,INFO
79 # RUN: yaml2obj --docnum=2 -DADDRALIGN=3 %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,ADDRALIGN
80 # RUN: yaml2obj --docnum=2 -DADDRESS=0x2020 %s | obj2yaml | FileCheck %s -DTYPE=PROGBITS --check-prefixes=ARANGE,SHDR,ADDRESS
82 # SHDR: - Name: .debug_aranges
83 # SHDR-NEXT: Type: SHT_[[TYPE]]
84 # FLAGS-NEXT: Flags: [ SHF_ALLOC ]
85 # LINK-NEXT: Link: .sec
86 # ENTSIZE-NEXT: EntSize: 0x3
87 # INFO-NEXT: Info: 0x3
88 # ADDRALIGN-NEXT: AddressAlign: 0x3
89 # ADDRESS-NEXT: Address: 0x2020
92 # ARANGE-NEXT: debug_aranges:
93 # ARANGE-NEXT: - Length: 0x1C
94 # ARANGE-NEXT: Version: 2
95 # ARANGE-NEXT: CuOffset: 0x1234
96 # ARANGE-NEXT: AddressSize: 0x8
105 - Name: .debug_aranges
106 Type: [[TYPE=SHT_PROGBITS]]
107 Flags: [[FLAGS=<none>]]
108 Link: [[LINK=<none>]]
109 EntSize: [[ENTSIZE=<none>]]
110 Info: [[INFO=<none>]]
111 AddressAlign: [[ADDRALIGN=0]]
112 Address: [[ADDRESS=<none>]]
120 ## c) Test dumping a .debug_aranges section whose address_size doesn't match the
121 ## object file's address size.
123 # RUN: yaml2obj --docnum=3 %s | obj2yaml | \
124 # RUN: FileCheck %s -DLENGTH=0x1C -DADDRSIZE=0x4 -DADDRLEN=0x12345678 --check-prefix=ADDRSIZE
127 # ADDRSIZE-NEXT: debug_aranges:
128 # ADDRSIZE-NEXT: - Length: [[LENGTH]]
129 # ADDRSIZE-NEXT: Version: 2
130 # ADDRSIZE-NEXT: CuOffset: 0x1234
131 # ADDRSIZE-NEXT: AddressSize: [[ADDRSIZE]]
132 # ADDRSIZE-NEXT: Descriptors:
133 # ADDRSIZE-NEXT: - Address: [[ADDRLEN]]
134 # ADDRSIZE-NEXT: Length: [[ADDRLEN]]
139 Class: ELFCLASS[[BITS=64]]
146 AddressSize: [[ADDRSIZE=0x4]]
148 - Address: [[ADDRLEN=0x12345678]]
149 Length: [[ADDRLEN=0x12345678]]
151 # RUN: yaml2obj --docnum=3 -DBITS=32 -DADDRSIZE=0x8 -DADDRLEN=0x1234567890abcdef %s | \
153 # RUN: FileCheck %s -DLENGTH=0x2C -DADDRSIZE=0x8 -DADDRLEN=0x1234567890ABCDEF --check-prefix=ADDRSIZE
155 ## d) Test dumping a .debug_aranges section whose length field doesn't match the actual length.
156 ## This makes the DWARF parser fail to parse it and we will dump it as a raw content section.
158 # RUN: yaml2obj --docnum=4 %s | obj2yaml | FileCheck %s --check-prefix=RAW-CONTENT
160 # RAW-CONTENT: Sections:
161 # RAW-CONTENT-NEXT: - Name: .debug_aranges
162 # RAW-CONTENT-NEXT: Type: SHT_PROGBITS
163 # RAW-CONTENT-NEXT: AddressAlign: 0x1
164 # RAW-CONTENT-NEXT: Content: '3412000002003412000008000000000000000000000000000000000000000000'
165 # RAW-CONTENT-NEXT: ...
178 ## e) Test dumping an empty .debug_aranges section.
180 # RUN: yaml2obj --docnum=5 %s | obj2yaml | FileCheck %s --check-prefix=EMPTY-CONTENT
182 # EMPTY-CONTENT: DWARF:
183 # EMPTY-CONTENT-NEXT: debug_aranges: []
184 # EMPTY-CONTENT-NEXT: ...
194 ## f) Show that dumping a table with a premature terminator entry still uses the
197 # RUN: yaml2obj --docnum=1 %s -DADDR=0 -DLENGTH=0 -DBITS=64 -DENDIAN=LSB | obj2yaml | \
198 # RUN: FileCheck %s --check-prefix=BASIC --implicit-check-not=Sections \
199 # RUN: -DLENGTH1=3C -DLENGTH2=44 -DADDRSIZE=0x8 -DVARADDR=0x0 -DVARLEN=0x0