[yaml2obj][test] Move tests to binary format specific subdirectories

Create COFF/, ELF/, and Minidump and move tests there.

Also

* Rename `*.test` to `*.yaml`
* For yaml2obj RUN lines, use `-o %t` instead of `> %t` for consistency.
  We still have tests that check stdout is the default output, e.g.
  multi-doc.test
* Update tests to consistently use `##` for comments.
  `#` is for RUN and CHECK lines.
* Merge symboless-relocation.yaml and invalid-symboless-relocation.yaml to ELF/relocation-implicit-symbol-index.test

Reviewed By: grimar, jhenderson

Differential Revision: https://reviews.llvm.org/D70264
This commit is contained in:
Fangrui Song 2019-11-18 09:06:14 -08:00
parent ed8afd9f6e
commit 053d07b664
86 changed files with 93 additions and 102 deletions

View File

@ -9,7 +9,7 @@
# ROUNDTRIP: VirtualAddress: 12288
--- !COFF
OptionalHeader:
OptionalHeader:
AddressOfEntryPoint: 4096
ImageBase: 1073741824
SectionAlignment: 4096
@ -26,55 +26,55 @@ OptionalHeader:
SizeOfStackCommit: 4096
SizeOfHeapReserve: 1048576
SizeOfHeapCommit: 4096
ExportTable:
ExportTable:
RelativeVirtualAddress: 0
Size: 0
ImportTable:
ImportTable:
RelativeVirtualAddress: 0
Size: 0
ResourceTable:
ResourceTable:
RelativeVirtualAddress: 0
Size: 0
ExceptionTable:
ExceptionTable:
RelativeVirtualAddress: 12288
Size: 8
CertificateTable:
CertificateTable:
RelativeVirtualAddress: 0
Size: 0
BaseRelocationTable:
BaseRelocationTable:
RelativeVirtualAddress: 0
Size: 0
Debug:
Debug:
RelativeVirtualAddress: 0
Size: 0
Architecture:
Architecture:
RelativeVirtualAddress: 0
Size: 0
GlobalPtr:
GlobalPtr:
RelativeVirtualAddress: 0
Size: 0
TlsTable:
TlsTable:
RelativeVirtualAddress: 0
Size: 0
LoadConfigTable:
LoadConfigTable:
RelativeVirtualAddress: 0
Size: 0
BoundImport:
BoundImport:
RelativeVirtualAddress: 0
Size: 0
IAT:
IAT:
RelativeVirtualAddress: 0
Size: 0
DelayImportDescriptor:
DelayImportDescriptor:
RelativeVirtualAddress: 0
Size: 0
ClrRuntimeHeader:
ClrRuntimeHeader:
RelativeVirtualAddress: 0
Size: 0
header:
header:
Machine: IMAGE_FILE_MACHINE_ARM64
Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE ]
sections:
sections:
- Name: .text
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
VirtualAddress: 4096

View File

@ -11,4 +11,4 @@ sections:
Characteristics: []
SectionData: 00
Alignment: 16384
symbols:
symbols: []

View File

@ -10,11 +10,11 @@
# RELOCS-NEXT: }
# RELOCS-NEXT: ]
# Check that we usually output relocations with SymbolName.
# For relocations with a non-unique symbol name, output
# SymbolTableIndex instead.
## Check that we usually output relocations with SymbolName.
## For relocations with a non-unique symbol name, output
## SymbolTableIndex instead.
# YAML: Relocations:
# YAML: Relocations:
# YAML-NEXT: - VirtualAddress: 3
# YAML-NEXT: SymbolTableIndex: 0
# YAML-NEXT: Type: IMAGE_REL_AMD64_REL32
@ -26,15 +26,15 @@
# YAML-NEXT: Type: IMAGE_REL_AMD64_REL32
--- !COFF
header:
header:
Machine: IMAGE_FILE_MACHINE_AMD64
Characteristics: [ ]
sections:
sections:
- Name: .text
Characteristics: [ ]
Alignment: 4
SectionData: 488B0500000000488B0500000000488B0500000000
Relocations:
Relocations:
- VirtualAddress: 3
SymbolTableIndex: 0
Type: IMAGE_REL_AMD64_REL32
@ -52,7 +52,7 @@ sections:
Characteristics: [ ]
Alignment: 1
SectionData: '01'
symbols:
symbols:
- Name: .rdata
Value: 0
SectionNumber: 2

View File

@ -1,9 +1,9 @@
## Check we are able to parse/emit the ABI version with yaml2obj/obj2yaml.
# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj --file-headers %t | FileCheck %s --check-prefix=FROMYAML
# RUN: obj2yaml %t | FileCheck %s --check-prefix=TOYAML
## Check we are able to parse/emit the ABI version with yaml2obj/obj2yaml.
# FROMYAML: ABIVersion: 5
# TOYAML: ABIVersion: 0x05

