stack-sizes.yaml
8.76 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
## Check how yaml2obj produces .stack_sizes sections.
## Test the following cases when the .stack_sizes Content field is specified:
## 1) We can produce a .stack_sizes section from a description with
## a valid section content.
## 2) We can produce an incorrect .stack_sizes section from a description with
## a broken (truncated) section content.
## 3) We can produce an empty .stack_sizes section from a description with
## empty section content.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s
## Case 1: valid content.
# CHECK: Section {
# CHECK: Index: 1
# CHECK-NEXT: Name: .stack_sizes (1)
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)
# CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
# CHECK-NEXT: Offset: 0x40
# CHECK-NEXT: Size: 9
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 0
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: SectionData (
# CHECK-NEXT: 0000: 10000000 00000000 20
# CHECK-NEXT: )
# CHECK-NEXT: }
## Case 2: truncated content.
# CHECK: Name: .stack_sizes
# CHECK: Size:
# CHECK-SAME: 8
# CHECK: SectionData (
# CHECK-NEXT: 0000: 10000000 00000000
## Case 3: empty content.
# CHECK: Name: .stack_sizes
# CHECK: Size:
# CHECK-SAME: 0
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
## Valid.
- Name: '.stack_sizes [1]'
Type: SHT_PROGBITS
Content: "100000000000000020"
## Truncated.
- Name: '.stack_sizes [2]'
Type: SHT_PROGBITS
Content: "1000000000000000"
## Empty.
- Name: '.stack_sizes [3]'
Type: SHT_PROGBITS
Content: ""
## Check we can describe .stack_sizes section using <address, size> pairs.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s --check-prefix=ENTRIES-LE64-BOTH
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: llvm-readobj --sections --section-data %t3 | FileCheck %s --check-prefix=ENTRIES-BE64-BOTH
# RUN: yaml2obj --docnum=4 %s -o %t4
# RUN: llvm-readobj --sections --section-data %t4 | FileCheck %s --check-prefix=ENTRIES-LE32-BOTH
# RUN: yaml2obj --docnum=5 %s -o %t5
# RUN: llvm-readobj --sections --section-data %t5 | FileCheck %s --check-prefix=ENTRIES-BE32-BOTH
# ENTRIES-LE64-BOTH: Name: .stack_sizes
# ENTRIES-LE64-BOTH: SectionData (
# ENTRIES-LE64-BOTH-NEXT: 0000: 10000000 00000000 20300000 00000000 |
# ENTRIES-LE64-BOTH-NEXT: 0010: 0040 |
# ENTRIES-BE64-BOTH: Name: .stack_sizes
# ENTRIES-BE64-BOTH: SectionData (
# ENTRIES-BE64-BOTH-NEXT: 0000: 00000000 00000010 20000000 00000000 |
# ENTRIES-BE64-BOTH-NEXT: 0010: 3040
# ENTRIES-LE32-BOTH: Name: .stack_sizes
# ENTRIES-LE32-BOTH: SectionData (
# ENTRIES-LE32-BOTH-NEXT: 0000: 10000000 20300000 0040 |
# ENTRIES-BE32-BOTH: Name: .stack_sizes
# ENTRIES-BE32-BOTH: SectionData (
# ENTRIES-BE32-BOTH-NEXT: 0000: 00000010 20000000 3040 |
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
Entries:
- Address: 0x10
Size: 0x20
- Address: 0x30
Size: 0x40
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2MSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
Entries:
- Address: 0x10
Size: 0x20
- Address: 0x30
Size: 0x40
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_386
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
Entries:
- Address: 0x10
Size: 0x20
- Address: 0x30
Size: 0x40
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2MSB
Type: ET_EXEC
Machine: EM_386
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
Entries:
- Address: 0x10
Size: 0x20
- Address: 0x30
Size: 0x40
## Check we can omit the "Address" tag. In this case the address will be zero.
# RUN: yaml2obj --docnum=6 %s -o %t6
# RUN: llvm-readobj --sections --section-data %t6 | FileCheck %s --check-prefix=ENTRIES-NOADDR
# ENTRIES-NOADDR: Name: .stack_sizes
# ENTRIES-NOADDR: SectionData (
# ENTRIES-NOADDR-NEXT: 0000: 00000000 00000000 10000000 00000000 |
# ENTRIES-NOADDR-NEXT: 0010: 0020 |
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
Entries:
- Size: 0x10
- Size: 0x20
## Check that "Size" tag is mandatory when we describe .stack_sizes using "Entries".
# RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=ENTRIES-NOSIZE
# ENTRIES-NOSIZE: error: missing required key 'Size'
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
Entries:
- Address: 0x10
## Check we can't use both "Content" and "Entries" tags at the same time.
# RUN: not yaml2obj --docnum=8 %s 2>&1 | FileCheck %s --check-prefix=ENTRIES-AND-CONTENT
# ENTRIES-AND-CONTENT: error: .stack_sizes: Content and Entries cannot be used together
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
Content: "00"
Entries:
- Address: 0x10
Size: 0x20
## Check we must specify either "Content", "Entries" or "Size" tag when describing .stack_sizes.
# RUN: not yaml2obj --docnum=9 %s 2>&1 | FileCheck %s --check-prefix=NO-TAGS
# NO-TAGS: .stack_sizes: one of Content, Entries and Size must be specified
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
## Check we can't use both "Size" and "Entries" tags at the same time.
# RUN: not yaml2obj --docnum=10 %s 2>&1 | FileCheck %s --check-prefix=ENTRIES-AND-SIZE
# ENTRIES-AND-SIZE: .stack_sizes: Size and Entries cannot be used together
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
Size: 0x1
Entries:
- Address: 0x10
Size: 0x20
## Check we can use only "Size" to create .stack_sizes section.
# RUN: yaml2obj --docnum=11 %s -o %t11
# RUN: llvm-readobj --sections --section-data %t11 | FileCheck %s --check-prefix=SIZE
# SIZE: Name: .stack_sizes
# SIZE: Size:
# SIZE-SAME: 17
# SIZE: SectionData (
# SIZE-NEXT: 0000: 00000000 00000000 00000000 00000000 |
# SIZE-NEXT: 0010: 00 |
# SIZE-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
Size: 0x11
## Check we can use "Size" and "Content" together to create .stack_sizes section.
# RUN: yaml2obj --docnum=12 %s -o %t12
# RUN: llvm-readobj --sections --section-data %t12 | FileCheck %s --check-prefix=SIZE-CONTENT
# SIZE-CONTENT: Name: .stack_sizes
# SIZE-CONTENT: Size:
# SIZE-CONTENT-SAME: 5
# SIZE-CONTENT: SectionData (
# SIZE-CONTENT-NEXT: 0000: 11223300 00 |
# SIZE-CONTENT-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
Size: 0x5
Content: "112233"
# RUN: not yaml2obj --docnum=13 %s 2>&1 | FileCheck %s --check-prefix=SIZE-CONTENT-ERR
# SIZE-CONTENT-ERR: error: .stack_sizes: Size must be greater than or equal to the content size
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .stack_sizes
Type: SHT_PROGBITS
Size: 0x1
Content: "1122"
## Check we can describe multiple .stack_sizes sections using unique suffixes.
# RUN: yaml2obj --docnum=14 %s -o %t11
# RUN: llvm-readobj --sections --section-data %t11 | FileCheck %s --check-prefix=UNIQUE
# UNIQUE: Name: .stack_sizes
# UNIQUE: SectionData (
# UNIQUE-NEXT: 0000: 10000000 00000000 20 |
# UNIQUE: Name: .stack_sizes
# UNIQUE: SectionData (
# UNIQUE-NEXT: 0000: 30000000 00000000 40 |
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: '.stack_sizes [1]'
Type: SHT_PROGBITS
Entries:
- Address: 0x10
Size: 0x20
- Name: '.stack_sizes [2]'
Type: SHT_PROGBITS
Entries:
- Address: 0x30
Size: 0x40