aboutsummaryrefslogtreecommitdiffstats
path: root/test/Object
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2012-08-02 19:16:56 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2012-08-02 19:16:56 +0000
commita915f247f72570a994d55cd0d2961cd2d7bbd0e1 (patch)
tree51bbc92eb6c125a893d516d180a15c4fb71752ba /test/Object
parentcfbda4a04dacaf976505c54a5308f6954b3b9a58 (diff)
downloadexternal_llvm-a915f247f72570a994d55cd0d2961cd2d7bbd0e1.zip
external_llvm-a915f247f72570a994d55cd0d2961cd2d7bbd0e1.tar.gz
external_llvm-a915f247f72570a994d55cd0d2961cd2d7bbd0e1.tar.bz2
Add yaml2obj. A utility to convert YAML to binaries.
yaml2obj takes a textual description of an object file in YAML format and outputs the binary equivalent. This greatly simplifies writing tests that take binary object files as input. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161205 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Object')
-rw-r--r--test/Object/COFF/i386.yaml83
-rw-r--r--test/Object/COFF/x86-64.yaml83
-rw-r--r--test/Object/Inputs/trivial-object-test.coff-i386bin346 -> 346 bytes
-rw-r--r--test/Object/nm-trivial-object.test8
-rw-r--r--test/Object/objdump-file-header.test3
-rw-r--r--test/Object/objdump-section-content.test5
-rw-r--r--test/Object/objdump-symbol-table.test6
7 files changed, 175 insertions, 13 deletions
diff --git a/test/Object/COFF/i386.yaml b/test/Object/COFF/i386.yaml
new file mode 100644
index 0000000..ca90222
--- /dev/null
+++ b/test/Object/COFF/i386.yaml
@@ -0,0 +1,83 @@
+header: !Header
+ Machine: IMAGE_FILE_MACHINE_I386 # (0x14c)
+
+sections:
+ - !Section
+ Name: .text
+ Characteristics: [IMAGE_SCN_CNT_CODE, IMAGE_SCN_ALIGN_16BYTES, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ, ] # 0x60500020
+ SectionData: !hex "83EC0CC744240800000000C7042400000000E800000000E8000000008B44240883C40CC3" # |....D$.......$...............D$.....|
+
+ Relocations:
+ - !Relocation
+ VirtualAddress: 0xe
+ SymbolTableIndex: 5
+ Type: IMAGE_REL_I386_DIR32
+
+ - !Relocation
+ VirtualAddress: 0x13
+ SymbolTableIndex: 6
+ Type: IMAGE_REL_I386_REL32
+
+ - !Relocation
+ VirtualAddress: 0x18
+ SymbolTableIndex: 7
+ Type: IMAGE_REL_I386_REL32
+
+ - !Section
+ Name: .data
+ Characteristics: [IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_ALIGN_1BYTES, 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)
+ NumberOfAuxSymbols: 1
+ AuxillaryData: !hex "240000000300000000000000010000000000" # |$.................|
+
+ - !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)
+ NumberOfAuxSymbols: 1
+ AuxillaryData: !hex "0D0000000000000000000000020000000000" # |..................|
+
+ - !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)
+
diff --git a/test/Object/COFF/x86-64.yaml b/test/Object/COFF/x86-64.yaml
new file mode 100644
index 0000000..0b1265f
--- /dev/null
+++ b/test/Object/COFF/x86-64.yaml
@@ -0,0 +1,83 @@
+header: !Header
+ Machine: IMAGE_FILE_MACHINE_AMD64 # (0x8664)
+
+sections:
+ - !Section
+ Name: .text
+ Characteristics: [IMAGE_SCN_CNT_CODE, IMAGE_SCN_ALIGN_16BYTES, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ, ] # 0x60500020
+ SectionData: !hex "4883EC28C744242400000000488D0D00000000E800000000E8000000008B4424244883C428C3" # |H..(.D$$....H.................D$$H..(.|
+
+ Relocations:
+ - !Relocation
+ VirtualAddress: 0xf
+ SymbolTableIndex: 5
+ Type: IMAGE_REL_AMD64_REL32
+
+ - !Relocation
+ VirtualAddress: 0x14
+ SymbolTableIndex: 6
+ Type: IMAGE_REL_AMD64_REL32
+
+ - !Relocation
+ VirtualAddress: 0x19
+ SymbolTableIndex: 7
+ Type: IMAGE_REL_AMD64_REL32
+
+ - !Section
+ Name: .data
+ Characteristics: [IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_ALIGN_1BYTES, 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)
+ NumberOfAuxSymbols: 1
+ AuxillaryData: !hex "260000000300000000000000010000000000" # |&.................|
+
+ - !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)
+ NumberOfAuxSymbols: 1
+ AuxillaryData: !hex "0D0000000000000000000000020000000000" # |..................|
+
+ - !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)
+
diff --git a/test/Object/Inputs/trivial-object-test.coff-i386 b/test/Object/Inputs/trivial-object-test.coff-i386
index 8cfd994..d4ab63b 100644
--- a/test/Object/Inputs/trivial-object-test.coff-i386
+++ b/test/Object/Inputs/trivial-object-test.coff-i386
Binary files differ
diff --git a/test/Object/nm-trivial-object.test b/test/Object/nm-trivial-object.test
index e5635ab..b6f70a0 100644
--- a/test/Object/nm-trivial-object.test
+++ b/test/Object/nm-trivial-object.test
@@ -1,7 +1,5 @@
-RUN: llvm-nm %p/Inputs/trivial-object-test.coff-i386 \
-RUN: | FileCheck %s -check-prefix COFF
-RUN: llvm-nm %p/Inputs/trivial-object-test.coff-x86-64 \
-RUN: | FileCheck %s -check-prefix COFF
+RUN: yaml2obj %p/COFF/i386.yaml | llvm-nm | FileCheck %s -check-prefix COFF
+RUN: yaml2obj %p/COFF/x86-64.yaml | llvm-nm | FileCheck %s -check-prefix COFF
RUN: llvm-nm %p/Inputs/trivial-object-test.elf-i386 \
RUN: | FileCheck %s -check-prefix ELF
RUN: llvm-nm %p/Inputs/trivial-object-test.elf-x86-64 \
@@ -30,4 +28,4 @@ macho: 00000000 U _puts
macho64: 00000028 s L_.str
macho64: 00000000 u _SomeOtherFunction
macho64: 00000000 s _main
-macho64: 00000000 u _puts \ No newline at end of file
+macho64: 00000000 u _puts
diff --git a/test/Object/objdump-file-header.test b/test/Object/objdump-file-header.test
index 3fce3f4..f35a8a1 100644
--- a/test/Object/objdump-file-header.test
+++ b/test/Object/objdump-file-header.test
@@ -1,5 +1,4 @@
-RUN: llvm-objdump -f %p/Inputs/trivial-object-test.coff-i386 \
-RUN: | FileCheck %s -check-prefix COFF-i386
+RUN: yaml2obj %p/COFF/i386.yaml | llvm-objdump -f - | FileCheck %s -check-prefix COFF-i386
RUN: llvm-objdump -f %p/Inputs/trivial-object-test.elf-i386 \
RUN: | FileCheck %s -check-prefix ELF-i386
diff --git a/test/Object/objdump-section-content.test b/test/Object/objdump-section-content.test
index 581e75e..56b7989 100644
--- a/test/Object/objdump-section-content.test
+++ b/test/Object/objdump-section-content.test
@@ -1,9 +1,8 @@
-RUN: llvm-objdump -s %p/Inputs/trivial-object-test.coff-i386 \
-RUN: | FileCheck %s -check-prefix COFF-i386
+RUN: yaml2obj %p/COFF/i386.yaml | llvm-objdump -s - | FileCheck %s -check-prefix COFF-i386
RUN: llvm-objdump -s %p/Inputs/trivial-object-test.elf-i386 \
RUN: | FileCheck %s -check-prefix ELF-i386
-COFF-i386: trivial-object-test.coff-i386: file format
+COFF-i386: file format
COFF-i386: Contents of section .text:
COFF-i386: 0000 83ec0cc7 44240800 000000c7 04240000 ....D$.......$..
COFF-i386: 0010 0000e800 000000e8 00000000 8b442408 .............D$.
diff --git a/test/Object/objdump-symbol-table.test b/test/Object/objdump-symbol-table.test
index 8a0f440..a721171 100644
--- a/test/Object/objdump-symbol-table.test
+++ b/test/Object/objdump-symbol-table.test
@@ -1,17 +1,17 @@
-RUN: llvm-objdump -t %p/Inputs/trivial-object-test.coff-i386 \
+RUN: yaml2obj %p/COFF/i386.yaml | llvm-objdump -t - \
RUN: | FileCheck %s -check-prefix COFF-i386
RUN: llvm-objdump -t %p/Inputs/trivial-object-test.elf-i386 \
RUN: | FileCheck %s -check-prefix ELF-i386
RUN: llvm-objdump -t %p/Inputs/trivial-object-test.macho-i386 \
RUN: | FileCheck %s -check-prefix macho-i386
-COFF-i386: trivial-object-test.coff-i386: file format
+COFF-i386: file format
COFF-i386: SYMBOL TABLE:
COFF-i386: [ 0](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .text
COFF-i386: AUX scnlen 0x24 nreloc 3 nlnno 0 checksum 0x0 assoc 1 comdat 0
COFF-i386: [ 2](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .data
COFF-i386: AUX scnlen 0xd nreloc 0 nlnno 0 checksum 0x0 assoc 2 comdat 0
-COFF-i386: [ 4](sec 1)(fl 0x00)(ty 200)(scl 2) (nx 0) 0x00000000 _main
+COFF-i386: [ 4](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 _main
COFF-i386: [ 5](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 L_.str
COFF-i386: [ 6](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _puts
COFF-i386: [ 7](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _SomeOtherFunction