View File

@ -159,7 +159,7 @@ Sections:
- Name: '.group [1]'
Type: SHT_GROUP
Info: 'foo [1]'
Members:
Members:
- SectionOrType: GRP_COMDAT
- SectionOrType: '.text.foo [1]'
- Name: '.text.foo [1]'

View File

@ -1,5 +1,5 @@
# Show that yaml2obj can handle a dynamic section with raw content instead of
# entries. Also show that it rejects raw content when entries are also provided.
## Show that yaml2obj can handle a dynamic section with raw content instead of
## entries. Also show that it rejects raw content when entries are also provided.
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readobj -x .dynamic --sections %t1 | FileCheck %s --check-prefix=RAW

View File

@ -1,4 +1,5 @@
# Ensures that dynamic section has sh_entsize correctly set
## Ensures that dynamic section has sh_entsize correctly set.
# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix=SECTION

View File

@ -51,12 +51,12 @@ DynamicSymbols:
# NUM-SAME: .data (0x1)
# NUM: Name: bar
# NUM: Section:
# NUM: Section:
# NUM-SAME: .strtab (0x2)
# NUM: Name: zed
# NUM: warning: '[[FILE]]': invalid section index: 255
# NUM: Section:
# NUM: Section:
# NUM-SAME: <?> (0xFF)
--- !ELF

View File

@ -0,0 +1,12 @@
## Ensure yaml2obj doesn't error on empty optional mappings, such as Symbols
# RUN: yaml2obj %s -o /dev/null
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
## We usually express this as `Symbols: []`, but here we show that the value
## can be omitted.
Symbols:

View File

@ -86,7 +86,7 @@ Sections:
# RUN: not yaml2obj %s --docnum=4 2>&1 | FileCheck %s --check-prefix=BOTH
# BOTH: error: "Options" and "Content" can't be used together
--- !ELF
FileHeader:
Class: ELFCLASS64

View File

@ -1,6 +1,6 @@
# Check we correctly set the sh_info field of .symtab section.
# A symbol table section's sh_info section header member holds
# the symbol table index for the first non-local symbol.
## Check we correctly set the sh_info field of .symtab section.
## A symbol table section's sh_info section header member holds
## the symbol table index for the first non-local symbol.
# RUN: yaml2obj -docnum=1 %s -o %t
# RUN: llvm-readobj --sections %t | FileCheck %s --check-prefix=ONE

View File

@ -5,7 +5,7 @@
# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE1
# CASE1: Section Headers:
# CASE1-NEXT: [Nr] Name Type Address Off Size
# CASE1-NEXT: [Nr] Name Type Address Off Size
# CASE1-NEXT: [ 0] NULL 0000000000000000 000000 000000
# CASE1-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000040 000001
# CASE1-NEXT: [ 2] .symtab SYMTAB 0000000000000000 000058 000002

View File

@ -1,5 +1,5 @@
# Show that yaml2obj properly emits program headers with explicit file size,
# memory size and offset parameters.
## Show that yaml2obj properly emits program headers with explicit file size,
## memory size and offset parameters.
# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj %t --program-headers | FileCheck %s

View File

@ -1,7 +1,8 @@
# Test that a relocation's symbol can be an integer.
# RUN: yaml2obj %s > %t
# LLVM tools (both llvm-readobj and llvm-objdump) reject relocations with
# invalid symbol indexes, so inspect the hex contents instead.
## Test that a relocation's symbol can be an integer (symbol index).
# RUN: yaml2obj %s -o %t
## LLVM tools (both llvm-readobj and llvm-objdump) reject relocations with
## invalid symbol indexes, so inspect the hex contents instead.
# RUN: llvm-readobj -x .rela.text %t | FileCheck %s
# CHECK: Hex dump of section '.rela.text':

View File

@ -1,8 +1,15 @@
# This test succeeds but produces an invalid relocation. This test
# documents this behavoir.
# RUN: yaml2obj %s > %t
## If "Symbol" is not specified for a relocation, the symbol index is assumed to be 0.
# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj -r %t | FileCheck %s
# CHECK: Relocations [
# CHECK-NEXT: Section (2) .rel.text {
# CHECK-NEXT: 0x1000 R_X86_64_RELATIVE - 0x0
# CHECK-NEXT: 0x1001 R_X86_64_PC32 - 0x0
# CHECK-NEXT: }
# CHECK-NEXT:]
!ELF
FileHeader:
Class: ELFCLASS64
@ -19,10 +26,7 @@ Sections:
Info: .text
Relocations:
- Offset: 0x1000
Type: R_X86_64_RELATIVE
## R_X86_64_PC32 should have a non-zero symbol index but we don't error.
- Offset: 0x1001
Type: R_X86_64_PC32
#CHECK: Relocations [
#CHECK-NEXT: Section (2) .rel.text {
#CHECK-NEXT: 0x1000 R_X86_64_PC32 - 0x0
#CHECK-NEXT: }
#CHECK-NEXT:]

