hash-section.yaml
6.41 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
## Check how yaml2obj produces SHT_HASH sections.
## Check we can describe a SHT_HASH section using the "Content" tag.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s --check-prefix=CONTENT
# CONTENT: Name: .hash
# CONTENT-NEXT: Type: SHT_HASH
# CONTENT-NEXT: Flags [
# CONTENT-NEXT: ]
# CONTENT-NEXT: Address: 0x0
# CONTENT-NEXT: Offset: 0x44
# CONTENT-NEXT: Size: 20
# CONTENT-NEXT: Link: 1
# CONTENT-NEXT: Info: 0
# CONTENT-NEXT: AddressAlignment: 0
# CONTENT-NEXT: EntrySize: 0
# CONTENT-NEXT: SectionData (
# CONTENT-NEXT: 0000: 01000000 02000000 03000000 04000000
# CONTENT-NEXT: 0010: 05000000
# CONTENT-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_386
Sections:
## SHT_HASH is linked to dynamic symbol table by default.
- Name: .dynsym
Type: SHT_DYNSYM
- Name: .hash
Type: SHT_HASH
Content: '0100000002000000030000000400000005000000'
## Check we can describe a SHT_HASH section using "Bucket" and "Chain" tags.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s --check-prefix=BUCKET-CHAIN
# BUCKET-CHAIN: Name: .hash
# BUCKET-CHAIN: Size:
# BUCKET-CHAIN-SAME: 28
# BUCKET-CHAIN: Link:
# BUCKET-CHAIN-SAME: 0
# BUCKET-CHAIN: SectionData (
# BUCKET-CHAIN-NEXT: 0000: 02000000 03000000 01000000 02000000 |
# BUCKET-CHAIN-NEXT: 0010: 03000000 04000000 05000000 |
# BUCKET-CHAIN-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_386
Sections:
- Name: .hash
Type: SHT_HASH
Bucket: [ 1, 2 ]
Chain: [ 3, 4, 5 ]
## Check we can't use "Content" and "Bucket" tags together.
# RUN: not yaml2obj --docnum=3 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-BUCKET
# CONTENT-BUCKET: "Bucket" cannot be used with "Content" or "Size"
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_386
Sections:
- Name: .hash
Type: SHT_HASH
Bucket: [ 1 ]
Content: '00'
## Check we can't use "Content" and "Chain" tags together.
# RUN: not yaml2obj --docnum=4 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-CHAIN
# CONTENT-CHAIN: "Chain" cannot be used with "Content" or "Size"
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_386
Sections:
- Name: .hash
Type: SHT_HASH
Chain: [ 1 ]
Content: '00'
## Check we can't use "Bucket" without "Chain".
# RUN: not yaml2obj --docnum=5 %s 2>&1 | FileCheck %s --check-prefix=NO-BUCKET-OR-CHAIN
# NO-BUCKET-OR-CHAIN: error: "Bucket" and "Chain" must be used together
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_386
Sections:
- Name: .hash
Type: SHT_HASH
Bucket: [ 1 ]
## Check we can't use "Chain" without "Bucket".
# RUN: not yaml2obj --docnum=6 %s 2>&1 | FileCheck %s --check-prefix=NO-BUCKET-OR-CHAIN
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_386
Sections:
- Name: .hash
Type: SHT_HASH
Chain: [ 1 ]
## Check we report an error if neither "Bucket", "Chain" nor "Content" were set.
# RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=NO-TAGS
# NO-TAGS: error: one of "Content", "Size", "Bucket" or "Chain" must be specified
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_386
Sections:
- Name: .hash
Type: SHT_HASH
## Check we can set any sh_link value with use of the "Link" tag.
# RUN: yaml2obj --docnum=8 %s -o %t8
# RUN: llvm-readobj --sections %t8 | FileCheck %s --check-prefix=LINK
# LINK: Name: .hash1
# LINK: Link:
# LINK-SAME: 123
# LINK: Name: .hash2
# LINK: Link:
# LINK-SAME: 1
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_386
Sections:
- Name: .hash1
Type: SHT_HASH
Content: ""
Link: 123
- Name: .hash2
Type: SHT_HASH
Content: ""
Link: .hash1
## SHT_HASH is linked to dynamic symbol table by default if it exists.
- Name: .dynsym
Type: SHT_DYNSYM
## Check we can use only "Size" to create a SHT_HASH section.
# RUN: yaml2obj --docnum=9 %s -o %t9
# RUN: llvm-readobj --sections --section-data %t9 | FileCheck %s --check-prefix=SIZE
# SIZE: Name: .hash
# 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: .hash
Type: SHT_HASH
Size: 0x11
## Check we can use "Size" and "Content" together to create a SHT_HASH section.
# RUN: yaml2obj --docnum=10 %s -o %t10
# RUN: llvm-readobj --sections --section-data %t10 | FileCheck %s --check-prefix=SIZE-CONTENT
# SIZE-CONTENT: Name: .hash
# 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: .hash
Type: SHT_HASH
Size: 0x5
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=11 %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: .hash
Type: SHT_HASH
Size: 0x1
Content: "1122"
## Check we can't use "Size" and "Bucket" tags together.
# RUN: not yaml2obj --docnum=12 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-BUCKET
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .hash
Type: SHT_HASH
Size: 0x1
Bucket: [ 1 ]
## Check we can't use "Size" and "Chain" tags together.
# RUN: not yaml2obj --docnum=13 %s 2>&1 | FileCheck %s --check-prefix=CONTENT-CHAIN
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .hash
Type: SHT_HASH
Size: 0x1
Chain: [ 1 ]