Debian Codegraph @

llvm/test/tools/yaml2obj/ELF/DWARF/debug-abbrev.yaml

raw
1 ## Test that yaml2obj emits .debug_abbrev section.
2
3 ## a) Generate the .debug_abbrev section from the "DWARF" entry.
4
5 # RUN: yaml2obj --docnum=1 %s -o %t1.o
6 # RUN: llvm-readobj --sections --section-data %t1.o | \
7 # RUN: FileCheck -DSIZE=59 -DADDRALIGN=1 %s --check-prefixes=SHDR,CONTENT
8
9 # SHDR: Index: 1
10 # SHDR-NEXT: Name: .debug_abbrev (1)
11 # SHDR-NEXT: Type: SHT_PROGBITS (0x1)
12 # SHDR-NEXT: Flags [ (0x0)
13 # SHDR-NEXT: ]
14 # SHDR-NEXT: Address: 0x0
15 # SHDR-NEXT: Offset: 0x40
16 # SHDR-NEXT: Size: [[SIZE]]
17 # SHDR-NEXT: Link: 0
18 # SHDR-NEXT: Info: 0
19 # SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]
20 # SHDR-NEXT: EntrySize: 0
21 # CONTENT-NEXT: SectionData (
22 # CONTENT-NEXT: 000: 01110125 0E130503
23 ## ^- abbreviation code ULEB128 ^- DW_FORM_strp ULEB128
24 ## ^- DW_TAG_compile_unit ULEB128 ^- DW_AT_language ULEB128
25 ## ^- DW_CHILDREN_yes 1-byte ^- DW_FORM_data2 ULEB128
26 ## ^- DW_AT_producer ULEB128 ^- DW_AT_name ULEB128
27 ##
28 ## CONTENT: 1A000002 2E011101 |...%............|
29 ## ^- DW_AT_strx ULEB128 ^- DW_TAG_subprogram ULEB128
30 ## ^--- attr terminator ^- DW_CHILDREN_yes 1-byte
31 ## ^- abbreviation code ULEB128 ^- DW_AT_low_pc ULEB128
32 ## ^- DW_FORM_addr ULEB128
33 ##
34 # CONTENT-NEXT: 0010: 121B0000 03060081
35 ## ^- DW_AT_high_pc ULEB128 ^- abbreviation code ULEB128
36 ## ^- DW_FORM_addrx ULEB128 ^- Tag: value UELB128
37 ## ^--- attr terminator ^- DW_CHILDREN_no 1-byte
38 ## ^- DW_AT_call_pc ULEB128 (0x81)
39 ##
40 # CONTENT: 01810104 02A04021 |..............@!|
41 ## -- ^- Form: reserved ULEB128
42 ## ^--- Form: invalid ULEB128 (0x81) ^--- Attribute: reserved ULEB128 (0x2020)
43 ## ^- Attribute: reserved ULEB128 ^- DW_FORM_implicit_const ULEB128
44 ##
45 # CONTENT-NEXT: 0020: CEC2F105 00000001
46 ## ^------- Value SLEB128 (12345678) ^--- attr terminator
47 ## ^- abbrev terminator
48 ## ^- abbreviation code ULEB128
49 # CONTENT: 1101250E 0000022E |..........%.....|
50 ## ^- DW_TAG_compile_unit ULEB128 ^--- attr terminator
51 ## ^- DW_CHILDREN_yes 1-byte ^- abbreviation code ULEB128
52 ## ^- DW_AT_producer ULEB128 ^- DW_TAG_subprogram ULEB128
53 ## ^- DW_FORM_strp ULEB128
54 # CONTENT-NEXT: 0030: 01110100 00031100 000000 |...........|
55 ## ^- DW_CHILDREN_yes 1-byte ^--- attr terminator
56 ## ^- DW_AT_low_pc ULEB128 ^- abbrev table terminator
57 ## ^- DW_FORM_addr UELB128
58 ## ^---- attr terminator
59 ## ^- abbrev code ULEB128 (0x03)
60 ## ^- DW_TAG_compile_unit
61 ## ^- DW_CHILDREN_no
62 # CONTENT-NEXT: )
63
64 --- !ELF
65 FileHeader:
66 Class: ELFCLASS64
67 Data: ELFDATA2LSB
68 Type: ET_EXEC
69 DWARF:
70 debug_abbrev:
71 - Table:
72 - Code: 1
73 Tag: DW_TAG_compile_unit
74 Children: DW_CHILDREN_yes
75 Attributes:
76 - Attribute: DW_AT_producer
77 Form: DW_FORM_strp
78 - Attribute: DW_AT_language
79 Form: DW_FORM_data2
80 - Attribute: DW_AT_name
81 Form: DW_FORM_strx
82 - Code: 2
83 Tag: DW_TAG_subprogram
84 Children: DW_CHILDREN_yes
85 Attributes:
86 - Attribute: DW_AT_low_pc
87 Form: DW_FORM_addr
88 - Attribute: DW_AT_high_pc
89 Form: DW_FORM_addrx
90 - Code: 3
91 ## Test a reserved tag value.
92 Tag: 0x06
93 Children: DW_CHILDREN_no
94 Attributes:
95 ## Test an attribute value that is more than one byte.
96 - Attribute: DW_AT_call_pc
97 ## Test a form value that is more than one byte.
98 Form: 0x81
99 ## Test a reserved attribute value.
100 - Attribute: 0x04
101 ## Test a reserved form value.
102 Form: 0x02
103 - Attribute: 0x2020
104 ## Test one special attribute form DW_FORM_implicit_const,
105 ## who is followed by a SLEB128 value.
106 Form: DW_FORM_implicit_const
107 Value: 12345678
108 - Table:
109 - Code: 1
110 Tag: DW_TAG_compile_unit
111 Children: DW_CHILDREN_yes
112 Attributes:
113 - Attribute: DW_AT_producer
114 Form: DW_FORM_strp
115 - Code: 2
116 Tag: DW_TAG_subprogram
117 Children: DW_CHILDREN_yes
118 Attributes:
119 - Attribute: DW_AT_low_pc
120 Form: DW_FORM_addr
121 ## Test that if the 'Attributes' field is not specified, yaml2obj emits
122 ## a terminating entry, 0 for the attribute, 0 for the form.
123 - Tag: DW_TAG_compile_unit
124 Children: DW_CHILDREN_no
125
126 ## b) Generate the .debug_abbrev section from raw section content.
127
128 # RUN: yaml2obj --docnum=2 %s -o %t2.o
129 # RUN: llvm-readobj --sections --section-data %t2.o | \
130 # RUN: FileCheck -DADDRALIGN=0 -DSIZE=3 %s --check-prefixes=SHDR,ARBITRARY-CONTENT
131
132 # ARBITRARY-CONTENT-NEXT: SectionData (
133 # ARBITRARY-CONTENT-NEXT: 0000: 112233
134 # ARBITRARY-CONTENT-NEXT: )
135
136 --- !ELF
137 FileHeader:
138 Class: ELFCLASS64
139 Data: ELFDATA2LSB
140 Type: ET_EXEC
141 Sections:
142 - Name: .debug_abbrev
143 Type: SHT_PROGBITS
144 Content: "112233"
145
146 ## c) Generate the .debug_abbrev section when the "Size" is specified.
147
148 # RUN: yaml2obj --docnum=3 %s -o %t3.o
149 # RUN: llvm-readobj --sections --section-data %t3.o | \
150 # RUN: FileCheck -DSIZE=16 -DADDRALIGN=0 %s --check-prefixes=SHDR,SIZE
151
152 # SIZE-NEXT: SectionData (
153 # SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|
154 # SIZE-NEXT: )
155
156 --- !ELF
157 FileHeader:
158 Class: ELFCLASS64
159 Data: ELFDATA2LSB
160 Type: ET_EXEC
161 Sections:
162 - Name: .debug_abbrev
163 Type: SHT_PROGBITS
164 Size: 0x10
165
166 ## d) Test that yaml2obj emits an error message when both the "Size" and the
167 ## "debug_abbrev" entry are specified at the same time.
168
169 # RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR
170
171 # ERROR: yaml2obj: error: cannot specify section '.debug_abbrev' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time
172
173 --- !ELF
174 FileHeader:
175 Class: ELFCLASS64
176 Data: ELFDATA2LSB
177 Type: ET_EXEC
178 Sections:
179 - Name: .debug_abbrev
180 Type: SHT_PROGBITS
181 Size: 0x10
182 DWARF:
183 debug_abbrev:
184 - Table:
185 - Code: 1
186 Tag: DW_TAG_compile_unit
187 Children: DW_CHILDREN_no
188
189 ## e) Test that yaml2obj emits an error message when both the "Content" and the
190 ## "debug_abbrev" entry are specified at the same time.
191
192 # RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR
193
194 --- !ELF
195 FileHeader:
196 Class: ELFCLASS64
197 Data: ELFDATA2LSB
198 Type: ET_EXEC
199 Sections:
200 - Name: .debug_abbrev
201 Type: SHT_PROGBITS
202 Content: "00"
203 DWARF:
204 debug_abbrev:
205 - Table:
206 - Code: 1
207 Tag: DW_TAG_compile_unit
208 Children: DW_CHILDREN_no
209
210 ## f) Test that all the properties can be overridden by the section header when
211 ## the "debug_abbrev" entry doesn't exist.
212
213 # RUN: yaml2obj --docnum=6 %s -o %t6.o
214 # RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN
215
216 # OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
217 # OVERRIDDEN: [ 1] .debug_abbrev STRTAB 0000000000002020 000050 000006 01 A 2 1 2
218 # OVERRIDDEN-NEXT: [ 2] .sec STRTAB 0000000000000000 000056 000000 00 0 0 0
219
220 --- !ELF
221 FileHeader:
222 Class: ELFCLASS64
223 Data: ELFDATA2LSB
224 Type: ET_EXEC
225 Sections:
226 - Name: .debug_abbrev
227 Type: SHT_STRTAB ## SHT_PROGBITS by default.
228 Flags: [SHF_ALLOC] ## 0 by default.
229 Link: .sec ## 0 by default.
230 EntSize: 1 ## 0 by default.
231 Info: 1 ## 0 by default.
232 AddressAlign: 2 ## 0 by default.
233 Address: 0x2020 ## 0x00 by default.
234 Offset: 0x50 ## 0x40 for the first section.
235 Size: 0x06 ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".
236 - Name: .sec ## Linked by .debug_abbrev.
237 Type: SHT_STRTAB
238
239 ## g) Test that all the properties can be overridden by the section header when
240 ## the "debug_abbrev" entry exists.
241
242 # RUN: yaml2obj --docnum=7 %s -o %t7.o
243 # RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN
244
245 --- !ELF
246 FileHeader:
247 Class: ELFCLASS64
248 Data: ELFDATA2LSB
249 Type: ET_EXEC
250 Sections:
251 - Name: .debug_abbrev
252 Type: SHT_STRTAB ## SHT_PROGBITS by default.
253 Flags: [SHF_ALLOC] ## 0 by default.
254 Link: .sec ## 0 by default.
255 EntSize: 1 ## 0 by default.
256 Info: 1 ## 0 by default.
257 AddressAlign: 2 ## 1 by default.
258 Address: 0x2020 ## 0x00 by default.
259 Offset: 0x50 ## 0x40 for the first section.
260 - Name: .sec ## Linked by .debug_abbrev.
261 Type: SHT_STRTAB
262 DWARF:
263 debug_abbrev:
264 - Table:
265 - Code: 1
266 Tag: DW_TAG_compile_unit
267 Children: DW_CHILDREN_no
268
269 ## h) Test that yaml2obj automatically generates abbreviation codes for us.
270
271 # RUN: yaml2obj --docnum=8 %s -o %t8.o
272 # RUN: llvm-readelf --hex-dump=.debug_abbrev %t8.o | FileCheck %s --check-prefix=CODE
273
274 # CODE: 0x00000000 01110000 00022e00 0000042e 00000004
275 ## ^- abbreviation code ULEB128
276 ## ^- abbreviation code ULEB128
277 ## ^- abbreviation code (ULEB128) 0x04
278 ## ^- abbreviation code (ULEB128) 0x04
279 ##
280 # CODE-NEXT: 0x00000010 2e000000 052e0000 00062e00 00000001
281 ## ^- abbreviation code ULEB128
282 ## ^- abbreviation code ULEB128
283 ## ^- abbreviation code ULEB128
284 # CODE-NEXT: 0x00000020 11000000 022e0000 0000
285 ## ^- abbreviation code ULEB128
286
287 --- !ELF
288 FileHeader:
289 Class: ELFCLASS64
290 Data: ELFDATA2LSB
291 Type: ET_EXEC
292 DWARF:
293 debug_abbrev:
294 - Table:
295 - Tag: DW_TAG_compile_unit
296 Children: DW_CHILDREN_no
297 - Tag: DW_TAG_subprogram
298 Children: DW_CHILDREN_no
299 - Code: 4
300 Tag: DW_TAG_subprogram
301 Children: DW_CHILDREN_no
302 - Code: 4
303 Tag: DW_TAG_subprogram
304 Children: DW_CHILDREN_no
305 - Tag: DW_TAG_subprogram
306 Children: DW_CHILDREN_no
307 - Tag: DW_TAG_subprogram
308 Children: DW_CHILDREN_no
309 - Table:
310 ## Test that the abbrev codes in a new table start from 1 by default.
311 - Tag: DW_TAG_compile_unit
312 Children: DW_CHILDREN_no
313 - Tag: DW_TAG_subprogram
314 Children: DW_CHILDREN_no
315
316 ## i) Test that yaml2obj emits an error message when there are non-empty compilation units
317 ## and multiple abbrev tables are assigned the same ID.
318
319 ## RUN: not yaml2obj --docnum=9 %s 2>&1 | FileCheck %s --check-prefix=ID-COLLISION
320
321 # ID-COLLISION: yaml2obj: error: the ID (1) of abbrev table with index 1 has been used by abbrev table with index 0
322
323 --- !ELF
324 FileHeader:
325 Class: ELFCLASS64
326 Data: ELFDATA2LSB
327 Type: ET_EXEC
328 Machine: EM_X86_64
329 DWARF:
330 debug_abbrev:
331 - ID: 1
332 - ID: 1
333 debug_info:
334 - Version: 4
335 AbbrOffset: 0x00
336 Entries:
337 - AbbrCode: 1
338 Values:
339 - Value: 0x1234