Follow up to d0858bffa11, add missing REQUIRES x86
[llvm-project.git] / llvm / test / tools / obj2yaml / ELF / DWARF / debug-aranges.yaml
blob63a0e8bb9b903c3f6a4c641c46f2ffd8eee5c652
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
26 #      BASIC: DWARF:
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
47 # BASIC-NEXT: ...
49 --- !ELF
50 FileHeader:
51   Class: ELFCLASS[[BITS]]
52   Data:  ELFDATA2[[ENDIAN]]
53   Type:  ET_EXEC
54 DWARF:
55   debug_aranges:
56     - Version:  2
57       CuOffset: 0x1234
58       Descriptors:
59         - Address: 0x1234
60           Length:  0x5678
61         - Address: 0x1234
62           Length:  0x5678
63     - Format:   DWARF64
64       Version:  2
65       CuOffset: 0x1234567890abcdef
66       Descriptors:
67         - Address: [[ADDR=0x1234]]
68           Length:  [[LENGTH=0x5678]]
69         - Address: 0x1234
70           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
91 #      ARANGE: DWARF:
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
97 # ARANGE-NEXT: ...
99 --- !ELF
100 FileHeader:
101   Class: ELFCLASS64
102   Data:  ELFDATA2LSB
103   Type:  ET_EXEC
104 Sections:
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>]]
113   - Name:         .sec
114     Type:         SHT_PROGBITS
115 DWARF:
116   debug_aranges:
117     - Version:  2
118       CuOffset: 0x1234
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
126 #      ADDRSIZE: DWARF:
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]]
135 # ADDRSIZE-NEXT: ...
137 --- !ELF
138 FileHeader:
139   Class: ELFCLASS[[BITS=64]]
140   Data:  ELFDATA2LSB
141   Type:  ET_EXEC
142 DWARF:
143   debug_aranges:
144     - Version:     2
145       CuOffset:    0x1234
146       AddressSize: [[ADDRSIZE=0x4]]
147       Descriptors:
148         - Address: [[ADDRLEN=0x12345678]]
149           Length:  [[ADDRLEN=0x12345678]]
151 # RUN: yaml2obj --docnum=3 -DBITS=32 -DADDRSIZE=0x8 -DADDRLEN=0x1234567890abcdef %s | \
152 # RUN:   obj2yaml | \
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: ...
167 --- !ELF
168 FileHeader:
169   Class: ELFCLASS64
170   Data:  ELFDATA2LSB
171   Type:  ET_EXEC
172 DWARF:
173   debug_aranges:
174     - Length:   0x1234
175       Version:  2
176       CuOffset: 0x1234
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: ...
186 --- !ELF
187 FileHeader:
188   Class: ELFCLASS64
189   Data:  ELFDATA2LSB
190   Type:  ET_EXEC
191 DWARF:
192   debug_aranges: []
194 ## f) Show that dumping a table with a premature terminator entry still uses the
195 ## DWARF tag.
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