324 lines · yaml
1## Check how yaml2obj produces SHT_GNU_HASH sections.2 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.5 6# RUN: yaml2obj --docnum=1 %s -o %t17# RUN: llvm-readobj --sections --section-data %t1 | FileCheck %s --check-prefix=CONTENT8 9# CONTENT: Name: .gnu.hash10# CONTENT-NEXT: Type: SHT_GNU_HASH11# CONTENT-NEXT: Flags [12# CONTENT-NEXT: ]13# CONTENT-NEXT: Address: 0x014# CONTENT-NEXT: Offset: 0x4015# CONTENT-NEXT: Size: 316# CONTENT-NEXT: Link: 217# CONTENT-NEXT: Info: 018# CONTENT-NEXT: AddressAlignment: 019# CONTENT-NEXT: EntrySize: 020# CONTENT-NEXT: SectionData (21# CONTENT-NEXT: 0000: 001122 |22# CONTENT-NEXT: )23# CONTENT: Index: 224# CONTENT-NEXT: Name: .dynsym (9)25 26--- !ELF27FileHeader:28 Class: ELFCLASS6429 Data: ELFDATA2LSB30 Type: ET_DYN31Sections:32 - Name: .gnu.hash33 Type: SHT_GNU_HASH34 Content: "001122"35## Used to trigger .dynsym creation.36DynamicSymbols: []37 38## Check we can use "Header", "BloomFilter", "HashBuckets" and "HashValues" keys to describe39## the hash section. Check we can set sh_link to any arbitrary value. Check both ELFCLASS32 and 64 bit output.40 41# RUN: yaml2obj --docnum=2 %s -o %t242# RUN: yaml2obj --docnum=3 %s -o %t343# RUN: llvm-readobj --sections --section-data %t2 | FileCheck %s --check-prefix=CONTENT3244# RUN: llvm-readobj --sections --section-data %t3 | FileCheck %s --check-prefix=CONTENT6445 46# CONTENT32: Name: .gnu.hash47# CONTENT32-NEXT: Type: SHT_GNU_HASH48# CONTENT32-NEXT: Flags [49# CONTENT32-NEXT: SHF_ALLOC50# CONTENT32-NEXT: ]51# CONTENT32-NEXT: Address: 0x052# CONTENT32-NEXT: Offset: 0x3453# CONTENT32-NEXT: Size: 5254# CONTENT32-NEXT: Link: 25455# CONTENT32-NEXT: Info: 056# CONTENT32-NEXT: AddressAlignment: 057# CONTENT32-NEXT: EntrySize: 058# 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 |63# CONTENT32-NEXT: )64 65# CONTENT64: Name: .gnu.hash66# CONTENT64-NEXT: Type: SHT_GNU_HASH67# CONTENT64-NEXT: Flags [68# CONTENT64-NEXT: SHF_ALLOC69# CONTENT64-NEXT: ]70# CONTENT64-NEXT: Address: 0x071# CONTENT64-NEXT: Offset: 0x4072# CONTENT64-NEXT: Size: 6073# CONTENT64-NEXT: Link: 25474# CONTENT64-NEXT: Info: 075# CONTENT64-NEXT: AddressAlignment: 076# CONTENT64-NEXT: EntrySize: 077# 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 |82# CONTENT64-NEXT: )83 84--- !ELF85FileHeader:86 Class: ELFCLASS3287 Data: ELFDATA2LSB88 Type: ET_DYN89Sections:90 - Name: .gnu.hash91 Type: SHT_GNU_HASH92 Flags: [ SHF_ALLOC ]93 Header:94 SymNdx: 0x195 Shift2: 0x296 BloomFilter: [0x3, 0x4]97 HashBuckets: [0x5, 0x6, 0x7]98 HashValues: [0x8, 0x9, 0xA, 0xB]99 Link: 0xFE100 101--- !ELF102FileHeader:103 Class: ELFCLASS64104 Data: ELFDATA2LSB105 Type: ET_DYN106Sections:107 - Name: .gnu.hash108 Type: SHT_GNU_HASH109 Flags: [ SHF_ALLOC ]110 Header:111 SymNdx: 0x1112 Shift2: 0x2113 BloomFilter: [0x3, 0x4]114 HashBuckets: [0x5, 0x6, 0x7]115 HashValues: [0x8, 0x9, 0xA, 0xB]116 Link: 0xFE117 118## Check we only can use "Header", "BloomFilter", "HashBuckets" and "HashValues" together.119 120# RUN: not yaml2obj --docnum=4 %s -o %t4 2>&1 | FileCheck %s --check-prefix=ERR121# RUN: not yaml2obj --docnum=5 %s -o %t5 2>&1 | FileCheck %s --check-prefix=ERR122# RUN: not yaml2obj --docnum=6 %s -o %t6 2>&1 | FileCheck %s --check-prefix=ERR123# RUN: not yaml2obj --docnum=7 %s -o %t7 2>&1 | FileCheck %s --check-prefix=ERR124 125# ERR: error: "Header", "BloomFilter", "HashBuckets" and "HashValues" must be used together126 127--- !ELF128FileHeader:129 Class: ELFCLASS64130 Data: ELFDATA2LSB131 Type: ET_DYN132Sections:133 - Name: .gnu.hash.no.header134 Type: SHT_GNU_HASH135 BloomFilter: []136 HashBuckets: []137 HashValues: []138 139--- !ELF140FileHeader:141 Class: ELFCLASS64142 Data: ELFDATA2LSB143 Type: ET_DYN144Sections:145 - Name: .gnu.hash.no.bloomfilter146 Type: SHT_GNU_HASH147 Header:148 SymNdx: 0x0149 Shift2: 0x0150 HashBuckets: []151 HashValues: []152 153--- !ELF154FileHeader:155 Class: ELFCLASS64156 Data: ELFDATA2LSB157 Type: ET_DYN158Sections:159 - Name: .gnu.hash.no.nobuckets160 Type: SHT_GNU_HASH161 Header:162 SymNdx: 0x0163 Shift2: 0x0164 BloomFilter: []165 HashValues: []166 167--- !ELF168FileHeader:169 Class: ELFCLASS64170 Data: ELFDATA2LSB171 Type: ET_DYN172Sections:173 - Name: .gnu.hash.no.novalues174 Type: SHT_GNU_HASH175 Header:176 SymNdx: 0x0177 Shift2: 0x0178 BloomFilter: []179 HashBuckets: []180 181## Check that "SymNdx" and "Shift2" fields are mandatory when we specify the "Header".182 183# RUN: not yaml2obj --docnum=8 %s -o %t8 2>&1 | FileCheck %s --check-prefix=ERR2184# ERR2: error: missing required key 'SymNdx'185 186# RUN: not yaml2obj --docnum=9 %s -o %t9 2>&1 | FileCheck %s --check-prefix=ERR3187# ERR3: error: missing required key 'Shift2'188 189--- !ELF190FileHeader:191 Class: ELFCLASS64192 Data: ELFDATA2LSB193 Type: ET_DYN194Sections:195 - Name: .gnu.hash196 Type: SHT_GNU_HASH197 Header:198 Shift2: 0x0199 200--- !ELF201FileHeader:202 Class: ELFCLASS64203 Data: ELFDATA2LSB204 Type: ET_DYN205Sections:206 - Name: .gnu.hash207 Type: SHT_GNU_HASH208 Header:209 SymNdx: 0x0210 211## Check we emit an empty section if neither "Content", "Header",212## "BloomFilter", "HashBuckets" nor "HashBuckets" were set.213 214# NOKEYS: Section Headers:215# NOKEYS: [Nr] Name Type Address Off Size216# NOKEYS: [ 1] .gnu.hash GNU_HASH 0000000000000000 000040 000000217 218# RUN: yaml2obj --docnum=10 %s -o %t10219# RUN: llvm-readelf --sections %t10 | FileCheck %s --check-prefix=NOKEYS220 221--- !ELF222FileHeader:223 Class: ELFCLASS64224 Data: ELFDATA2LSB225 Type: ET_DYN226Sections:227 - Name: .gnu.hash228 Type: SHT_GNU_HASH229 230## Test that "Header", "BloomFilter", "HashBuckets" and "HashValues" can't be used together with the "Content" or "Size"231 232# RUN: not yaml2obj --docnum=11 -DCONTENT="" %s 2>&1 | FileCheck %s --check-prefix=TOGETHER233# RUN: not yaml2obj --docnum=11 -DSIZE=0 %s 2>&1 | FileCheck %s --check-prefix=TOGETHER234# TOGETHER: error: "Header", "BloomFilter", "HashBuckets" and "HashValues" cannot be used with "Content" or "Size"235 236--- !ELF237FileHeader:238 Class: ELFCLASS32239 Data: ELFDATA2LSB240 Type: ET_DYN241Sections:242 - Name: .gnu.hash243 Type: SHT_GNU_HASH244 Content: [[CONTENT=<none>]]245 Size: [[SIZE=<none>]]246 Header:247 SymNdx: 0x0248 Shift2: 0x0249 BloomFilter: []250 HashBuckets: []251 HashValues: []252 253## Test we can override the number of buckets and the number of words in the Bloom filter254## using the "NBuckets" and "Shift2" keys.255 256# RUN: yaml2obj --docnum=12 %s -o %t12257# RUN: llvm-readobj --sections --section-data %t12 | FileCheck %s --check-prefix=OVERRIDE-CONTENT258 259# OVERRIDE-CONTENT: Name: .gnu.hash260# OVERRIDE-CONTENT: SectionData (261# OVERRIDE-CONTENT-NEXT: 0000: 01000000 02000000 03000000 04000000 |262# OVERRIDE-CONTENT-NEXT: )263 264--- !ELF265FileHeader:266 Class: ELFCLASS32267 Data: ELFDATA2LSB268 Type: ET_DYN269Sections:270 - Name: .gnu.hash271 Type: SHT_GNU_HASH272 Header:273 NBuckets: 0x1274 SymNdx: 0x2275 MaskWords: 0x3276 Shift2: 0x4277 BloomFilter: []278 HashBuckets: []279 HashValues: []280 281## Check we can use the "Content" key with the "Size" key when the size is greater282## than or equal to the content size.283 284# RUN: not yaml2obj --docnum=13 -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \285# RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR286 287# CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size288 289--- !ELF290FileHeader:291 Class: ELFCLASS64292 Data: ELFDATA2LSB293 Type: ET_DYN294Sections:295 - Name: .gnu.hash296 Type: SHT_GNU_HASH297 Size: [[SIZE=<none>]]298 Content: [[CONTENT=<none>]]299 300# RUN: yaml2obj --docnum=13 -DSIZE=2 -DCONTENT="'0011'" %s -o %t.cont.size.eq.o301# RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \302# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="0011"303 304# RUN: yaml2obj --docnum=13 -DSIZE=3 -DCONTENT="'0011'" %s -o %t.cont.size.gr.o305# RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \306# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="001100"307 308# CHECK-CONTENT: Name: .gnu.hash309# CHECK-CONTENT: SectionData (310# CHECK-CONTENT-NEXT: 0000: [[DATA]] |311# CHECK-CONTENT-NEXT: )312 313## Check we can use the "Size" key alone to create the section.314 315# RUN: yaml2obj --docnum=13 -DSIZE=3 %s -o %t.size.o316# RUN: llvm-readobj --sections --section-data %t.size.o | \317# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="000000"318 319## Check we can use the "Content" key alone to create the section.320 321# RUN: yaml2obj --docnum=13 -DCONTENT="'112233'" %s -o %t.content.o322# RUN: llvm-readobj --sections --section-data %t.content.o | \323# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="112233"324