1 ## Check how yaml2obj produces SHT_GNU_HASH sections.
3 ## Check we can describe a SHT_GNU_HASH section using the "Content" tag.
4 ## Check we set sh_link to index of the .dynsym by default.
6 # RUN: yaml2obj --docnum=1 %s -o %t1
7 # RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s --check-prefix=CONTENT
9 # CONTENT: Name: .gnu.hash
10 # CONTENT-NEXT: Type: SHT_GNU_HASH
11 # CONTENT-NEXT: Flags [
13 # CONTENT-NEXT: Address: 0x0
14 # CONTENT-NEXT: Offset: 0x40
15 # CONTENT-NEXT: Size: 3
16 # CONTENT-NEXT: Link: 2
17 # CONTENT-NEXT: Info: 0
18 # CONTENT-NEXT: AddressAlignment: 0
19 # CONTENT-NEXT: EntrySize: 0
20 # CONTENT-NEXT: SectionData (
21 # CONTENT-NEXT: 0000: 001122 |
24 # CONTENT-NEXT: Name: .dynsym (9)
35 ## Used to trigger .dynsym creation.
38 ## Check we can use "Header", "BloomFilter", "HashBuckets" and "HashValues" keys to describe
39 ## the hash section. Check we can set sh_link to any arbitrary value. Check both ELFCLASS32 and 64 bit output.
41 # RUN: yaml2obj --docnum=2 %s -o %t2
42 # RUN: yaml2obj --docnum=3 %s -o %t3
43 # RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s --check-prefix=CONTENT32
44 # RUN: llvm-readobj --sections --section-data %t3 | FileCheck %s --check-prefix=CONTENT64
46 # CONTENT32: Name: .gnu.hash
47 # CONTENT32-NEXT: Type: SHT_GNU_HASH
48 # CONTENT32-NEXT: Flags [
49 # CONTENT32-NEXT: SHF_ALLOC
51 # CONTENT32-NEXT: Address: 0x0
52 # CONTENT32-NEXT: Offset: 0x34
53 # CONTENT32-NEXT: Size: 52
54 # CONTENT32-NEXT: Link: 254
55 # CONTENT32-NEXT: Info: 0
56 # CONTENT32-NEXT: AddressAlignment: 0
57 # CONTENT32-NEXT: EntrySize: 0
58 # CONTENT32-NEXT: SectionData (
59 # CONTENT32-NEXT: 0000: 03000000 01000000 02000000 02000000 |
60 # CONTENT32-NEXT: 0010: 03000000 04000000 05000000 06000000 |
61 # CONTENT32-NEXT: 0020: 07000000 08000000 09000000 0A000000 |
62 # CONTENT32-NEXT: 0030: 0B000000 |
65 # CONTENT64: Name: .gnu.hash
66 # CONTENT64-NEXT: Type: SHT_GNU_HASH
67 # CONTENT64-NEXT: Flags [
68 # CONTENT64-NEXT: SHF_ALLOC
70 # CONTENT64-NEXT: Address: 0x0
71 # CONTENT64-NEXT: Offset: 0x40
72 # CONTENT64-NEXT: Size: 60
73 # CONTENT64-NEXT: Link: 254
74 # CONTENT64-NEXT: Info: 0
75 # CONTENT64-NEXT: AddressAlignment: 0
76 # CONTENT64-NEXT: EntrySize: 0
77 # CONTENT64-NEXT: SectionData (
78 # CONTENT64-NEXT: 0000: 03000000 01000000 02000000 02000000 |
79 # CONTENT64-NEXT: 0010: 03000000 00000000 04000000 00000000 |
80 # CONTENT64-NEXT: 0020: 05000000 06000000 07000000 08000000 |
81 # CONTENT64-NEXT: 0030: 09000000 0A000000 0B000000 |
96 BloomFilter: [0x3, 0x4]
97 HashBuckets: [0x5, 0x6, 0x7]
98 HashValues: [0x8, 0x9, 0xA, 0xB]
113 BloomFilter: [0x3, 0x4]
114 HashBuckets: [0x5, 0x6, 0x7]
115 HashValues: [0x8, 0x9, 0xA, 0xB]
118 ## Check we only can use "Header", "BloomFilter", "HashBuckets" and "HashValues" together.
120 # RUN: not yaml2obj --docnum=4 %s -o %t4 2>&1 | FileCheck %s --check-prefix=ERR
121 # RUN: not yaml2obj --docnum=5 %s -o %t5 2>&1 | FileCheck %s --check-prefix=ERR
122 # RUN: not yaml2obj --docnum=6 %s -o %t6 2>&1 | FileCheck %s --check-prefix=ERR
123 # RUN: not yaml2obj --docnum=7 %s -o %t7 2>&1 | FileCheck %s --check-prefix=ERR
125 # ERR: error: "Header", "BloomFilter", "HashBuckets" and "HashValues" must be used together
133 - Name: .gnu.hash.no.header
145 - Name: .gnu.hash.no.bloomfilter
159 - Name: .gnu.hash.no.nobuckets
173 - Name: .gnu.hash.no.novalues
181 ## Check that "SymNdx" and "Shift2" fields are mandatory when we specify the "Header".
183 # RUN: not yaml2obj --docnum=8 %s -o %t8 2>&1 | FileCheck %s --check-prefix=ERR2
184 # ERR2: error: missing required key 'SymNdx'
186 # RUN: not yaml2obj --docnum=9 %s -o %t9 2>&1 | FileCheck %s --check-prefix=ERR3
187 # ERR3: error: missing required key 'Shift2'
211 ## Check we emit an empty section if neither "Content", "Header",
212 ## "BloomFilter", "HashBuckets" nor "HashBuckets" were set.
214 # NOKEYS: Section Headers:
215 # NOKEYS: [Nr] Name Type Address Off Size
216 # NOKEYS: [ 1] .gnu.hash GNU_HASH 0000000000000000 000040 000000
218 # RUN: yaml2obj --docnum=10 %s -o %t10
219 # RUN: llvm-readelf --sections %t10 | FileCheck %s --check-prefix=NOKEYS
230 ## Test that "Header", "BloomFilter", "HashBuckets" and "HashValues" can't be used together with the "Content" or "Size"
232 # RUN: not yaml2obj --docnum=11 -DCONTENT="" %s 2>&1 | FileCheck %s --check-prefix=TOGETHER
233 # RUN: not yaml2obj --docnum=11 -DSIZE=0 %s 2>&1 | FileCheck %s --check-prefix=TOGETHER
234 # TOGETHER: error: "Header", "BloomFilter", "HashBuckets" and "HashValues" cannot be used with "Content" or "Size"
244 Content: [[CONTENT=<none>]]
245 Size: [[SIZE=<none>]]
253 ## Test we can override the number of buckets and the number of words in the Bloom filter
254 ## using the "NBuckets" and "Shift2" keys.
256 # RUN: yaml2obj --docnum=12 %s -o %t12
257 # RUN: llvm-readobj --sections --section-data %t12 | FileCheck %s --check-prefix=OVERRIDE-CONTENT
259 # OVERRIDE-CONTENT: Name: .gnu.hash
260 # OVERRIDE-CONTENT: SectionData (
261 # OVERRIDE-CONTENT-NEXT: 0000: 01000000 02000000 03000000 04000000 |
262 # OVERRIDE-CONTENT-NEXT: )
281 ## Check we can use the "Content" key with the "Size" key when the size is greater
282 ## than or equal to the content size.
284 # RUN: not yaml2obj --docnum=13 -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \
285 # RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR
287 # CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size
297 Size: [[SIZE=<none>]]
298 Content: [[CONTENT=<none>]]
300 # RUN: yaml2obj --docnum=13 -DSIZE=2 -DCONTENT="'0011'" %s -o %t.cont.size.eq.o
301 # RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \
302 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="0011"
304 # RUN: yaml2obj --docnum=13 -DSIZE=3 -DCONTENT="'0011'" %s -o %t.cont.size.gr.o
305 # RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \
306 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="001100"
308 # CHECK-CONTENT: Name: .gnu.hash
309 # CHECK-CONTENT: SectionData (
310 # CHECK-CONTENT-NEXT: 0000: [[DATA]] |
311 # CHECK-CONTENT-NEXT: )
313 ## Check we can use the "Size" key alone to create the section.
315 # RUN: yaml2obj --docnum=13 -DSIZE=3 %s -o %t.size.o
316 # RUN: llvm-readobj --sections --section-data %t.size.o | \
317 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="000000"
319 ## Check we can use the "Content" key alone to create the section.
321 # RUN: yaml2obj --docnum=13 -DCONTENT="'112233'" %s -o %t.content.o
322 # RUN: llvm-readobj --sections --section-data %t.content.o | \
323 # RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="112233"