[llvm/test/Object] - Cleanup and move out the yaml2obj tests.

There are multiple yaml2obj-* tests in llvm/test/Object
folder. This is not correct place to have them and my intention
was to move them out to test\tools\yaml2obj folder. I reviewed
them, made some changes, and my comments are below.

For all tests I:

Added comments when needed.
Moved them from llvm/test/Object to yaml2obj tests.
Another changes performed:

1) yaml2obj-invalid.yaml. It was a test for an invalid YAML input.
I just moved it.

2) yaml2obj-coff-multi-doc.test/yaml2obj-elf-multi-doc.test:
these were a tests for testing --docnum=x functionality,
one was for COFF and one for ELF. I merged them into one.

3) yaml2obj-elf-bits-endian.test:
I removed its 4 YAML inputs (merged into the main test).

4) yaml2obj-readobj.test:
This file has a long history. It was added to check the
"parsing of header charactestics" initially. Then was used to test
how yaml2obj writes the relocations. Then was upgraded to check how
yaml2obj handle "-o" option. I think it should be heavily splitted
and refactored in a separate patch. For now I leaved it as is, but restyled
to reduce the changes in a follow-ups.

5) yaml2obj-elf-alignment.yaml: its intention was to check we
can set sh-addralign field. I moved, renamed (to elf-sh-addralign.yaml)
and updated this test.

6) yaml2obj-elf-file-headers.yaml: I removed it.
It's intention was to check that
yaml2obj handles OS/ABI and ELF type (e.g Relocatable).
We are testing this already, for example in D64800. We might want
to add a better (more complete) test, but keeping the existent test
does not have much sense I think.

7) yaml2obj-elf-file-headers-with-e_flags.yaml: I would describe its intention
as "testing MIPS e_flags". It is far from being complete and tests only
a few flags. I leaved it alone for now.

8) yaml2obj-elf-rel.yaml: its intention is to check the MIPS32 relocations.
We have a version for MIPS64 here: test\Object\Mips\elf-mips64-rel.yaml
Seems them both are incomplete. I leaved them alone for now.

9) yaml2obj-elf-rel-noref.yaml: was introduced to check the support of arm32
R_ARM_V4BX relocatiion. I leaved it alone for now.

10) yaml2obj-elf-section-basic.yaml: it just checked that we are able to recognise
trivial fields like section 'Name', 'Type', 'Flags' and others. All of our yaml2obj
tests are heavily using it. I just removed this test.

