140 lines
4.1 KiB
YAML
140 lines
4.1 KiB
YAML
|
## Check we are able to produce a valid SHT_LLVM_LINKER_OPTIONS
|
||
|
## section from its description.
|
||
|
|
||
|
## Check we can use "Options", "Size" and "Content" alone to describe the data.
|
||
|
|
||
|
# RUN: yaml2obj --docnum=1 %s -o %t1
|
||
|
# RUN: llvm-readobj --string-dump .linker-options1 --sections --section-data %t1 \
|
||
|
# RUN: | FileCheck %s --check-prefix=OPTIONS
|
||
|
|
||
|
# OPTIONS: Name: .linker-options1
|
||
|
# OPTIONS-NEXT: Type: SHT_LLVM_LINKER_OPTIONS
|
||
|
# OPTIONS-NEXT: Flags [
|
||
|
# OPTIONS-NEXT: ]
|
||
|
# OPTIONS-NEXT: Address: 0x0
|
||
|
# OPTIONS-NEXT: Offset: 0x40
|
||
|
# OPTIONS-NEXT: Size: 34
|
||
|
# OPTIONS-NEXT: Link: 0
|
||
|
# OPTIONS-NEXT: Info: 0
|
||
|
# OPTIONS-NEXT: AddressAlignment: 0
|
||
|
# OPTIONS-NEXT: EntrySize: 0
|
||
|
|
||
|
# OPTIONS: Name: .linker-options2
|
||
|
# OPTIONS-NEXT: Type: SHT_LLVM_LINKER_OPTIONS
|
||
|
# OPTIONS: SectionData (
|
||
|
# OPTIONS-NEXT: 0000: 00112233 |
|
||
|
# OPTIONS-NEXT: )
|
||
|
|
||
|
# OPTIONS: Name: .linker-options3
|
||
|
# OPTIONS-NEXT: Type: SHT_LLVM_LINKER_OPTIONS
|
||
|
# OPTIONS: SectionData (
|
||
|
# OPTIONS-NEXT: 0000: 00000000 |
|
||
|
# OPTIONS-NEXT: )
|
||
|
|
||
|
# OPTIONS: String dump of section '.linker-options1':
|
||
|
# OPTIONS-NEXT: [ 0] option 0
|
||
|
# OPTIONS-NEXT: [ 9] value 0
|
||
|
# OPTIONS-NEXT: [ 11] option 1
|
||
|
# OPTIONS-NEXT: [ 1a] value 1
|
||
|
|
||
|
--- !ELF
|
||
|
FileHeader:
|
||
|
Class: ELFCLASS64
|
||
|
Data: ELFDATA2LSB
|
||
|
Type: ET_REL
|
||
|
Sections:
|
||
|
- Name: .linker-options1
|
||
|
Type: SHT_LLVM_LINKER_OPTIONS
|
||
|
Options:
|
||
|
- Name: option 0
|
||
|
Value: value 0
|
||
|
- Name: option 1
|
||
|
Value: value 1
|
||
|
- Name: .linker-options2
|
||
|
Type: SHT_LLVM_LINKER_OPTIONS
|
||
|
Content: "00112233"
|
||
|
- Name: .linker-options3
|
||
|
Type: SHT_LLVM_LINKER_OPTIONS
|
||
|
Size: 4
|
||
|
|
||
|
## Check that "Value" and "Name" fields are mandatory when using "Options" key.
|
||
|
|
||
|
# RUN: not yaml2obj --docnum=2 %s 2>&1 | FileCheck %s --check-prefix=NOVALUE
|
||
|
# RUN: not yaml2obj --docnum=3 %s 2>&1 | FileCheck %s --check-prefix=NONAME
|
||
|
|
||
|
# NOVALUE: error: missing required key 'Value'
|
||
|
# NONAME: error: missing required key 'Name'
|
||
|
|
||
|
--- !ELF
|
||
|
FileHeader:
|
||
|
Class: ELFCLASS64
|
||
|
Data: ELFDATA2LSB
|
||
|
Type: ET_REL
|
||
|
Sections:
|
||
|
- Name: .linker-options
|
||
|
Type: SHT_LLVM_LINKER_OPTIONS
|
||
|
Options:
|
||
|
- Name: name
|
||
|
|
||
|
--- !ELF
|
||
|
FileHeader:
|
||
|
Class: ELFCLASS64
|
||
|
Data: ELFDATA2LSB
|
||
|
Type: ET_REL
|
||
|
Sections:
|
||
|
- Name: .linker-options
|
||
|
Type: SHT_LLVM_LINKER_OPTIONS
|
||
|
Options:
|
||
|
- Value: value
|
||
|
|
||
|
## Check we can't use "Options" or "Size" keys together with the "Content" key.
|
||
|
|
||
|
# RUN: not yaml2obj %s -DOPTIONS="[]" -DCONTENT="''" --docnum=4 2>&1 | \
|
||
|
# RUN: FileCheck %s --check-prefix=TOGETHER
|
||
|
|
||
|
# RUN: not yaml2obj %s -DOPTIONS="[]" -DSIZE="0" --docnum=4 2>&1 | \
|
||
|
# RUN: FileCheck %s --check-prefix=TOGETHER
|
||
|
|
||
|
# TOGETHER: error: "Options" cannot be used with "Content" or "Size"
|
||
|
|
||
|
--- !ELF
|
||
|
FileHeader:
|
||
|
Class: ELFCLASS64
|
||
|
Data: ELFDATA2LSB
|
||
|
Type: ET_REL
|
||
|
Sections:
|
||
|
- Name: .linker-options
|
||
|
Type: SHT_LLVM_LINKER_OPTIONS
|
||
|
Options: [[OPTIONS=<none>]]
|
||
|
Content: [[CONTENT=<none>]]
|
||
|
Size: [[SIZE=<none>]]
|
||
|
|
||
|
## Check we can omit "Options", "Content" and "Size" keys. This produces an empty section.
|
||
|
|
||
|
# RUN: yaml2obj %s --docnum=4 2>&1 -o %t5
|
||
|
# RUN: llvm-readelf --sections %t5 | FileCheck %s --check-prefix=NONE
|
||
|
|
||
|
# NONE: [Nr] Name Type Address Off Size
|
||
|
# NONE: [ 1] .linker-options LLVM_LINKER_OPTIONS 0000000000000000 000040 000000
|
||
|
|
||
|
## Check we can use the "Content" key with the "Size" key when the size is greater
|
||
|
## than or equal to the content size.
|
||
|
|
||
|
# RUN: not yaml2obj --docnum=4 -DSIZE=1 -DCONTENT="'0011'" %s 2>&1 | \
|
||
|
# RUN: FileCheck %s --check-prefix=CONTENT-SIZE-ERR
|
||
|
|
||
|
# CONTENT-SIZE-ERR: error: Section size must be greater than or equal to the content size
|
||
|
|
||
|
# RUN: yaml2obj --docnum=4 -DSIZE=2 -DCONTENT="'0011'" %s -o %t.cont.size.eq.o
|
||
|
# RUN: llvm-readobj --sections --section-data %t.cont.size.eq.o | \
|
||
|
# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="0011"
|
||
|
|
||
|
# CHECK-CONTENT: Name: .linker-options (1)
|
||
|
# CHECK-CONTENT: SectionData (
|
||
|
# CHECK-CONTENT-NEXT: 0000: [[DATA]] |
|
||
|
# CHECK-CONTENT-NEXT: )
|
||
|
|
||
|
# RUN: yaml2obj --docnum=4 -DSIZE=3 -DCONTENT="'0011'" %s -o %t.cont.size.gr.o
|
||
|
# RUN: llvm-readobj --sections --section-data %t.cont.size.gr.o | \
|
||
|
# RUN: FileCheck %s --check-prefix=CHECK-CONTENT -DDATA="001100"
|