## Check how yaml2obj produces SHT_HASH sections.
## Check we can describe a SHT_HASH section using the "Content" tag.
## Check default values of section fields.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readobj --sections --section-data %t1 | \
# RUN: FileCheck %s -DENTSIZE=4 --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: [[ENTSIZE]]{{$}}
# 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
Sections:
## SHT_HASH is linked to dynamic symbol table by default.
- Name: .dynsym
Type: SHT_DYNSYM
- Name: .hash
Type: SHT_HASH
Content: '0100000002000000030000000400000005000000'
EntSize: [[ENTSIZE=<none>]]
## Check we can set an arbitrary entry size for the SHT_HASH section.
# RUN: yaml2obj --docnum=1 -DENTSIZE=0xFF %s -o %t1.entsize
# RUN: llvm-readobj --sections --section-data %t1.entsize | \
# RUN: FileCheck %s -DENTSIZE=255 --check-prefix=CONTENT
## 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
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" and "Chain" cannot be used with "Content" or "Size"
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
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
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
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
Sections:
- Name: .hash
Type: SHT_HASH
Chain: [ 1 ]
## Check we emit an empty section if neither "Bucket", "Chain",
## "Content" nor "Size" were set.
# RUN: yaml2obj --docnum=7 %s -o %t7
# RUN: llvm-readelf --sections %t7 | FileCheck %s --check-prefix=NO-TAGS
# NO-TAGS: [Nr] Name Type Address Off Size
# NO-TAGS: [ 1] .hash HASH 00000000 000034 000000
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
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
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
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
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: Section size must be greater than or equal to the content size
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
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
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
Sections:
- Name: .hash
Type: SHT_HASH
Size: 0x1
Chain: [ 1 ]
## Check we can override "nbucket" and "nchain" values of a SHT_HASH section using "NBucket"
## and "NChain" tags. Check that the section size is unaffected when we do this.
# RUN: yaml2obj --docnum=14 %s -o %t14
# RUN: llvm-readobj --sections --section-data %t14 | FileCheck %s --check-prefix=OVERRIDE
# OVERRIDE: Name: .hash
# OVERRIDE-NEXT: Type: SHT_HASH
# OVERRIDE-NEXT: Flags [
# OVERRIDE-NEXT: ]
# OVERRIDE-NEXT: Address: 0x0
# OVERRIDE-NEXT: Offset: 0x34
# OVERRIDE-NEXT: Size: 28
# OVERRIDE-NEXT: Link: 0
# OVERRIDE-NEXT: Info: 0
# OVERRIDE-NEXT: AddressAlignment: 0
# OVERRIDE-NEXT: EntrySize: 4
# OVERRIDE-NEXT: SectionData (
# OVERRIDE-NEXT: 0000: AA000000 BB000000 01000000 02000000
# OVERRIDE-NEXT: 0010: 03000000 04000000 05000000
# OVERRIDE-NEXT: )
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Sections:
- Name: .hash
Type: SHT_HASH
Bucket: [ 1, 2 ]
Chain: [ 3, 4, 5 ]
NBucket: 0xAA
NChain: 0xBB