llvm-project/llvm/test/Object/yaml2obj-readobj.test

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

126 lines
3.6 KiB
Plaintext
Raw Normal View History

[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
2019-08-06 16:02:25 +08:00
# 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: 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)