11) yaml2obj-elf-section-invalid-size.yaml: its intention was to check the
"Section size must be greater than or equal to the content size" error.
I moved this test to `tools\yaml2obj\section-size-content.yaml'

12) yaml2obj-elf-symbol-basic.yaml: its intention seems was to support declarations
of the symbols in yaml2obj. I removed it. We use this in almost each test we already have.

13) yaml2obj-elf-symbol-LocalGlobalWeak.yaml: its intention was to check that we can
declare different symbol bindings. I moved it to tools\yaml2obj\elf-symbol-binding.yaml.

14) yaml2obj-coff-invalid-alignment.test: check that error is reported for a too large coff
section alignment. Moved it to tools\yaml2obj\coff-invalid-alignment.test

15) yaml2obj-elf-symbol-visibility.yaml: tests ELF symbols visibility. I improved it and
moved to tools\yaml2obj\elf-symbol-visibility.yaml and tools\obj2yaml\elf-symbol-visibility.yaml

Differential revision: https://reviews.llvm.org/D65652

llvm-svn: 367988
This commit is contained in:
George Rimar 2019-08-06 08:02:25 +00:00
parent ebc2cf9c27
commit c056dd1502
22 changed files with 359 additions and 519 deletions

View File

@ -1,6 +0,0 @@
!ELF
FileHeader: !FileHeader
Class: ELFCLASS32
Data: ELFDATA2MSB
Type: ET_EXEC
Machine: EM_PPC

View File

@ -1,6 +0,0 @@
!ELF
FileHeader: !FileHeader
Class: ELFCLASS64
Data: ELFDATA2MSB
Type: ET_EXEC
Machine: EM_PPC64

View File

@ -1,6 +0,0 @@
!ELF
FileHeader: !FileHeader
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_386

View File

@ -1,6 +0,0 @@
!ELF
FileHeader: !FileHeader
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64

View File

@ -1,54 +0,0 @@
# Check that yaml2obj takes in account section AddressAlign field.
# RUN: yaml2obj %s > %t
# RUN: llvm-readobj -S %t | FileCheck %s
# CHECK: Section {
# CHECK: Index: 2
# CHECK-NEXT: Name: .data
# CHECK-NEXT: Type: SHT_PROGBITS
# CHECK-NEXT: Flags [
# CHECK-NEXT: SHF_ALLOC
# CHECK-NEXT: SHF_WRITE
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
# CHECK-NEXT: Offset: 0x{{[0-9A-F]*}}00
# CHECK-NEXT: Size: 4
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 256
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 8
Size: 4
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 256
Size: 4
Symbols:
- Name: T0
Type: STT_FUNC
Section: .text
Size: 4
Binding: STB_GLOBAL
- Name: D0
Type: STT_OBJECT
Section: .data
Size: 4
Binding: STB_GLOBAL
...

View File

@ -1,16 +0,0 @@
RUN: yaml2obj %p/Inputs/ELF/LE64.yaml | llvm-readobj --file-headers - | FileCheck %s --check-prefix LE64
RUN: yaml2obj %p/Inputs/ELF/BE64.yaml | llvm-readobj --file-headers - | FileCheck %s --check-prefix BE64
RUN: yaml2obj %p/Inputs/ELF/LE32.yaml | llvm-readobj --file-headers - | FileCheck %s --check-prefix LE32
RUN: yaml2obj %p/Inputs/ELF/BE32.yaml | llvm-readobj --file-headers - | FileCheck %s --check-prefix BE32
LE64: Class: 64-bit (0x2)
LE64-NEXT: DataEncoding: LittleEndian (0x1)
BE64: Class: 64-bit (0x2)
BE64-NEXT: DataEncoding: BigEndian (0x2)
LE32: Class: 32-bit (0x1)
LE32-NEXT: DataEncoding: LittleEndian (0x1)
BE32: Class: 32-bit (0x1)
BE32-NEXT: DataEncoding: BigEndian (0x2)

View File

@ -1,11 +0,0 @@
# RUN: yaml2obj %s | llvm-readobj --file-headers - | FileCheck %s
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
OSABI: ELFOSABI_GNU
Type: ET_REL
Machine: EM_X86_64
# CHECK: OS/ABI: GNU/Linux
# CHECK: Type: Relocatable

View File

@ -1,56 +0,0 @@
# RUN: yaml2obj -docnum=1 %s \
# RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC1 %s
# RUN: yaml2obj -docnum=2 %s \
# RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC2 %s
# RUN: not yaml2obj -docnum=3 %s 2>&1 \
# RUN: | FileCheck -check-prefix=DOC3 %s
# DOC1: Name: T1 (1)
# DOC2: Name: T2 (1)
# DOC3: yaml2obj: Cannot find the 3rd document
--- !ELF
FileHeader: !FileHeader
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [EF_MIPS_CPIC]
Sections:
- Name: .text
Type: SHT_PROGBITS
Content: "0000000000000000"
AddressAlign: 16
Flags: [SHF_EXECINSTR, SHF_ALLOC]
Symbols:
- Name: T1
Section: .text
Type: STT_FUNC
Value: 0x0
Size: 8
Binding: STB_GLOBAL
--- !ELF
FileHeader: !FileHeader
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Sections:
- Name: .text
Type: SHT_PROGBITS
Content: "00000000"
AddressAlign: 16
Flags: [SHF_EXECINSTR, SHF_ALLOC]
Symbols:
- Name: T2
Section: .text
Type: STT_FUNC
Value: 0x0
Size: 4
Binding: STB_GLOBAL
...

View File

@ -1,79 +0,0 @@
# RUN: yaml2obj %s | llvm-readobj --sections --section-data - | FileCheck %s
# RUN: yaml2obj -o %t %s
# RUN: llvm-readobj --sections --section-data %t | FileCheck %s
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0xCAFEBABE
Link: .text # Doesn't make sense for SHT_PROGBITS, but good enough for test.
Content: EBFE
AddressAlign: 2
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0xCAFECAFE
Content: FEBF
Size: 8
AddressAlign: 2
# CHECK: Section {
# CHECK: Index: 0
# CHECK: Type: SHT_NULL (0x0)
#
# CHECK: Section {
# CHECK: Name: .text
# CHECK: Type: SHT_PROGBITS (0x1)
# CHECK-NEXT: Flags [ (0x6)
# CHECK-NEXT: SHF_ALLOC (0x2)
# CHECK-NEXT: SHF_EXECINSTR (0x4)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0xCAFEBABE
# CHECK: Size: 2
# Check that Link != 0.
# CHECK: Link: {{[1-9][0-9]*}}
# CHECK: AddressAlignment: 2
# CHECK: SectionData (
# CHECK-NEXT: 0000: EBFE
# CHECK-NEXT: )
#
# CHECK: Section {
# CHECK: Name: .data
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)
# CHECK-NEXT: Flags [ (0x2)
# CHECK-NEXT: SHF_ALLOC (0x2)
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0xCAFECAFE
# CHECK-NEXT: Offset: 0x{{[0-9A-F]+}}
# CHECK-NEXT: Size: 8
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 2
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: SectionData (
# CHECK-NEXT: 0000: FEBF0000 00000000 |........|
# CHECK-NEXT: )
#
# CHECK: Section {
# CHECK: Name: .symtab (25)
# CHECK: Type: SHT_SYMTAB (0x2)
# CHECK: AddressAlignment: 8
# CHECK: }
# CHECK: Section {
# CHECK: Name: .strtab (17)
# CHECK: Type: SHT_STRTAB (0x3)
# CHECK: AddressAlignment: 1
# CHECK: }
# CHECK: Section {
# CHECK: Name: .shstrtab (7)
# CHECK: Type: SHT_STRTAB (0x3)
# CHECK: AddressAlignment: 1
# CHECK: }

View File

@ -1,26 +0,0 @@
# RUN: not yaml2obj -o %t %s 2>&1 | FileCheck %s
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Content: EBFE
AddressAlign: 2
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Content: 0000000000000000
Size: 2
# CHECK: YAML:17:5: error: Section size must be greater than or equal to the content size
# CHECK-NEXT: - Name: .data
# CHECK-NEXT: ^
# CHECK-NEXT: yaml2obj: Failed to parse YAML file!

View File

@ -1,42 +0,0 @@
# RUN: yaml2obj %s | llvm-readobj --symbols - | FileCheck %s
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x4
Content: "90EBFE" # x86 machine code
# NOP ; To make main's `Value` non-zero (for testing).
# main:
# JMP -2 ; (infloop)
# This YAML file is a valid relocatable object that,
# when linked and run on x86_64, will go into an
# infloop.
Symbols:
- Name: main
Type: STT_FUNC
Section: .text
Value: 0x1
Size: 2
Binding: STB_GLOBAL
- Name: undefined_symbol
Binding: STB_GLOBAL
# CHECK: Symbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: (0)
# CHECK: Symbol {
# CHECK-NEXT: Name: main
# CHECK-NEXT: Value: 0x1
# CHECK-NEXT: Size: 2
# CHECK: Binding: Global
# CHECK-NEXT: Type: Function
# CHECK: Section: .text
# CHECK: Symbol {
# CHECK: Name: undefined_symbol
# CHECK: Section: Undefined (0x0)

View File

@ -1,144 +0,0 @@
# RUN: yaml2obj %s | llvm-readobj --symbols - | \
# RUN: FileCheck --check-prefix OBJ %s
# RUN: yaml2obj %s | obj2yaml - | FileCheck --check-prefix YAML %s
# OBJ: Symbol {
# OBJ: Name: default1 (36)
# OBJ-NEXT: Value: 0x0
# OBJ-NEXT: Size: 4
# OBJ-NEXT: Binding: Global (0x1)
# OBJ-NEXT: Type: Object (0x1)
# OBJ-NEXT: Other: 0
# OBJ-NEXT: Section: .data (0x1)
# OBJ-NEXT: }
# OBJ-NEXT: Symbol {
# OBJ-NEXT: Name: default2 (27)
# OBJ-NEXT: Value: 0x4
# OBJ-NEXT: Size: 4
# OBJ-NEXT: Binding: Global (0x1)
# OBJ-NEXT: Type: Object (0x1)
# OBJ-NEXT: Other: 0
# OBJ-NEXT: Section: .data (0x1)
# OBJ-NEXT: }
# OBJ-NEXT: Symbol {
# OBJ-NEXT: Name: internal (8)
# OBJ-NEXT: Value: 0x8
# OBJ-NEXT: Size: 4
# OBJ-NEXT: Binding: Global (0x1)
# OBJ-NEXT: Type: Object (0x1)
# OBJ-NEXT: Other [ (0x1)
# OBJ-NEXT: STV_INTERNAL
# OBJ-NEXT: ]
# OBJ-NEXT: Section: .data (0x1)
# OBJ-NEXT: }
# OBJ-NEXT: Symbol {
# OBJ-NEXT: Name: hidden (1)
# OBJ-NEXT: Value: 0xC
# OBJ-NEXT: Size: 4
# OBJ-NEXT: Binding: Global (0x1)
# OBJ-NEXT: Type: Object (0x1)
# OBJ-NEXT: Other [ (0x2)
# OBJ-NEXT: STV_HIDDEN
# OBJ-NEXT: ]
# OBJ-NEXT: Section: .data (0x1)
# OBJ-NEXT: }
# OBJ-NEXT: Symbol {
# OBJ-NEXT: Name: protected (17)
# OBJ-NEXT: Value: 0x10
# OBJ-NEXT: Size: 4
# OBJ-NEXT: Binding: Global (0x1)
# OBJ-NEXT: Type: Object (0x1)
# OBJ-NEXT: Other [ (0xA3)
# OBJ-NEXT: STO_MIPS_MICROMIPS
# OBJ-NEXT: STO_MIPS_PIC
# OBJ-NEXT: STV_PROTECTED
# OBJ-NEXT: ]
# OBJ-NEXT: Section: .data (0x1)
# OBJ-NEXT: }
# YAML: Symbols:
# YAML-NEXT: - Name: default1
# YAML-NEXT: Type: STT_OBJECT
# YAML-NEXT: Section: .data
# YAML-NEXT: Binding: STB_GLOBAL
# YAML-NEXT: Size: 0x0000000000000004
# YAML-NEXT: - Name: default2
# YAML-NEXT: Type: STT_OBJECT
# YAML-NEXT: Section: .data
# YAML-NEXT: Binding: STB_GLOBAL
# YAML-NEXT: Value: 0x0000000000000004
# YAML-NEXT: Size: 0x0000000000000004
# YAML-NEXT: - Name: internal
# YAML-NEXT: Type: STT_OBJECT
# YAML-NEXT: Section: .data
# YAML-NEXT: Binding: STB_GLOBAL
# YAML-NEXT: Value: 0x0000000000000008
# YAML-NEXT: Size: 0x0000000000000004
# YAML-NEXT: Visibility: STV_INTERNAL
# YAML-NEXT: - Name: hidden
# YAML-NEXT: Type: STT_OBJECT
# YAML-NEXT: Section: .data
# YAML-NEXT: Binding: STB_GLOBAL
# YAML-NEXT: Value: 0x000000000000000C
# YAML-NEXT: Size: 0x0000000000000004
# YAML-NEXT: Visibility: STV_HIDDEN
# YAML-NEXT: - Name: protected
# YAML-NEXT: Type: STT_OBJECT
# YAML-NEXT: Section: .data
# YAML-NEXT: Binding: STB_GLOBAL
# YAML-NEXT: Value: 0x0000000000000010
# YAML-NEXT: Size: 0x0000000000000004
# YAML-NEXT: Visibility: STV_PROTECTED
# YAML-NEXT: Other: [ STO_MIPS_PIC, STO_MIPS_MICROMIPS ]
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ]
Sections:
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_WRITE ]
AddressAlign: 0x04
Size: 0x14
Symbols:
- Name: default1
Type: STT_OBJECT
Visibility: STV_DEFAULT
Section: .data
Value: 0x00
Size: 0x04
Binding: STB_GLOBAL
- Name: default2
Type: STT_OBJECT
Section: .data
Value: 0x04
Size: 0x04
Binding: STB_GLOBAL
- Name: internal
Type: STT_OBJECT
Visibility: STV_INTERNAL
Section: .data
Value: 0x08
Size: 0x04
Binding: STB_GLOBAL
- Name: hidden
Type: STT_OBJECT
Visibility: STV_HIDDEN
Section: .data
Value: 0x0C
Size: 0x04
Binding: STB_GLOBAL
- Name: protected
Type: STT_OBJECT
Visibility: STV_PROTECTED
Other: [ STO_MIPS_MICROMIPS, STO_MIPS_PIC ]
Section: .data
Value: 0x10
Size: 0x04
Binding: STB_GLOBAL

View File

@ -1,31 +1,125 @@
RUN: yaml2obj %p/Inputs/COFF/i386.yaml | llvm-readobj --file-headers -r --expand-relocs - | FileCheck %s --check-prefix COFF-I386
RUN: yaml2obj -o %t %p/Inputs/COFF/i386.yaml
RUN: llvm-readobj --file-headers -r --expand-relocs %t \
RUN: | FileCheck %s --check-prefix COFF-I386
# RUN: yaml2obj %s | llvm-readobj --file-headers -r --expand-relocs - | FileCheck %s --check-prefix COFF-I386
# RUN: yaml2obj -o %t %s
# RUN: llvm-readobj --file-headers -r --expand-relocs %t | FileCheck %s --check-prefix COFF-I386
// COFF-I386: Characteristics [ (0x200)
// COFF-I386-NEXT: IMAGE_FILE_DEBUG_STRIPPED (0x200)
// COFF-I386-NEXT: ]
# COFF-I386: Characteristics [ (0x200)
# COFF-I386-NEXT: IMAGE_FILE_DEBUG_STRIPPED (0x200)
# COFF-I386-NEXT: ]
// COFF-I386: Relocations [
// COFF-I386-NEXT: Section (1) .text {
// COFF-I386-NEXT: Relocation {
// COFF-I386-NEXT: Offset: 0xE
// COFF-I386-NEXT: Type: IMAGE_REL_I386_DIR32 (6)
// COFF-I386-NEXT: Symbol: L_.str
// COFF-I386-NEXT: SymbolIndex: 5
// COFF-I386-NEXT: }
// COFF-I386-NEXT: Relocation {
// COFF-I386-NEXT: Offset: 0x13
// COFF-I386-NEXT: Type: IMAGE_REL_I386_REL32 (20)
// COFF-I386-NEXT: Symbol: _puts
// COFF-I386-NEXT: SymbolIndex: 6
// COFF-I386-NEXT: }
// COFF-I386-NEXT: Relocation {
// COFF-I386-NEXT: Offset: 0x18
// COFF-I386-NEXT: Type: IMAGE_REL_I386_REL32 (20)
// COFF-I386-NEXT: Symbol: _SomeOtherFunction
// COFF-I386-NEXT: SymbolIndex: 7
// COFF-I386-NEXT: }
// COFF-I386-NEXT: }
// COFF-I386-NEXT: ]
# COFF-I386: Relocations [
# COFF-I386-NEXT: Section (1) .text {
# COFF-I386-NEXT: Relocation {
# COFF-I386-NEXT: Offset: 0xE
# COFF-I386-NEXT: Type: IMAGE_REL_I386_DIR32 (6)
# COFF-I386-NEXT: Symbol: L_.str
# COFF-I386-NEXT: SymbolIndex: 5
# COFF-I386-NEXT: }
# COFF-I386-NEXT: Relocation {
# COFF-I386-NEXT: Offset: 0x13
# COFF-I386-NEXT: Type: IMAGE_REL_I386_REL32 (20)
# COFF-I386-NEXT: Symbol: _puts
# COFF-I386-NEXT: SymbolIndex: 6
# COFF-I386-NEXT: }
# COFF-I386-NEXT: Relocation {
# COFF-I386-NEXT: Offset: 0x18
# COFF-I386-NEXT: Type: IMAGE_REL_I386_REL32 (20)
# COFF-I386-NEXT: Symbol: _SomeOtherFunction
# COFF-I386-NEXT: SymbolIndex: 7
# COFF-I386-NEXT: }
# COFF-I386-NEXT: }
# COFF-I386-NEXT: ]
!COFF
header: !Header
Machine: IMAGE_FILE_MACHINE_I386 # (0x14c)
Characteristics: [ IMAGE_FILE_DEBUG_STRIPPED ]
sections:
- !Section
Name: .text
Alignment: 16
Characteristics: [IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ, ] # 0x60500020
SectionData: !hex "83EC0CC744240800000000C7042400000000E800000000E8000000008B44240883C40CC3" # |....D$.......$...............D$.....|
Relocations:
- !Relocation
VirtualAddress: 0xe
SymbolName: L_.str
Type: IMAGE_REL_I386_DIR32
- !Relocation
VirtualAddress: 0x13
SymbolName: _puts
Type: IMAGE_REL_I386_REL32
- !Relocation
VirtualAddress: 0x18
SymbolName: _SomeOtherFunction
Type: IMAGE_REL_I386_REL32
- !Section
Name: .data
Alignment: 1
Characteristics: [IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE, ] # 0xc0100040
SectionData: !hex "48656C6C6F20576F726C642100" # |Hello World!.|
symbols:
- !Symbol
Name: .text
Value: 0
SectionNumber: 1
SimpleType: IMAGE_SYM_TYPE_NULL # (0)
ComplexType: IMAGE_SYM_DTYPE_NULL # (0)
StorageClass: IMAGE_SYM_CLASS_STATIC # (3)
SectionDefinition:
Length: 36
NumberOfRelocations: 3
NumberOfLinenumbers: 0
CheckSum: 0
Number: 1
- !Symbol
Name: .data
Value: 0
SectionNumber: 2
SimpleType: IMAGE_SYM_TYPE_NULL # (0)
ComplexType: IMAGE_SYM_DTYPE_NULL # (0)
StorageClass: IMAGE_SYM_CLASS_STATIC # (3)
SectionDefinition:
Length: 13
NumberOfRelocations: 0
NumberOfLinenumbers: 0
CheckSum: 0
Number: 2
- !Symbol
Name: _main
Value: 0
SectionNumber: 1
SimpleType: IMAGE_SYM_TYPE_NULL # (0)
ComplexType: IMAGE_SYM_DTYPE_FUNCTION # (2)
StorageClass: IMAGE_SYM_CLASS_EXTERNAL # (2)
- !Symbol
Name: L_.str
Value: 0
SectionNumber: 2
SimpleType: IMAGE_SYM_TYPE_NULL # (0)
ComplexType: IMAGE_SYM_DTYPE_NULL # (0)
StorageClass: IMAGE_SYM_CLASS_STATIC # (3)
- !Symbol
Name: _puts
Value: 0
SectionNumber: 0
SimpleType: IMAGE_SYM_TYPE_NULL # (0)
ComplexType: IMAGE_SYM_DTYPE_NULL # (0)
StorageClass: IMAGE_SYM_CLASS_EXTERNAL # (2)
- !Symbol
Name: _SomeOtherFunction
Value: 0
SectionNumber: 0
SimpleType: IMAGE_SYM_TYPE_NULL # (0)
ComplexType: IMAGE_SYM_DTYPE_NULL # (0)
StorageClass: IMAGE_SYM_CLASS_EXTERNAL # (2)

View File

@ -0,0 +1,35 @@
## Check obj2yaml is able to dump the Visibility field correctly.
# RUN: yaml2obj %s | obj2yaml - | FileCheck %s
# CHECK: --- !ELF
# CHECK-NEXT: FileHeader:
# CHECK-NEXT: Class: ELFCLASS64
# CHECK-NEXT: Data: ELFDATA2LSB
# CHECK-NEXT: Type: ET_REL
# CHECK-NEXT: Machine: EM_X86_64
# CHECK-NEXT: Symbols:
# CHECK-NEXT: - Name: default
# CHECK-NEXT: - Name: internal
# CHECK-NEXT: Visibility: STV_INTERNAL
# CHECK-NEXT: - Name: hidden
# CHECK-NEXT: Visibility: STV_HIDDEN
# CHECK-NEXT: - Name: protected
# CHECK-NEXT: Visibility: STV_PROTECTED
# CHECK-NEXT: ...
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Symbols:
- Name: default
Visibility: STV_DEFAULT
- Name: internal
Visibility: STV_INTERNAL
- Name: hidden
Visibility: STV_HIDDEN
- Name: protected
Visibility: STV_PROTECTED

View File

@ -1,6 +1,6 @@
# RUN: not yaml2obj %s 2>&1 | FileCheck %s
# CHECK: Section alignment is too large
## CHECK: Section alignment is too large
--- !COFF
header:

View File

@ -0,0 +1,46 @@
## Check we can produce 32/64 bits outputs with a different endianness.
# RUN: yaml2obj %s --docnum=1 | llvm-readobj --file-headers - | FileCheck %s --check-prefix LE64
# RUN: yaml2obj %s --docnum=2 | llvm-readobj --file-headers - | FileCheck %s --check-prefix BE64
# RUN: yaml2obj %s --docnum=3 | llvm-readobj --file-headers - | FileCheck %s --check-prefix LE32
# RUN: yaml2obj %s --docnum=4 | llvm-readobj --file-headers - | FileCheck %s --check-prefix BE32
# LE64: Class: 64-bit (0x2)
# LE64-NEXT: DataEncoding: LittleEndian (0x1)
# BE64: Class: 64-bit (0x2)
# BE64-NEXT: DataEncoding: BigEndian (0x2)
# LE32: Class: 32-bit (0x1)
# LE32-NEXT: DataEncoding: LittleEndian (0x1)
# BE32: Class: 32-bit (0x1)
# BE32-NEXT: DataEncoding: BigEndian (0x2)
--- !ELF
FileHeader: !FileHeader
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
--- !ELF
FileHeader: !FileHeader
Class: ELFCLASS64
Data: ELFDATA2MSB
Type: ET_EXEC
Machine: EM_PPC64
--- !ELF
FileHeader: !FileHeader
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_386
--- !ELF
FileHeader: !FileHeader
Class: ELFCLASS32
Data: ELFDATA2MSB
Type: ET_EXEC
Machine: EM_PPC

View File

@ -0,0 +1,30 @@
## Check that yaml2obj takes in account section AddressAlign field.
# RUN: yaml2obj %s > %t
# RUN: llvm-readobj -S %t | FileCheck %s
# CHECK: Section {
# CHECK: Index:
# CHECK: Name: .data
# CHECK-NEXT: Type: SHT_PROGBITS
# CHECK-NEXT: Flags [
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
# CHECK-NEXT: Offset: 0x{{[0-9A-F]*}}00
# CHECK-NEXT: Size:
# CHECK-NEXT: Link:
# CHECK-NEXT: Info:
# CHECK-NEXT: AddressAlignment: 256
# CHECK-NEXT: EntrySize:
# CHECK-NEXT: }
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .data
Type: SHT_PROGBITS
AddressAlign: 256

View File

@ -1,26 +1,22 @@
## Check we can set different bindings for symbols.
# RUN: yaml2obj %s | llvm-readobj --symbols - | FileCheck %s
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_WRITE ]
Content: "DEADBEEF"
Symbols:
- Name: local_symbol
Type: STT_OBJECT
Section: .data
Binding: STB_LOCAL
- Name: global_symbol
Type: STT_OBJECT
Section: .data
Binding: STB_GLOBAL
- Name: weak_symbol
Type: STT_OBJECT
Section: .data
Binding: STB_WEAK
# CHECK: Symbol {

View File

@ -0,0 +1,62 @@
## Check yaml2obj is able to parse the Visibility field and produce the output.
# RUN: yaml2obj %s | llvm-readobj --symbols - | FileCheck --check-prefix OBJ %s
# OBJ: Symbol {
# OBJ: Name: default (1)
# OBJ-NEXT: Value: 0x0
# OBJ-NEXT: Size: 0
# OBJ-NEXT: Binding: Local (0x0)
# OBJ-NEXT: Type: None (0x0)
# OBJ-NEXT: Other: 0
# OBJ-NEXT: Section: Undefined (0x0)
# OBJ-NEXT: }
# OBJ-NEXT: Symbol {
# OBJ-NEXT: Name: internal (16)
# OBJ-NEXT: Value: 0x0
# OBJ-NEXT: Size: 0
# OBJ-NEXT: Binding: Local (0x0)
# OBJ-NEXT: Type: None (0x0)
# OBJ-NEXT: Other [ (0x1)
# OBJ-NEXT: STV_INTERNAL (0x1)
# OBJ-NEXT: ]
# OBJ-NEXT: Section: Undefined (0x0)
# OBJ-NEXT: }
# OBJ-NEXT: Symbol {
# OBJ-NEXT: Name: hidden (9)
# OBJ-NEXT: Value: 0x0
# OBJ-NEXT: Size: 0
# OBJ-NEXT: Binding: Local (0x0)
# OBJ-NEXT: Type: None (0x0)
# OBJ-NEXT: Other [ (0x2)
# OBJ-NEXT: STV_HIDDEN (0x2)
# OBJ-NEXT: ]
# OBJ-NEXT: Section: Undefined (0x0)
# OBJ-NEXT: }
# OBJ-NEXT: Symbol {
# OBJ-NEXT: Name: protected (25)
# OBJ-NEXT: Value: 0x0
# OBJ-NEXT: Size: 0
# OBJ-NEXT: Binding: Local (0x0)
# OBJ-NEXT: Type: None (0x0)
# OBJ-NEXT: Other [ (0x3)
# OBJ-NEXT: STV_PROTECTED (0x3)
# OBJ-NEXT: ]
# OBJ-NEXT: Section: Undefined (0x0)
# OBJ-NEXT: }
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Symbols:
- Name: default
Visibility: STV_DEFAULT
- Name: internal
Visibility: STV_INTERNAL
- Name: hidden
Visibility: STV_HIDDEN
- Name: protected
Visibility: STV_PROTECTED

View File

@ -1,4 +1,4 @@
AAA: | BBB
# RUN: not yaml2obj %s 2>&1 | FileCheck %s
# CHECK: Map value must not be empty
AAA: | BBB

View File

@ -1,13 +1,41 @@
## Check we are able to have multiple YAMLs in a file and switch between
## them using --docnum=x option.
# RUN: yaml2obj -docnum=1 %s \
# RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC1 %s
# RUN: yaml2obj -docnum=2 %s \
# RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC2 %s
# RUN: not yaml2obj -docnum=3 %s 2>&1 \
# RUN: | FileCheck -check-prefix=DOC3 %s
# RUN: yaml2obj -docnum=3 %s \
# RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC3 %s
# RUN: yaml2obj -docnum=4 %s \
# RUN: | llvm-readobj --symbols - | FileCheck -check-prefix=DOC4 %s
# RUN: not yaml2obj -docnum=5 %s 2>&1 \
# RUN: | FileCheck -check-prefix=DOC5 %s
# DOC1: Name: _sym1
# DOC2: Name: _sym2
# DOC3: yaml2obj: Cannot find the 3rd document
# DOC3: Name: _sym3
# DOC4: Name: _sym4
# DOC5: yaml2obj: Cannot find the 5th document
--- !ELF
FileHeader: !FileHeader
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [EF_MIPS_CPIC]
Symbols:
- Name: _sym1
--- !ELF
FileHeader: !FileHeader
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_386
Symbols:
- Name: _sym2
--- !COFF
header:
@ -20,7 +48,6 @@ sections:
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE,
IMAGE_SCN_MEM_READ ]
SectionData: "00000000"
symbols:
- Name: .text
Value: 0
@ -34,15 +61,7 @@ symbols:
NumberOfLinenumbers: 0
CheckSum: 0
Number: 1
- Name: _main
Value: 0
SectionNumber: 1
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_FUNCTION
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
- Name: _sym1
- Name: _sym3
Value: 0
SectionNumber: 0
SimpleType: IMAGE_SYM_TYPE_NULL
@ -60,7 +79,6 @@ sections:
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE,
IMAGE_SCN_MEM_READ ]
SectionData: "00000000"
symbols:
- Name: .text
Value: 0
@ -74,18 +92,9 @@ symbols:
NumberOfLinenumbers: 0
CheckSum: 0
Number: 1
- Name: _main
Value: 0
SectionNumber: 1
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_FUNCTION
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
- Name: _sym2
- Name: _sym4
Value: 0
SectionNumber: 0
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
...

View File

@ -156,3 +156,23 @@ FileHeader:
Sections:
- Name: .foo
Type: SHT_PROGBITS
# RUN: not yaml2obj --docnum=7 %s 2>&1 | FileCheck %s --check-prefix=ERR2
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_X86_64
Sections:
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Content: 0000000000000000
Size: 2
# ERR2: error: Section size must be greater than or equal to the content size
# ERR2-NEXT: - Name: .data
# ERR2-NEXT: ^
# ERR2-NEXT: yaml2obj: Failed to parse YAML file!