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
| ## Check how yaml2obj produces SHT_LLVM_ADDRSIG sections.
## Check we can describe SHT_LLVM_ADDRSIG using the "Symbols" tag. We can define
## symbols either using names or indexes.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s --check-prefix=SYMBOLS
# SYMBOLS: Section {
# SYMBOLS: Index: 1
# SYMBOLS-NEXT: Name: .llvm_addrsig
# SYMBOLS-NEXT: Type: SHT_LLVM_ADDRSIG
# SYMBOLS-NEXT: Flags [
# SYMBOLS-NEXT: ]
# SYMBOLS-NEXT: Address: 0x0
# SYMBOLS-NEXT: Offset: 0x40
# SYMBOLS-NEXT: Size: 4
# SYMBOLS-NEXT: Link: 2
# SYMBOLS-NEXT: Info: 0
# SYMBOLS-NEXT: AddressAlignment: 0
# SYMBOLS-NEXT: EntrySize: 0
# SYMBOLS-NEXT: SectionData (
# SYMBOLS-NEXT: 0000: 01020102
# SYMBOLS-NEXT: )
# SYMBOLS-NEXT: }
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Symbols:
- Name: foo
- Name: bar
- Index: 1
- Index: 2
Symbols:
- Name: foo
Type: STT_FUNC
Binding: STB_GLOBAL
- Name: bar
Type: STT_FUNC
Binding: STB_GLOBAL
## We can't specify both "Index" and "Name" when defining a symbol.
# RUN: not yaml2obj --docnum=2 %s 2>&1 | FileCheck %s --check-prefix=INDEX-NAME
# INDEX-NAME: error: "Index" and "Name" cannot be used together when defining a symbol
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Symbols:
- Name: foo
Index: 1
Symbols:
- Name: foo
Type: STT_FUNC
Binding: STB_GLOBAL
## Check we report an error if an unknown symbol is referenced in the
## SHT_LLVM_ADDRSIG section description.
# RUN: not yaml2obj --docnum=3 %s 2>&1 | FileCheck %s --check-prefix=SYMBOL-UNKNOWN
# SYMBOL-UNKNOWN: error: unknown symbol referenced: 'foo' by YAML section '.llvm_addrsig'
# SYMBOL-UNKNOWN: error: unknown symbol referenced: 'bar' by YAML section '.llvm_addrsig'
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Symbols:
- Name: foo
- Name: bar
## Check we can specify any arbitrary symbol indices.
# RUN: yaml2obj --docnum=4 %s -o %t4
# RUN: llvm-readobj --sections --section-data %t4 | FileCheck %s --check-prefix=SYMBOL-INDEX
# SYMBOL-INDEX: Type: SHT_LLVM_ADDRSIG
# SYMBOL-INDEX: SectionData (
# SYMBOL-INDEX-NEXT: 0000: 00FF01C4 E6888901 FFFFFFFF 0F
# SYMBOL-INDEX-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Symbols:
- Index: 0
- Index: 255
- Index: 0x11223344
## 0xFFFFFFFF is a maximum allowed index value.
- Index: 0xFFFFFFFF
## Check that the maximum symbol index size is 32 bits.
# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=SYMBOL-INDEX-OVERFLOW
# SYMBOL-INDEX-OVERFLOW: error: out of range hex32 number
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Symbols:
- Index: 0x1122334455
## Check we can use the "Content" tag to specify any data for SHT_LLVM_ADDRSIG sections.
# RUN: yaml2obj --docnum=6 %s -o %t6
# RUN: llvm-readobj --sections --section-data %t6 | FileCheck %s --check-prefix=CONTENT
# CONTENT: Type: SHT_LLVM_ADDRSIG
# CONTENT: Size:
# CONTENT-SAME: 5
# CONTENT: SectionData (
# CONTENT-NEXT: 0000: 11223344 55
# CONTENT-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Content: "1122334455"
## Either "Content" or "Symbols" must be specifed for SHT_LLVM_ADDRSIG sections.
# RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=NO-TAGS
# NO-TAGS: error: one of "Content", "Size" or "Symbols" must be specified
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
## "Content" and "Symbols" cannot be used together to describe the SHT_LLVM_ADDRSIG section.
# RUN: not yaml2obj --docnum=8 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-SYMBOLS
# CONTENT-SYMBOLS: "Symbols" cannot be used with "Content" or "Size"
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Content: ""
Symbols:
## Check we can set an arbitrary sh_link value for SHT_LLVM_ADDRSIG sections.
# RUN: yaml2obj --docnum=9 %s -o %t9
# RUN: llvm-readobj --sections %t9 | FileCheck %s --check-prefix=LINK
# LINK: Name: .llvm_addrsig
# LINK: Link:
# LINK-SAME: 123{{$}}
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Sections:
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Link: 123
Content: ""
## Check we can use only "Size" to create a SHT_LLVM_ADDRSIG section.
# RUN: yaml2obj --docnum=10 %s -o %t10
# RUN: llvm-readobj --sections --section-data %t10 | FileCheck %s --check-prefix=SIZE
# SIZE: Name: .llvm_addrsig
# 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: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Size: 0x11
## Check we can use "Size" and "Content" together to create a SHT_LLVM_ADDRSIG section.
# RUN: yaml2obj --docnum=11 %s -o %t11
# RUN: llvm-readobj --sections --section-data %t11 | FileCheck %s --check-prefix=SIZE-CONTENT
# SIZE-CONTENT: Name: .llvm_addrsig_sizegr
# SIZE-CONTENT: Size:
# SIZE-CONTENT-SAME: 5
# SIZE-CONTENT: SectionData (
# SIZE-CONTENT-NEXT: 0000: 11223300 00 |
# SIZE-CONTENT-NEXT: )
# SIZE-CONTENT: Name: .llvm_addrsig_sizeeq
# SIZE-CONTENT: Size:
# SIZE-CONTENT-SAME: 3
# SIZE-CONTENT: SectionData (
# SIZE-CONTENT-NEXT: 0000: 112233 |
# SIZE-CONTENT-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .llvm_addrsig_sizegr
Type: SHT_LLVM_ADDRSIG
Size: 0x5
Content: "112233"
- Name: .llvm_addrsig_sizeeq
Type: SHT_LLVM_ADDRSIG
Size: 0x3
Content: "112233"
## Check that when "Size" and "Content" are used together, the size
## must be greater than or equal to the content size.
# RUN: not yaml2obj --docnum=12 %s 2>&1 | FileCheck %s --check-prefix=SIZE-CONTENT-ERR
# SIZE-CONTENT-ERR: error: "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: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Size: 0x1
Content: "1122"
## Check we can't use "Size" and "Symbols" tags together.
# RUN: not yaml2obj --docnum=13 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-SYMBOLS
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .llvm_addrsig
Type: SHT_LLVM_ADDRSIG
Size: 0x1
Symbols: [ ]
|