Debian Codegraph @

llvm/test/tools/yaml2obj/ELF/DWARF/debug-gnu-pubnames.yaml

raw
1 ## Test that yaml2obj emits .debug_gnu_pubnames section.
2
3 ## a) Generate the '.debug_gnu_pubnames' section from the 'DWARF' entry.
4
5 ## Generate and verify a 32-bit little endian .debug_gnu_pubnames section.
6
7 # RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2LSB %s -o %t1.le.o
8 # RUN: llvm-readobj --sections --section-data %t1.le.o | \
9 # RUN: FileCheck -DSIZE=32 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-LE
10
11 # SHDR: Index: 1
12 # SHDR-NEXT: Name: .debug_gnu_pubnames (1)
13 # SHDR-NEXT: Type: SHT_PROGBITS (0x1)
14 # SHDR-NEXT: Flags [ (0x0)
15 # SHDR-NEXT: ]
16 # SHDR-NEXT: Address: 0x0
17 # SHDR-NEXT: Offset: 0x40
18 # SHDR-NEXT: Size: [[SIZE]]
19 # SHDR-NEXT: Link: 0
20 # SHDR-NEXT: Info: 0
21 # SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]
22 # SHDR-NEXT: EntrySize: 0
23 # DWARF32-LE-NEXT: SectionData (
24 # DWARF32-LE-NEXT: 0000: 34120000 02003412 00002143 00007856 |4.....4...!C..xV|
25 ## ^------- unit_length (4-byte)
26 ## ^--- version (2-byte)
27 ## ^-------- debug_info_offset (4-byte)
28 ## ^-------- debug_info_length (4-byte)
29 ## ^--- offset (4-byte)
30 # DWARF32-LE-NEXT: 0010: 34123061 62630021 43658730 64656600 |4.0abc.!Ce.0def.|
31 ## ----
32 ## ^- descriptor (1-byte)
33 ## ^-------- name "abc\0"
34 ## ^-------- offset (4-byte)
35 ## ^- descriptor (1-byte)
36 ## ^------- name "def\0"
37 # DWARF32-LE-NEXT: )
38
39 --- !ELF
40 FileHeader:
41 Class: ELFCLASS64
42 Data: [[ENDIAN]]
43 Type: ET_EXEC
44 DWARF:
45 debug_gnu_pubnames:
46 Length: 0x1234
47 Version: 2
48 UnitOffset: 0x1234
49 UnitSize: 0x4321
50 Entries:
51 - DieOffset: 0x12345678
52 Descriptor: 0x30
53 Name: abc
54 - DieOffset: 0x87654321
55 Descriptor: 0x30
56 Name: def
57
58 ## Generate and verify a 32-bit big endian .debug_gnu_pubnames section.
59
60 # RUN: yaml2obj --docnum=1 -DENDIAN=ELFDATA2MSB %s -o %t1.be.o
61 # RUN: llvm-readobj --sections --section-data %t1.be.o | \
62 # RUN: FileCheck -DSIZE=32 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF32-BE
63
64 # DWARF32-BE-NEXT: SectionData (
65 # DWARF32-BE-NEXT: 0000: 00001234 00020000 12340000 43211234 |...4.....4..C!.4|
66 ## ^------- unit_length (4-byte)
67 ## ^--- version (2-byte)
68 ## ^-------- debug_info_offset (4-byte)
69 ## ^-------- debug_info_length (4-byte)
70 ## ^--- offset (4-byte)
71 # DWARF32-BE-NEXT: 0010: 56783061 62630087 65432130 64656600 |Vx0abc..eC!0def.|
72 ## ----
73 ## ^- descriptor (1-byte)
74 ## ^-------- name "abc\0"
75 ## ^-------- offset (4-byte)
76 ## ^- descriptor (1-byte)
77 ## ^------- name "def\0"
78 # DWARF32-BE-NEXT: )
79
80 ## b) Generate the .debug_gnu_pubnames section from raw section content.
81
82 # RUN: yaml2obj --docnum=2 %s -o %t2.o
83 # RUN: llvm-readobj --sections --section-data %t2.o | \
84 # RUN: FileCheck %s -DADDRALIGN=0 -DSIZE=3 --check-prefixes=SHDR,ARBITRARY-CONTENT
85
86 # ARBITRARY-CONTENT: SectionData (
87 # ARBITRARY-CONTENT-NEXT: 0000: 112233
88 # ARBITRARY-CONTENT-NEXT: )
89
90 --- !ELF
91 FileHeader:
92 Class: ELFCLASS64
93 Data: ELFDATA2LSB
94 Type: ET_EXEC
95 Sections:
96 - Name: .debug_gnu_pubnames
97 Type: SHT_PROGBITS
98 Content: "112233"
99
100 ## c) Generate the .debug_gnu_pubnames section when the "Size" is specified.
101
102 # RUN: yaml2obj --docnum=3 %s -o %t3.o
103 # RUN: llvm-readobj --sections --section-data %t3.o | \
104 # RUN: FileCheck -DSIZE=16 -DADDRALIGN=0 %s --check-prefixes=SHDR,SIZE
105
106 # SIZE: SectionData (
107 # SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|
108 # SIZE-NEXT: )
109
110 --- !ELF
111 FileHeader:
112 Class: ELFCLASS64
113 Data: ELFDATA2LSB
114 Type: ET_EXEC
115 Sections:
116 - Name: .debug_gnu_pubnames
117 Type: SHT_PROGBITS
118 Size: 0x10
119
120 ## d) Test that yaml2obj emits an error message when both the "Size" and the
121 ## "debug_gnu_pubnames" entry are specified at the same time.
122
123 # RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=ERROR
124
125 # ERROR: yaml2obj: error: cannot specify section '.debug_gnu_pubnames' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time
126
127 --- !ELF
128 FileHeader:
129 Class: ELFCLASS64
130 Data: ELFDATA2LSB
131 Type: ET_EXEC
132 Sections:
133 - Name: .debug_gnu_pubnames
134 Type: SHT_PROGBITS
135 Size: 0x10
136 DWARF:
137 debug_gnu_pubnames:
138 Length: 0x1234
139 Version: 2
140 UnitOffset: 0x1234
141 UnitSize: 0x4321
142 Entries: []
143
144 ## e) Test that yaml2obj emits an error message when both the "Content" and the
145 ## "debug_gnu_pubnames" entry are specified at the same time.
146
147 # RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=ERROR
148
149 --- !ELF
150 FileHeader:
151 Class: ELFCLASS64
152 Data: ELFDATA2LSB
153 Type: ET_EXEC
154 Sections:
155 - Name: .debug_gnu_pubnames
156 Type: SHT_PROGBITS
157 Content: "00"
158 DWARF:
159 debug_gnu_pubnames:
160 Length: 0x1234
161 Version: 2
162 UnitOffset: 0x1234
163 UnitSize: 0x4321
164 Entries: []
165
166 ## f) Test that all the properties can be overridden by the section header when
167 ## the "debug_gnu_pubnames" entry doesn't exist.
168
169 # RUN: yaml2obj --docnum=6 %s -o %t6.o
170 # RUN: llvm-readelf --sections %t6.o | FileCheck %s --check-prefix=OVERRIDDEN
171
172 # OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
173 # OVERRIDDEN: [ 1] .debug_gnu_pubnames STRTAB 0000000000002020 000050 00000e 01 A 2 1 2
174 # OVERRIDDEN-NEXT: [ 2] .sec STRTAB 0000000000000000 00005e 000000 00 0 0 0
175
176 --- !ELF
177 FileHeader:
178 Class: ELFCLASS64
179 Data: ELFDATA2LSB
180 Type: ET_EXEC
181 Sections:
182 - Name: .debug_gnu_pubnames
183 Type: SHT_STRTAB ## SHT_PROGBITS by default.
184 Flags: [SHF_ALLOC] ## 0 by default.
185 Link: .sec ## 0 by default.
186 EntSize: 1 ## 0 by default.
187 Info: 1 ## 0 by default.
188 AddressAlign: 2 ## 0 by default.
189 Address: 0x2020 ## 0x00 by default.
190 Offset: 0x50 ## 0x40 for the first section.
191 Size: 0x0e ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".
192 - Name: .sec ## Linked by .debug_gnu_pubnames.
193 Type: SHT_STRTAB
194
195 ## g) Test that all the properties can be overridden by the section header when
196 ## the "debug_gnu_pubnames" entry exists.
197
198 # RUN: yaml2obj --docnum=7 %s -o %t7.o
199 # RUN: llvm-readelf --sections %t7.o | FileCheck %s --check-prefix=OVERRIDDEN
200
201 --- !ELF
202 FileHeader:
203 Class: ELFCLASS64
204 Data: ELFDATA2LSB
205 Type: ET_EXEC
206 Sections:
207 - Name: .debug_gnu_pubnames
208 Type: SHT_STRTAB ## SHT_PROGBITS by default.
209 Flags: [SHF_ALLOC] ## 0 by default.
210 Link: .sec ## 0 by default.
211 EntSize: 1 ## 0 by default.
212 Info: 1 ## 0 by default.
213 AddressAlign: 2 ## 1 by default.
214 Address: 0x2020 ## 0x00 by default.
215 Offset: 0x50 ## 0x40 for the first section.
216 - Name: .sec ## Linked by .debug_gnu_pubnames.
217 Type: SHT_STRTAB
218 DWARF:
219 debug_gnu_pubnames:
220 Length: 0x1234
221 Version: 2
222 UnitOffset: 0x1234
223 UnitSize: 0x4321
224 Entries: []
225
226 ## h) Test that yaml2obj emits an error if 'Descriptor' is missing.
227
228 # RUN: not yaml2obj --docnum=8 %s -o %t8.o 2>&1 | FileCheck -DMSG=%errc_EINVAL %s --check-prefix=MISSING-KEY
229
230 # MISSING-KEY: YAML:{{.*}}:9: error: missing required key 'Descriptor'
231 # MISSING-KEY-NEXT: - DieOffset: 0x12345678
232 # MISSING-KEY-NEXT: ^
233 # MISSING-KEY-NEXT: yaml2obj: error: failed to parse YAML input: [[MSG]]
234
235 --- !ELF
236 FileHeader:
237 Class: ELFCLASS64
238 Data: ELFDATA2LSB
239 Type: ET_EXEC
240 DWARF:
241 debug_gnu_pubnames:
242 Length: 0x1234
243 Version: 2
244 UnitOffset: 0x1234
245 UnitSize: 0x4321
246 Entries:
247 - DieOffset: 0x12345678
248 Name: abc