View File

@ -1,4 +1,5 @@
# Ensures that implicitly added sections can be ordered within Sections.
## Ensures that implicitly added sections can be ordered within Sections.
# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj --sections %t | FileCheck %s

View File

@ -1,4 +1,5 @@
# Ensure yaml2obj doesn't crash on unnamed sections
## Check that "Name" defaults to an empty string.
# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj --sections %t | FileCheck %s

View File

@ -1,6 +1,6 @@
## Check that yaml2obj takes in account section AddressAlign field.
# RUN: yaml2obj %s > %t
# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj -S %t | FileCheck %s
# CHECK: Section {

View File

@ -21,7 +21,7 @@ Symbols:
Index: SHN_XINDEX
## Check that yaml2obj keeps the SHT_SYMTAB_SHNDX section in the output
## even when symbol's section index value is low enough to not require the extended symtab.
## even when symbol's section index value is low enough to not require the extended symtab.
## Also, check that symbols in .symtab still have the SHN_XINDEX index.
# RUN: yaml2obj --docnum=2 %s -o %t2

View File

@ -1,4 +1,5 @@
# This test insures that the user cannot have both an Index and a Section field.
## Check that "Index" and "Section" cannot be used together in a symbol.
# RUN: not yaml2obj %s
!ELF

View File

@ -1,4 +1,4 @@
# RUN: yaml2obj %s > %t
# RUN: yaml2obj %s -o %t
# RUN: llvm-readelf -s %t | FileCheck %s
!ELF
@ -21,10 +21,10 @@ Symbols:
Binding: STB_GLOBAL
- Name: common1
Index: SHN_COMMON
Binding: STB_GLOBAL
Binding: STB_GLOBAL
- Name: common2
Index: 0xfff2
Binding: STB_GLOBAL
Binding: STB_GLOBAL
- Name: good
Index: 0x1
Binding: STB_GLOBAL

View File

@ -1,4 +1,4 @@
# RUN: yaml2obj %s > %t
# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj --symbols %t | FileCheck %s
# CHECK: Name: notype
@ -30,7 +30,7 @@ Sections:
Symbols:
- Name: notype
Type: STT_NOTYPE
Binding: STB_GLOBAL
Binding: STB_GLOBAL
- Name: normal_type
Type: STT_OBJECT
Binding: STB_GLOBAL

View File

@ -21,7 +21,7 @@
# CHECK-NEXT: Size:
# CHECK-NEXT: Link:
# CHECK-NEXT: Info: 26
--- !ELF
FileHeader:
Class: ELFCLASS64

View File

@ -1,8 +1,8 @@
## Check we are able to handle SHT_GNU_verdef sections.
# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj -V %t | FileCheck %s
# Check we are able to handle the SHT_GNU_verdef sections.
# CHECK: VersionDefinitions [
# CHECK-NEXT: Definition {
# CHECK-NEXT: Version: 1

View File

@ -1,8 +1,8 @@
## Check we are able to handle SHT_GNU_verneed sections.
# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj -V %t | FileCheck %s
# Check we are able to handle the SHT_GNU_verneed sections.
# CHECK: VersionRequirements [
# CHECK-NEXT: Dependency {
# CHECK-NEXT: Version: 1

View File

@ -68,7 +68,7 @@ Sections:
Dependencies:
- Version: 1
File: dso.so.0
Entries:
Entries:
- Name: v1
Hash: 1937
Flags: 0

View File

@ -1,10 +0,0 @@
# Ensure yaml2obj doesn't error on empty optional mappings, such as Symbols
# RUN: yaml2obj %s -o %t
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
Symbols:

View File

@ -1,4 +1,4 @@
# RUN: not yaml2obj -o %p/path/does/not/exist 2>&1 | FileCheck %s
# Don't check the OS-dependent message "No such file or directory".
## Don't check the OS-dependent message "No such file or directory".
# CHECK: yaml2obj: error: failed to open '{{.*}}/path/does/not/exist': {{.*}}

View File

@ -1,20 +0,0 @@
# Just make sure this isn't an error even though it has no Symbol
# RUN: yaml2obj %s
!ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Content: "00000000"
- Name: .rel.text
Type: SHT_REL
Info: .text
Relocations:
- Offset: 0x1000
Type: R_X86_64_RELATIVE