diff options
| -rw-r--r-- | lld/test/COFF/Inputs/baserel.obj.yaml | 164 | ||||
| -rw-r--r-- | lld/test/COFF/baserel.test | 280 |
2 files changed, 219 insertions, 225 deletions
diff --git a/lld/test/COFF/Inputs/baserel.obj.yaml b/lld/test/COFF/Inputs/baserel.obj.yaml deleted file mode 100644 index 9a31dbbfc59..00000000000 --- a/lld/test/COFF/Inputs/baserel.obj.yaml +++ /dev/null @@ -1,164 +0,0 @@ ---- -header: - Machine: IMAGE_FILE_MACHINE_AMD64 - Characteristics: [ ] -sections: - - Name: .text - Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] - Alignment: 4096 - SectionData: B800000000000000005068000000000000000068000000000000000050E8000000000000000050E8000000000000000050E80000000000000000 - Relocations: - - VirtualAddress: 0 - SymbolName: abs_symbol - Type: IMAGE_REL_AMD64_ADDR64 - - VirtualAddress: 7 - SymbolName: caption - Type: IMAGE_REL_AMD64_ADDR64 - - VirtualAddress: 12 - SymbolName: message - Type: IMAGE_REL_AMD64_ADDR64 - - VirtualAddress: 18 - SymbolName: MessageBoxA - Type: IMAGE_REL_AMD64_REL32 - - VirtualAddress: 24 - SymbolName: ExitProcess - Type: IMAGE_REL_AMD64_REL32 - - VirtualAddress: 30 - SymbolName: __ImageBase - Type: IMAGE_REL_AMD64_ADDR64 - - Name: .text2 - Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] - Alignment: 4096 - SectionData: B800000000000000005068000000000000000068000000000000000050E8000000000000000050E8000000000000000050E80000000000000000 - Relocations: - - VirtualAddress: 0 - SymbolName: abs_symbol - Type: IMAGE_REL_AMD64_ADDR64 - - VirtualAddress: 7 - SymbolName: caption - Type: IMAGE_REL_AMD64_ADDR64 - - VirtualAddress: 12 - SymbolName: message - Type: IMAGE_REL_AMD64_ADDR64 - - VirtualAddress: 18 - SymbolName: MessageBoxA - Type: IMAGE_REL_AMD64_REL32 - - VirtualAddress: 24 - SymbolName: ExitProcess - Type: IMAGE_REL_AMD64_REL32 - - VirtualAddress: 30 - SymbolName: __ImageBase - Type: IMAGE_REL_AMD64_ADDR64 - - Name: .data - Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] - Alignment: 4 - SectionData: 48656C6C6F0048656C6C6F20576F726C6400 - - Name: .drectve - Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] - Alignment: 2147483648 - SectionData: 2F454E5452593A6D61696E20 -symbols: - - Name: "@comp.id" - Value: 10394907 - SectionNumber: 65535 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_STATIC - - Name: .text - Value: 0 - SectionNumber: 1 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: - Length: 28 - NumberOfRelocations: 6 - NumberOfLinenumbers: 0 - CheckSum: 0 - Number: 0 - - Name: .text2 - Value: 0 - SectionNumber: 1 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: - Length: 28 - NumberOfRelocations: 6 - NumberOfLinenumbers: 0 - CheckSum: 0 - Number: 0 - - Name: .data - Value: 0 - SectionNumber: 3 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: - Length: 18 - NumberOfRelocations: 0 - NumberOfLinenumbers: 0 - CheckSum: 0 - Number: 0 - - Name: MessageBoxA - Value: 0 - SectionNumber: 0 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_EXTERNAL - - Name: ExitProcess - Value: 0 - SectionNumber: 0 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_EXTERNAL - - Name: message - Value: 6 - SectionNumber: 2 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_STATIC - - Name: mainCRTStartup - Value: 0 - SectionNumber: 1 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_EXTERNAL - - Name: caption - Value: 0 - SectionNumber: 2 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_STATIC - - Name: .drectve - Value: 0 - SectionNumber: 3 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: - Length: 12 - NumberOfRelocations: 0 - NumberOfLinenumbers: 0 - CheckSum: 0 - Number: 0 - - Name: .file - Value: 0 - SectionNumber: 65534 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_STATIC - File: "hello.c" - - Name: abs_symbol - Value: 0xDEADBEEF - SectionNumber: -1 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_EXTERNAL - - Name: __ImageBase - Value: 0 - SectionNumber: 0 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_EXTERNAL -... diff --git a/lld/test/COFF/baserel.test b/lld/test/COFF/baserel.test index 6c543103701..58227179c37 100644 --- a/lld/test/COFF/baserel.test +++ b/lld/test/COFF/baserel.test @@ -1,48 +1,48 @@ -# RUN: yaml2obj %p/Inputs/baserel.obj.yaml > %t.obj +# RUN: yaml2obj < %s > %t.obj # # RUN: lld -flavor link2 /out:%t.exe %t.obj %p/Inputs/std64.lib -# RUN: llvm-readobj -coff-basereloc %t.exe | FileCheck %s --check-prefix=BASEREL +# RUN: llvm-readobj -coff-basereloc %t.exe | FileCheck %s -check-prefix=BASEREL # # RUN: lld -flavor link2 /out:%t.exe /fixed %t.obj %p/Inputs/std64.lib -# RUN: llvm-readobj -coff-basereloc %t.exe | FileCheck %s --check-prefix=NOBASEREL - -BASEREL: BaseReloc [ -BASEREL-NEXT: Entry { -BASEREL-NEXT: Type: DIR64 -BASEREL-NEXT: Address: 0x2000 -BASEREL-NEXT: } -BASEREL-NEXT: Entry { -BASEREL-NEXT: Type: DIR64 -BASEREL-NEXT: Address: 0x2007 -BASEREL-NEXT: } -BASEREL-NEXT: Entry { -BASEREL-NEXT: Type: DIR64 -BASEREL-NEXT: Address: 0x200C -BASEREL-NEXT: } -BASEREL-NEXT: Entry { -BASEREL-NEXT: Type: ABSOLUTE -BASEREL-NEXT: Address: 0x2000 -BASEREL-NEXT: } -BASEREL-NEXT: Entry { -BASEREL-NEXT: Type: DIR64 -BASEREL-NEXT: Address: 0x3000 -BASEREL-NEXT: } -BASEREL-NEXT: Entry { -BASEREL-NEXT: Type: DIR64 -BASEREL-NEXT: Address: 0x3007 -BASEREL-NEXT: } -BASEREL-NEXT: Entry { -BASEREL-NEXT: Type: DIR64 -BASEREL-NEXT: Address: 0x300C -BASEREL-NEXT: } -BASEREL-NEXT: Entry { -BASEREL-NEXT: Type: ABSOLUTE -BASEREL-NEXT: Address: 0x3000 -BASEREL-NEXT: } - -NOBASEREL: BaseReloc [ -NOBASEREL-NEXT: ] - +# RUN: llvm-readobj -coff-basereloc %t.exe | FileCheck %s -check-prefix=NOBASEREL +# +# BASEREL: BaseReloc [ +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: DIR64 +# BASEREL-NEXT: Address: 0x2000 +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: DIR64 +# BASEREL-NEXT: Address: 0x2007 +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: DIR64 +# BASEREL-NEXT: Address: 0x200C +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: ABSOLUTE +# BASEREL-NEXT: Address: 0x2000 +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: DIR64 +# BASEREL-NEXT: Address: 0x3000 +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: DIR64 +# BASEREL-NEXT: Address: 0x3007 +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: DIR64 +# BASEREL-NEXT: Address: 0x300C +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: ABSOLUTE +# BASEREL-NEXT: Address: 0x3000 +# BASEREL-NEXT: } +# +# NOBASEREL: BaseReloc [ +# NOBASEREL-NEXT: ] +# # RUN: lld -flavor link2 /out:%t.exe %t.obj %p/Inputs/std64.lib # RUN: llvm-readobj -file-headers -sections %t.exe | FileCheck %s \ # RUN: --check-prefix=BASEREL-HEADER @@ -50,24 +50,182 @@ NOBASEREL-NEXT: ] # RN: lld -flavor link2 /out:%t.exe /fixed %t.obj %p/Inputs/std64.lib # RN: llvm-readobj -file-headers %t.exe | FileCheck %s \ # RN: --check-prefix=NOBASEREL-HEADER +# +# BASEREL-HEADER-NOT: IMAGE_FILE_RELOCS_STRIPPED +# +# NOBASEREL-HEADER: IMAGE_FILE_RELOCS_STRIPPED +# +# BASEREL-HEADER: BaseRelocationTableRVA: 0x5000 +# BASEREL-HEADER: BaseRelocationTableSize: 0x20 +# BASEREL-HEADER: Name: .reloc (2E 72 65 6C 6F 63 00 00) +# BASEREL-HEADER-NEXT: VirtualSize: 0x20 +# BASEREL-HEADER-NEXT: VirtualAddress: 0x5000 +# BASEREL-HEADER-NEXT: RawDataSize: 512 +# BASEREL-HEADER-NEXT: PointerToRawData: 0x1800 +# BASEREL-HEADER-NEXT: PointerToRelocations: 0x0 +# BASEREL-HEADER-NEXT: PointerToLineNumbers: 0x0 +# BASEREL-HEADER-NEXT: RelocationCount: 0 +# BASEREL-HEADER-NEXT: LineNumberCount: 0 +# BASEREL-HEADER-NEXT: Characteristics [ (0x42000040) +# BASEREL-HEADER-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40) +# BASEREL-HEADER-NEXT: IMAGE_SCN_MEM_DISCARDABLE (0x2000000) +# BASEREL-HEADER-NEXT: IMAGE_SCN_MEM_READ (0x40000000) +# BASEREL-HEADER-NEXT: ] -BASEREL-HEADER-NOT: IMAGE_FILE_RELOCS_STRIPPED - -NOBASEREL-HEADER: IMAGE_FILE_RELOCS_STRIPPED - -BASEREL-HEADER: BaseRelocationTableRVA: 0x5000 -BASEREL-HEADER: BaseRelocationTableSize: 0x20 -BASEREL-HEADER: Name: .reloc (2E 72 65 6C 6F 63 00 00) -BASEREL-HEADER-NEXT: VirtualSize: 0x20 -BASEREL-HEADER-NEXT: VirtualAddress: 0x5000 -BASEREL-HEADER-NEXT: RawDataSize: 512 -BASEREL-HEADER-NEXT: PointerToRawData: 0x1800 -BASEREL-HEADER-NEXT: PointerToRelocations: 0x0 -BASEREL-HEADER-NEXT: PointerToLineNumbers: 0x0 -BASEREL-HEADER-NEXT: RelocationCount: 0 -BASEREL-HEADER-NEXT: LineNumberCount: 0 -BASEREL-HEADER-NEXT: Characteristics [ (0x42000040) -BASEREL-HEADER-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA (0x40) -BASEREL-HEADER-NEXT: IMAGE_SCN_MEM_DISCARDABLE (0x2000000) -BASEREL-HEADER-NEXT: IMAGE_SCN_MEM_READ (0x40000000) -BASEREL-HEADER-NEXT: ] +--- +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4096 + SectionData: B800000000000000005068000000000000000068000000000000000050E8000000000000000050E8000000000000000050E80000000000000000 + Relocations: + - VirtualAddress: 0 + SymbolName: abs_symbol + Type: IMAGE_REL_AMD64_ADDR64 + - VirtualAddress: 7 + SymbolName: caption + Type: IMAGE_REL_AMD64_ADDR64 + - VirtualAddress: 12 + SymbolName: message + Type: IMAGE_REL_AMD64_ADDR64 + - VirtualAddress: 18 + SymbolName: MessageBoxA + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 24 + SymbolName: ExitProcess + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 30 + SymbolName: __ImageBase + Type: IMAGE_REL_AMD64_ADDR64 + - Name: .text2 + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4096 + SectionData: B800000000000000005068000000000000000068000000000000000050E8000000000000000050E8000000000000000050E80000000000000000 + Relocations: + - VirtualAddress: 0 + SymbolName: abs_symbol + Type: IMAGE_REL_AMD64_ADDR64 + - VirtualAddress: 7 + SymbolName: caption + Type: IMAGE_REL_AMD64_ADDR64 + - VirtualAddress: 12 + SymbolName: message + Type: IMAGE_REL_AMD64_ADDR64 + - VirtualAddress: 18 + SymbolName: MessageBoxA + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 24 + SymbolName: ExitProcess + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 30 + SymbolName: __ImageBase + Type: IMAGE_REL_AMD64_ADDR64 + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: 48656C6C6F0048656C6C6F20576F726C6400 + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 2147483648 + SectionData: 2F454E5452593A6D61696E20 +symbols: + - Name: "@comp.id" + Value: 10394907 + SectionNumber: 65535 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 28 + NumberOfRelocations: 6 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: .text2 + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 28 + NumberOfRelocations: 6 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: .data + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 18 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: MessageBoxA + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: ExitProcess + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: message + Value: 6 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: mainCRTStartup + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: caption + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: .drectve + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 12 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: abs_symbol + Value: 0xDEADBEEF + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: __ImageBase + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... |

