1 ## Test that yaml2obj emits .debug_abbrev section.
3 ## a) Generate the .debug_abbrev section from the "DWARF" entry.
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
10 # SHDR-NEXT: Name: .debug_abbrev (1)
11 # SHDR-NEXT: Type: SHT_PROGBITS (0x1)
12 # SHDR-NEXT: Flags [ (0x0)
14 # SHDR-NEXT: Address: 0x0
15 # SHDR-NEXT: Offset: 0x40
16 # SHDR-NEXT: Size: [[SIZE]]
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
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
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)
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
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
73 Tag: DW_TAG_compile_unit
74 Children: DW_CHILDREN_yes
76 - Attribute: DW_AT_producer
78 - Attribute: DW_AT_language
80 - Attribute: DW_AT_name
83 Tag: DW_TAG_subprogram
84 Children: DW_CHILDREN_yes
86 - Attribute: DW_AT_low_pc
88 - Attribute: DW_AT_high_pc
91 ## Test a reserved tag value.
93 Children: DW_CHILDREN_no
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.
99 ## Test a reserved attribute value.
101 ## Test a reserved form value.
104 ## Test one special attribute form DW_FORM_implicit_const,
105 ## who is followed by a SLEB128 value.
106 Form: DW_FORM_implicit_const
110 Tag: DW_TAG_compile_unit
111 Children: DW_CHILDREN_yes
113 - Attribute: DW_AT_producer
116 Tag: DW_TAG_subprogram
117 Children: DW_CHILDREN_yes
119 - Attribute: DW_AT_low_pc
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
126 ## b) Generate the .debug_abbrev section from raw section content.
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
132 # ARBITRARY-CONTENT-NEXT: SectionData (
133 # ARBITRARY-CONTENT-NEXT: 0000: 112233
134 # ARBITRARY-CONTENT-NEXT: )
142 - Name: .debug_abbrev
146 ## c) Generate the .debug_abbrev section when the "Size" is specified.
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
152 # SIZE-NEXT: SectionData (
153 # SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|
162 - Name: .debug_abbrev
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.
169 # RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR
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
179 - Name: .debug_abbrev
186 Tag: DW_TAG_compile_unit
187 Children: DW_CHILDREN_no
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.
192 # RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR
200 - Name: .debug_abbrev
207 Tag: DW_TAG_compile_unit
208 Children: DW_CHILDREN_no
210 ## f) Test that all the properties can be overridden by the section header when
211 ## the "debug_abbrev" entry doesn't exist.
213 # RUN: yaml2obj --docnum=6 %s -o %t6.o
214 # RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN
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
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.
239 ## g) Test that all the properties can be overridden by the section header when
240 ## the "debug_abbrev" entry exists.
242 # RUN: yaml2obj --docnum=7 %s -o %t7.o
243 # RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN
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.
266 Tag: DW_TAG_compile_unit
267 Children: DW_CHILDREN_no
269 ## h) Test that yaml2obj automatically generates abbreviation codes for us.
271 # RUN: yaml2obj --docnum=8 %s -o %t8.o
272 # RUN: llvm-readelf --hex-dump=.debug_abbrev %t8.o | FileCheck %s --check-prefix=CODE
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
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
295 - Tag: DW_TAG_compile_unit
296 Children: DW_CHILDREN_no
297 - Tag: DW_TAG_subprogram
298 Children: DW_CHILDREN_no
300 Tag: DW_TAG_subprogram
301 Children: DW_CHILDREN_no
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
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
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.
319 ## RUN: not yaml2obj --docnum=9 %s 2>&1 | FileCheck %s --check-prefix=ID-COLLISION
321 # ID-COLLISION: yaml2obj: error: the ID (1) of abbrev table with index 1 has been used by abbrev table with index 0