debug-str-offsets.yaml
9.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
## Test that yaml2obj emits a .debug_str_offsets section when requested.
## a) Generate and verify a little endian .debug_str_offsets section.
# RUN: yaml2obj -DENDIAN=ELFDATA2LSB --docnum=1 %s -o %t1.le.o
# RUN: llvm-readobj --sections --section-data %t1.le.o | \
# RUN: FileCheck -DSIZE=48 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF-LE
# SHDR: Index: 1
# SHDR-NEXT: Name: .debug_str_offsets (1)
# SHDR-NEXT: Type: SHT_PROGBITS (0x1)
# SHDR-NEXT: Flags [ (0x0)
# SHDR-NEXT: ]
# SHDR-NEXT: Address: 0x0
# SHDR-NEXT: Offset: 0x40
# SHDR-NEXT: Size: [[SIZE]]
# SHDR-NEXT: Link: 0
# SHDR-NEXT: Info: 0
# SHDR-NEXT: AddressAlignment: [[ADDRALIGN]]
# SHDR-NEXT: EntrySize: 0
# DWARF-LE-NEXT: SectionData (
# DWARF-LE-NEXT: 0000: 0C000000 05000000 78563412 21436587 |........xV4.!Ce.|
## ^------- unit_length (4-byte)
## ^--- version (2-byte)
## ^--- padding (2-byte)
## ^------- offsets[0] (4-byte)
## ^------- offsets[1] (4-byte)
# DWARF-LE-NEXT: 0010: FFFFFFFF 14000000 00000000 05000000 |................|
## ^------------------------- unit_length (12-byte)
## ^--- version (2-byte)
## ^--- padding (2-byte)
# DWARF-LE-NEXT: 0020: F0DEBC9A 78563412 89674523 01EFCDAB |....xV4..gE#....|
## ^---------------- offsets[0] (8-byte)
## ^---------------- offsets[1] (8-byte)
# DWARF-LE-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: [[ENDIAN]]
Type: ET_EXEC
DWARF:
debug_str_offsets:
- Offsets:
- 0x12345678
- 0x87654321
- Format: DWARF64
Offsets:
- 0x123456789abcdef0
- 0xabcdef0123456789
## b) Generate and verify a big endian .debug_str_offsets section.
# RUN: yaml2obj -DENDIAN=ELFDATA2MSB --docnum=1 %s -o %t1.be.o
# RUN: llvm-readobj --sections --section-data %t1.be.o | \
# RUN: FileCheck -DSIZE=48 -DADDRALIGN=1 %s --check-prefixes=SHDR,DWARF-BE
# DWARF-BE-NEXT: SectionData (
# DWARF-BE-NEXT: 0000: 0000000C 00050000 12345678 87654321 |.........4Vx.eC!|
## ^------- unit_length (4-byte)
## ^--- version (2-byte)
## ^--- padding (2-byte)
## ^------- offsets[0] (4-byte)
## ^------- offsets[1] (4-byte)
# DWARF-BE-NEXT: 0010: FFFFFFFF 00000000 00000014 00050000 |................|
## ^------------------------- unit_length (12-byte)
## ^--- version (2-byte)
## ^--- padding (2-byte)
# DWARF-BE-NEXT: 0020: 12345678 9ABCDEF0 ABCDEF01 23456789 |.4Vx........#Eg.|
## ^---------------- offsets[0] (8-byte)
## ^---------------- offsets[1] (8-byte)
# DWARF-BE-NEXT: )
## c) Test that the length, version and padding fields can be overwritten.
# RUN: yaml2obj --docnum=2 %s -o %t2.o
# RUN: llvm-readelf --hex-dump=.debug_str_offsets %t2.o | \
# RUN: FileCheck %s --check-prefix=OVERWRITE
# OVERWRITE: Hex dump of section '.debug_str_offsets':
# OVERWRITE-NEXT: 0x00000000 34120000 06001200 4.......
## ^------- unit_length (4-byte)
## ^--- version (2-byte)
## ^--- padding (2-bye)
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
DWARF:
debug_str_offsets:
- Length: 0x1234
Version: 6
Padding: 0x12
## d) Test that an empty 'Offsets' field is allowed.
# RUN: yaml2obj --docnum=3 %s -o %t3.o
# RUN: llvm-readelf --hex-dump=.debug_str_offsets %t3.o | \
# RUN: FileCheck %s --check-prefix=EMPTY-OFFSETS
# EMPTY-OFFSETS: Hex dump of section '.debug_str_offsets':
# EMPTY-OFFSETS-NEXT: 0x00000000 04000000 05000000 ........
## ^------- unit_length (4-byte)
## ^--- version (2-byte)
## ^--- padding (2-byte)
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
DWARF:
debug_str_offsets:
- Offsets: []
## e) Test that the .debug_str_offsets section header is emitted if the "debug_str_offsets" is empty.
# RUN: yaml2obj --docnum=4 %s -o %t4.o
# RUN: llvm-readobj --sections --section-data %t4.o | \
# RUN: FileCheck -DSIZE=0 -DADDRALIGN=1 %s --check-prefixes=SHDR,EMPTY-CONTENT
# EMPTY-CONTENT-NEXT: SectionData (
# EMPTY-CONTENT-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
DWARF:
debug_str_offsets: []
## f) Generate the .debug_str_offsets section from raw section content.
# RUN: yaml2obj --docnum=5 %s -o %t5.o
# RUN: llvm-readobj --sections --section-data %t5.o | \
# RUN: FileCheck %s -DADDRALIGN=0 -DSIZE=3 --check-prefixes=SHDR,ARBITRARY-CONTENT
# ARBITRARY-CONTENT: SectionData (
# ARBITRARY-CONTENT-NEXT: 0000: 112233
# ARBITRARY-CONTENT-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str_offsets
Type: SHT_PROGBITS
Content: "112233"
## g) Generate the .debug_str_offsets section when the "Size" is specified.
# RUN: yaml2obj --docnum=6 %s -o %t6.o
# RUN: llvm-readelf --hex-dump=.debug_str_offsets %t6.o | \
# RUN: FileCheck %s --check-prefix=SIZE
# SIZE: Hex dump of section '.debug_str_offsets':
# SIZE-NEXT: 0x00000000 00000000 00000000 00000000 00000000 ................
# SIZE-EMPTY:
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str_offsets
Type: SHT_PROGBITS
Size: 0x10
## h) Test that yaml2obj emits an error message when both the "Size" and the
## "debug_str_offsets" entry are specified at the same time.
# RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=ERROR
# ERROR: yaml2obj: error: cannot specify section '.debug_str_offsets' contents in the 'DWARF' entry and the 'Content' or 'Size' in the 'Sections' entry at the same time
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str_offsets
Type: SHT_PROGBITS
Size: 0x10
DWARF:
debug_str_offsets:
- Offsets: []
## i) Test that yaml2obj emits an error message when both the "Content" and the
## "debug_str_offsets" entry are specified at the same time.
# RUN: not yaml2obj --docnum=8 %s 2>&1 | FileCheck %s --check-prefix=ERROR
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str_offsets
Type: SHT_PROGBITS
Content: "00"
DWARF:
debug_str_offsets:
- Offsets: []
## j) Test that all the properties can be overridden by the section header when
## the "debug_str_offsets" entry doesn't exist.
# RUN: yaml2obj --docnum=9 %s -o %t9.o
# RUN: llvm-readelf --sections %t9.o | FileCheck %s --check-prefix=OVERRIDDEN
# OVERRIDDEN: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
# OVERRIDDEN: [ 1] .debug_str_offsets STRTAB 0000000000002020 000050 000008 01 A 2 1 2
# OVERRIDDEN-NEXT: [ 2] .sec STRTAB 0000000000000000 000058 000000 00 0 0 0
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str_offsets
Type: SHT_STRTAB ## SHT_PROGBITS by default.
Flags: [SHF_ALLOC] ## 0 by default.
Link: .sec ## 0 by default.
EntSize: 1 ## 0 by default.
Info: 1 ## 0 by default.
AddressAlign: 2 ## 0 by default.
Address: 0x2020 ## 0x00 by default.
Offset: 0x50 ## 0x40 for the first section.
Size: 0x08 ## Set the "Size" so that we can reuse the check tag "OVERRIDDEN".
- Name: .sec ## Linked by .debug_str_offsets.
Type: SHT_STRTAB
## k) Test that all the properties can be overridden by the section header when
## the "debug_str_offsets" entry exists.
# RUN: yaml2obj --docnum=10 %s -o %t10.o
# RUN: llvm-readelf --sections %t10.o | FileCheck %s --check-prefix=OVERRIDDEN
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Sections:
- Name: .debug_str_offsets
Type: SHT_STRTAB ## SHT_PROGBITS by default.
Flags: [SHF_ALLOC] ## 0 by default.
Link: .sec ## 0 by default.
EntSize: 1 ## 0 by default.
Info: 1 ## 0 by default.
AddressAlign: 2 ## 1 by default.
Address: 0x2020 ## 0x00 by default.
Offset: 0x50 ## 0x40 for the first section.
- Name: .sec ## Linked by .debug_str_offsets.
Type: SHT_STRTAB
DWARF:
debug_str_offsets:
- Offsets: []