diff options
Diffstat (limited to 'test/COFF')
117 files changed, 4194 insertions, 238 deletions
diff --git a/test/COFF/Inputs/associative-comdat-mingw-2.s b/test/COFF/Inputs/associative-comdat-mingw-2.s new file mode 100644 index 000000000000..edb6a82da84b --- /dev/null +++ b/test/COFF/Inputs/associative-comdat-mingw-2.s @@ -0,0 +1,34 @@ + .section .xdata$foo,"dr" + .linkonce discard + .p2align 3 + .long 42 + + .section .xdata$bar,"dr" + .linkonce discard + .p2align 3 + .long 43 + + .section .xdata$baz,"dr" + .linkonce discard + .p2align 3 + .long 44 + + .def foo; + .scl 2; + .type 32; + .endef + .section .text$foo,"xr",discard,foo + .globl foo + .p2align 4 +foo: + ret + + .def bar; + .scl 2; + .type 32; + .endef + .section .text$bar,"xr",discard,bar + .globl bar + .p2align 4 +bar: + ret diff --git a/test/COFF/Inputs/bad-block-size.pdb b/test/COFF/Inputs/bad-block-size.pdb new file mode 100644 index 000000000000..fadd8833e4bb --- /dev/null +++ b/test/COFF/Inputs/bad-block-size.pdb @@ -0,0 +1,2 @@ +Microsoft C/C++ MSF 7.00
+DS
\ No newline at end of file diff --git a/test/COFF/Inputs/comdat-jumptable2.s b/test/COFF/Inputs/comdat-jumptable2.s new file mode 100644 index 000000000000..8990d4c0d7f3 --- /dev/null +++ b/test/COFF/Inputs/comdat-jumptable2.s @@ -0,0 +1,35 @@ + .section .text@comdatfunc, "x" + .linkonce discard + .globl comdatfunc +comdatfunc: + leaq .Ljumptable(%rip), %rax + movslq (%rax, %rcx, 4), %rcx + addq %rcx, %rax + jmp *%rax + + .section .rdata, "dr" + .long 0xcccccccc +.Ljumptable: + .long .Ltail1-.Ljumptable + .long .Ltail2-.Ljumptable + .long .Ltail3-.Ljumptable + .long 0xdddddddd + + .section .text@comdatfunc, "x" +# If assembled with binutils, the following line can be kept in: +# .linkonce discard +.Ltail1: + movl $1, %eax + ret +.Ltail2: + movl $2, %eax + ret +.Ltail3: + movl $3, %eax + ret + + .text + .globl otherfunc +otherfunc: + call comdatfunc + ret diff --git a/test/COFF/Inputs/common-replacement.s b/test/COFF/Inputs/common-replacement.s new file mode 100644 index 000000000000..eaaeee2a3d36 --- /dev/null +++ b/test/COFF/Inputs/common-replacement.s @@ -0,0 +1,5 @@ + .globl foo + .data + .p2align 2, 0 +foo: + .long 42 diff --git a/test/COFF/Inputs/crt-dyn-initializer-order_1.yaml b/test/COFF/Inputs/crt-dyn-initializer-order_1.yaml new file mode 100644 index 000000000000..302f6f2feeac --- /dev/null +++ b/test/COFF/Inputs/crt-dyn-initializer-order_1.yaml @@ -0,0 +1,15 @@ +--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: [ ]
+sections:
+ - Name: '.CRT$XCU'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 55
+ - Name: '.CRT$XCU'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 70
+symbols:
+...
diff --git a/test/COFF/Inputs/crt-dyn-initializer-order_2.yaml b/test/COFF/Inputs/crt-dyn-initializer-order_2.yaml new file mode 100644 index 000000000000..a2d0e5e25b1c --- /dev/null +++ b/test/COFF/Inputs/crt-dyn-initializer-order_2.yaml @@ -0,0 +1,19 @@ +--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: [ ]
+sections:
+ - Name: '.CRT$XCU'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 10
+ - Name: '.CRT$XCU'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 11
+ - Name: '.CRT$XCU'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 12
+symbols:
+...
diff --git a/test/COFF/Inputs/empty.yaml b/test/COFF/Inputs/empty.yaml new file mode 100644 index 000000000000..6396f8aed08a --- /dev/null +++ b/test/COFF/Inputs/empty.yaml @@ -0,0 +1,67 @@ +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_I386 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 31C0C3 + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .bss + Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 3 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 3963538403 + Number: 1 + - Name: .data + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 2 + - Name: .bss + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 3 + - Name: '@feat.00' + Value: 1 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: _main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/Inputs/far-arm-thumb-abs.s b/test/COFF/Inputs/far-arm-thumb-abs.s deleted file mode 100644 index 9f1b59a55f8c..000000000000 --- a/test/COFF/Inputs/far-arm-thumb-abs.s +++ /dev/null @@ -1,2 +0,0 @@ -.global too_far1 -too_far1 = 0x1401004 diff --git a/test/COFF/Inputs/far-arm-thumb-abs20.s b/test/COFF/Inputs/far-arm-thumb-abs20.s deleted file mode 100644 index 8483e32dc7f0..000000000000 --- a/test/COFF/Inputs/far-arm-thumb-abs20.s +++ /dev/null @@ -1,2 +0,0 @@ -.global too_far20 -too_far20 = 0x501004 diff --git a/test/COFF/Inputs/gnu-implib-data.s b/test/COFF/Inputs/gnu-implib-data.s new file mode 100644 index 000000000000..d9af7756332c --- /dev/null +++ b/test/COFF/Inputs/gnu-implib-data.s @@ -0,0 +1,23 @@ + .global __imp_data + + # The data that is emitted into .idata$7 here is isn't needed for + # the import data structures, but we need to emit something which + # produces a relocation against _head_test_lib, to pull in the + # header and trailer objects. + + .section .idata$7 + .rva _head_test_lib + + .section .idata$5 +__imp_data: + .rva .Lhint_name + .long 0 + + .section .idata$4 + .rva .Lhint_name + .long 0 + + .section .idata$6 +.Lhint_name: + .short 0 + .asciz "data" diff --git a/test/COFF/Inputs/gnu-implib-func.s b/test/COFF/Inputs/gnu-implib-func.s new file mode 100644 index 000000000000..5f37ee1cd223 --- /dev/null +++ b/test/COFF/Inputs/gnu-implib-func.s @@ -0,0 +1,27 @@ + .text + .global func + .global __imp_func +func: + jmp *__imp_func + + # The data that is emitted into .idata$7 here is isn't needed for + # the import data structures, but we need to emit something which + # produces a relocation against _head_test_lib, to pull in the + # header and trailer objects. + + .section .idata$7 + .rva _head_test_lib + + .section .idata$5 +__imp_func: + .rva .Lhint_name + .long 0 + + .section .idata$4 + .rva .Lhint_name + .long 0 + + .section .idata$6 +.Lhint_name: + .short 0 + .asciz "func" diff --git a/test/COFF/Inputs/gnu-implib-head.s b/test/COFF/Inputs/gnu-implib-head.s new file mode 100644 index 000000000000..b32acf0d6f3d --- /dev/null +++ b/test/COFF/Inputs/gnu-implib-head.s @@ -0,0 +1,13 @@ + .section .idata$2 + .global _head_test_lib +_head_test_lib: + .rva hname + .long 0 + .long 0 + .rva __test_lib_iname + .rva fthunk + + .section .idata$5 +fthunk: + .section .idata$4 +hname: diff --git a/test/COFF/Inputs/gnu-implib-tail.s b/test/COFF/Inputs/gnu-implib-tail.s new file mode 100644 index 000000000000..784d51f6e830 --- /dev/null +++ b/test/COFF/Inputs/gnu-implib-tail.s @@ -0,0 +1,11 @@ + .section .idata$4 + .long 0 + .long 0 + .section .idata$5 + .long 0 + .long 0 + + .section .idata$7 + .global __test_lib_iname +__test_lib_iname: + .asciz "foo.dll" diff --git a/test/COFF/Inputs/gnu-weak.o b/test/COFF/Inputs/gnu-weak.o Binary files differnew file mode 100644 index 000000000000..997f00463560 --- /dev/null +++ b/test/COFF/Inputs/gnu-weak.o diff --git a/test/COFF/Inputs/gnu-weak2.o b/test/COFF/Inputs/gnu-weak2.o Binary files differnew file mode 100644 index 000000000000..15b5d4dad93f --- /dev/null +++ b/test/COFF/Inputs/gnu-weak2.o diff --git a/test/COFF/Inputs/icf-safe.s b/test/COFF/Inputs/icf-safe.s new file mode 100644 index 000000000000..3a2b3b18e7ab --- /dev/null +++ b/test/COFF/Inputs/icf-safe.s @@ -0,0 +1,9 @@ +.section .rdata,"dr",one_only,non_addrsig1 +.globl non_addrsig1 +non_addrsig1: +.byte 3 + +.section .rdata,"dr",one_only,non_addrsig2 +.globl non_addrsig2 +non_addrsig2: +.byte 3 diff --git a/test/COFF/Inputs/inline-weak.o b/test/COFF/Inputs/inline-weak.o Binary files differnew file mode 100644 index 000000000000..5987e60fd657 --- /dev/null +++ b/test/COFF/Inputs/inline-weak.o diff --git a/test/COFF/Inputs/inline-weak2.o b/test/COFF/Inputs/inline-weak2.o Binary files differnew file mode 100644 index 000000000000..b413f5bb0d43 --- /dev/null +++ b/test/COFF/Inputs/inline-weak2.o diff --git a/test/COFF/Inputs/pdb-file-statics-a.yaml b/test/COFF/Inputs/pdb-file-statics-a.yaml index 957eb5aee869..1a0dbdb67855 100644 --- a/test/COFF/Inputs/pdb-file-statics-a.yaml +++ b/test/COFF/Inputs/pdb-file-statics-a.yaml @@ -1353,7 +1353,7 @@ sections: RegRelativeSym: Offset: 48 Type: 116 - Register: CVRegRSP + Register: RSP VarName: __formal - Kind: S_PROC_ID_END ScopeEndSym: @@ -1528,13 +1528,13 @@ sections: RegRelativeSym: Offset: 48 Type: 116 - Register: CVRegRSP + Register: RSP VarName: argc - Kind: S_REGREL32 RegRelativeSym: Offset: 56 Type: 4098 - Register: CVRegRSP + Register: RSP VarName: argv - Kind: S_PROC_ID_END ScopeEndSym: diff --git a/test/COFF/Inputs/pdb-file-statics-b.yaml b/test/COFF/Inputs/pdb-file-statics-b.yaml index 8b7a311f0f8b..f74bab703477 100644 --- a/test/COFF/Inputs/pdb-file-statics-b.yaml +++ b/test/COFF/Inputs/pdb-file-statics-b.yaml @@ -1328,7 +1328,7 @@ sections: RegRelativeSym: Offset: 48 Type: 116 - Register: CVRegRSP + Register: RSP VarName: __formal - Kind: S_PROC_ID_END ScopeEndSym: diff --git a/test/COFF/Inputs/pdb-scopes-a.yaml b/test/COFF/Inputs/pdb-scopes-a.yaml index 0fc41723bdc2..e422a6241f27 100644 --- a/test/COFF/Inputs/pdb-scopes-a.yaml +++ b/test/COFF/Inputs/pdb-scopes-a.yaml @@ -53,7 +53,7 @@ sections: RegRelativeSym: Offset: 8 Type: 116 - Register: CVRegRSP + Register: RSP VarName: x - Kind: S_PROC_ID_END ScopeEndSym: @@ -93,7 +93,7 @@ sections: RegRelativeSym: Offset: 64 Type: 116 - Register: CVRegRSP + Register: RSP VarName: argc - Kind: S_BLOCK32 BlockSym: @@ -104,7 +104,7 @@ sections: RegRelativeSym: Offset: 32 Type: 116 - Register: CVRegRSP + Register: RSP VarName: x - Kind: S_END ScopeEndSym: @@ -117,7 +117,7 @@ sections: RegRelativeSym: Offset: 36 Type: 116 - Register: CVRegRSP + Register: RSP VarName: y - Kind: S_END ScopeEndSym: diff --git a/test/COFF/Inputs/pdb-scopes-b.yaml b/test/COFF/Inputs/pdb-scopes-b.yaml index c0ee98b0d64c..b1c602143c3f 100644 --- a/test/COFF/Inputs/pdb-scopes-b.yaml +++ b/test/COFF/Inputs/pdb-scopes-b.yaml @@ -53,7 +53,7 @@ sections: RegRelativeSym: Offset: 64 Type: 116 - Register: CVRegRSP + Register: RSP VarName: x - Kind: S_BLOCK32 BlockSym: @@ -64,7 +64,7 @@ sections: RegRelativeSym: Offset: 32 Type: 116 - Register: CVRegRSP + Register: RSP VarName: y - Kind: S_END ScopeEndSym: @@ -77,7 +77,7 @@ sections: RegRelativeSym: Offset: 36 Type: 116 - Register: CVRegRSP + Register: RSP VarName: w - Kind: S_END ScopeEndSym: diff --git a/test/COFF/Inputs/pdb-type-server-missing-2.yaml b/test/COFF/Inputs/pdb-type-server-missing-2.yaml new file mode 100644 index 000000000000..e71bcec22448 --- /dev/null +++ b/test/COFF/Inputs/pdb-type-server-missing-2.yaml @@ -0,0 +1,32 @@ +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: '.debug$T' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Types: + - Kind: LF_TYPESERVER2 + TypeServer2: + Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}' + Age: 18 + Name: 'C:\src\llvm-project\build\definitely_not_found_for_sure.pdb' + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 33C0C3 +symbols: + - Name: '.debug$T' + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 564 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 +... diff --git a/test/COFF/Inputs/pdb-type-server-simple-a.yaml b/test/COFF/Inputs/pdb-type-server-simple-a.yaml index 8425c4f63b70..78c68168127b 100644 --- a/test/COFF/Inputs/pdb-type-server-simple-a.yaml +++ b/test/COFF/Inputs/pdb-type-server-simple-a.yaml @@ -53,7 +53,7 @@ sections: RegRelativeSym: Offset: 32 Type: 4102 - Register: CVRegRSP + Register: RSP VarName: f - Kind: S_PROC_ID_END ScopeEndSym: diff --git a/test/COFF/Inputs/pdb-type-server-simple-b.yaml b/test/COFF/Inputs/pdb-type-server-simple-b.yaml index 3b511cb0d861..56e97d530894 100644 --- a/test/COFF/Inputs/pdb-type-server-simple-b.yaml +++ b/test/COFF/Inputs/pdb-type-server-simple-b.yaml @@ -53,7 +53,7 @@ sections: RegRelativeSym: Offset: 8 Type: 4097 - Register: CVRegRSP + Register: RSP VarName: p - Kind: S_PROC_ID_END ScopeEndSym: diff --git a/test/COFF/Inputs/pdb-type-server-valid-signature.yaml b/test/COFF/Inputs/pdb-type-server-valid-signature.yaml new file mode 100644 index 000000000000..dd95a3df8893 --- /dev/null +++ b/test/COFF/Inputs/pdb-type-server-valid-signature.yaml @@ -0,0 +1,121 @@ +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 3 + DbgStart: 0 + DbgEnd: 2 + FunctionType: 4199 + Flags: [ ] + DisplayName: main + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 3 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'c:\src\llvm-project\build\t.c' + Lines: + - Offset: 0 + LineStart: 1 + IsStatement: true + EndDelta: 0 + Columns: + - !FileChecksums + Checksums: + - FileName: 'c:\src\llvm-project\build\t.c' + Kind: MD5 + Checksum: 270A878DCC1B845655B162F56C4F5020 + - !StringTable + Strings: + - 'c:\src\llvm-project\build\t.c' + Relocations: + - VirtualAddress: 44 + SymbolName: main + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 48 + SymbolName: main + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 100 + SymbolName: main + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 104 + SymbolName: main + Type: IMAGE_REL_AMD64_SECTION + - Name: '.debug$T' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Types: + - Kind: LF_TYPESERVER2 + TypeServer2: + Guid: '{8DABD2A0-28FF-CB43-9BAF-175B77B76414}' + Age: 18 + Name: 'pdb-diff-cl.pdb' + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 33C0C3 +symbols: + - Name: '.debug$S' + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 328 + NumberOfRelocations: 4 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: '.debug$T' + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 564 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: '.text$mn' + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 3 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 4021952397 + Number: 0 + - Name: main + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/Inputs/precomp-a.obj b/test/COFF/Inputs/precomp-a.obj Binary files differnew file mode 100644 index 000000000000..b63392a7a86f --- /dev/null +++ b/test/COFF/Inputs/precomp-a.obj diff --git a/test/COFF/Inputs/precomp-b.obj b/test/COFF/Inputs/precomp-b.obj Binary files differnew file mode 100644 index 000000000000..d590ecebe288 --- /dev/null +++ b/test/COFF/Inputs/precomp-b.obj diff --git a/test/COFF/Inputs/precomp-invalid.obj b/test/COFF/Inputs/precomp-invalid.obj Binary files differnew file mode 100644 index 000000000000..2ad270a6e616 --- /dev/null +++ b/test/COFF/Inputs/precomp-invalid.obj diff --git a/test/COFF/Inputs/precomp.obj b/test/COFF/Inputs/precomp.obj Binary files differnew file mode 100644 index 000000000000..424077e68dc5 --- /dev/null +++ b/test/COFF/Inputs/precomp.obj diff --git a/test/COFF/arm-thumb-branch-error.s b/test/COFF/arm-thumb-branch-error.s deleted file mode 100644 index 00b835c58a15..000000000000 --- a/test/COFF/arm-thumb-branch-error.s +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: llvm-mc -filetype=obj -triple=thumbv7a-windows-gnu %s -o %t -// RUN: llvm-mc -filetype=obj -triple=thumbv7a-windows-gnu %S/Inputs/far-arm-thumb-abs.s -o %tfar -// RUN: not lld-link -entry:_start -subsystem:console %t %tfar -out:%t2 2>&1 | FileCheck %s -// REQUIRES: arm - .syntax unified - .globl _start -_start: - bl too_far1 - -// CHECK: relocation out of range diff --git a/test/COFF/arm-thumb-branch20-error.s b/test/COFF/arm-thumb-branch20-error.s index ec7d23b05329..fbbc0d49d02b 100644 --- a/test/COFF/arm-thumb-branch20-error.s +++ b/test/COFF/arm-thumb-branch20-error.s @@ -1,10 +1,16 @@ // REQUIRES: arm // RUN: llvm-mc -filetype=obj -triple=thumbv7a-windows-gnu %s -o %t.obj -// RUN: llvm-mc -filetype=obj -triple=thumbv7a-windows-gnu %S/Inputs/far-arm-thumb-abs20.s -o %t.far.obj -// RUN: not lld-link -entry:_start -subsystem:console %t.obj %t.far.obj -out:%t.exe 2>&1 | FileCheck %s +// RUN: not lld-link -entry:_start -subsystem:console %t.obj -out:%t.exe 2>&1 | FileCheck %s .syntax unified .globl _start _start: bne too_far20 + .space 0x100000 + .section .text$a, "xr" +too_far20: + bx lr -// CHECK: relocation out of range +// When trying to add a thunk at the end of the section, the thunk itself +// will be too far away, so this won't converge. + +// CHECK: adding thunks hasn't converged diff --git a/test/COFF/arm-thumb-thunks-multipass.s b/test/COFF/arm-thumb-thunks-multipass.s new file mode 100644 index 000000000000..5e64e8df49c8 --- /dev/null +++ b/test/COFF/arm-thumb-thunks-multipass.s @@ -0,0 +1,70 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=thumbv7-windows %s -o %t.obj +// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe -verbose 2>&1 | FileCheck -check-prefix=VERBOSE %s +// RUN: llvm-objdump -d %t.exe -start-address=0x403000 -stop-address=0x403008 | FileCheck -check-prefix=FUNC01 %s +// RUN: llvm-objdump -d %t.exe -start-address=0x404ffa -stop-address=0x405012 | FileCheck -check-prefix=FUNC01-THUNKS %s + +// VERBOSE: Added {{.*}} thunks with margin 204800 in 2 passes + + .syntax unified + .globl main + .text +main: + b func01 + bx lr + +.irp i, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18 + .section .text$\i\()a, "xr" + .balign 8192 +func\i: + bne far_func\i + bne func_within_margin\i + // Originally, the first section is less than 8192 bytes large, and the + // second one follows almost directly. After adding one thunk after + // the first section, the second one will move forward by 8192 bytes + // due to the alignment. + .space 8192 - 8 - 4 + + .section .text$\i\()b, "xr" + .balign 8192 +align\i: + nop +.endr + + .section .text$999, "xr" +tail: + .space 0x100000 - 100*1024 - 18*8192*2 + // Initially, these symbols are within range from all the sections above, + // even when taking the initial margin into account. After adding thunks + // to all the sections above, some of these are also out of range, forcing + // running a second pass. +.irp i, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18 +func_within_margin\i: + nop +.endr + .space 0x100000 + + // These are always out of range. +.irp i, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18 +far_func\i: + nop +.endr + bx lr + +// FUNC01: 403000: 41 f0 fc 87 bne.w #8184 <.text+0x3ffc> +// FUNC01: 403004: 41 f0 ff 87 bne.w #8190 <.text+0x4006> + +// Check that we only have two thunks here, even if we created the first +// thunk twice (once in the first pass, then thrown away and recreated +// in the second pass). + +// FUNC01-THUNKS: 404ffa: 00 00 movs r0, r0 +// The instruction above is padding from the .space +// FUNC01-THUNKS: 404ffc: 47 f2 1e 0c movw r12, #28702 +// FUNC01-THUNKS: 405000: c0 f2 20 0c movt r12, #32 +// FUNC01-THUNKS: 405004: e7 44 add pc, r12 +// FUNC01-THUNKS: 405006: 46 f6 f0 7c movw r12, #28656 +// FUNC01-THUNKS: 40500a: c0 f2 10 0c movt r12, #16 +// FUNC01-THUNKS: 40500e: e7 44 add pc, r12 +// The instruction below is padding from the .balign +// FUNC01-THUNKS: 405010: cc cc ldm r4!, {r2, r3, r6, r7} diff --git a/test/COFF/arm-thumb-thunks.s b/test/COFF/arm-thumb-thunks.s new file mode 100644 index 000000000000..33c3740ba8cb --- /dev/null +++ b/test/COFF/arm-thumb-thunks.s @@ -0,0 +1,75 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=thumbv7-windows %s -o %t.obj +// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe -verbose 2>&1 | FileCheck -check-prefix=VERBOSE %s +// RUN: llvm-objdump -d %t.exe -start-address=0x401000 -stop-address=0x401022 | FileCheck -check-prefix=MAIN %s +// RUN: llvm-objdump -d %t.exe -start-address=0x501022 -stop-address=0x501032 | FileCheck -check-prefix=FUNC1 %s +// RUN: llvm-objdump -d %t.exe -start-address=0x601032 | FileCheck -check-prefix=FUNC2 %s + +// VERBOSE: Added 3 thunks with margin {{.*}} in 1 passes + + .syntax unified + .globl main + .globl func1 + .text +main: + bne func1 + bne func2 + // This should reuse the same thunk as func1 above + bne func1_alias + bx lr + .section .text$a, "xr" + .space 0x100000 + .section .text$b, "xr" +func1: +func1_alias: + // This shouldn't reuse the func2 thunk from above, since it is out + // of range. + bne func2 + bx lr + .section .text$c, "xr" + .space 0x100000 + .section .text$d, "xr" +func2: +// Test using string tail merging. This is irrelevant to the thunking itself, +// but running multiple passes of assignAddresses() calls finalizeAddresses() +// multiple times; check that MergeChunk handles this correctly. + movw r0, :lower16:"??_C@string1" + movt r0, :upper16:"??_C@string1" + movw r1, :lower16:"??_C@string2" + movt r1, :upper16:"??_C@string2" + bx lr + + .section .rdata,"dr",discard,"??_C@string1" + .globl "??_C@string1" +"??_C@string1": + .asciz "foobar" + .section .rdata,"dr",discard,"??_C@string2" + .globl "??_C@string2" +"??_C@string2": + .asciz "bar" + +// MAIN: 401000: 40 f0 05 80 bne.w #10 <.text+0xe> +// MAIN: 401004: 40 f0 08 80 bne.w #16 <.text+0x18> +// MAIN: 401008: 40 f0 01 80 bne.w #2 <.text+0xe> +// MAIN: 40100c: 70 47 bx lr +// func1 thunk +// MAIN: 40100e: 40 f2 08 0c movw r12, #8 +// MAIN: 401012: c0 f2 10 0c movt r12, #16 +// MAIN: 401016: e7 44 add pc, r12 +// func2 thunk +// MAIN: 401018: 40 f2 0e 0c movw r12, #14 +// MAIN: 40101c: c0 f2 20 0c movt r12, #32 +// MAIN: 401020: e7 44 add pc, r12 + +// FUNC1: 501022: 40 f0 01 80 bne.w #2 <.text+0x100028> +// FUNC1: 501026: 70 47 bx lr +// func2 thunk +// FUNC1: 501028: 4f f6 fe 7c movw r12, #65534 +// FUNC1: 50102c: c0 f2 0f 0c movt r12, #15 +// FUNC1: 501030: e7 44 add pc, r12 + +// FUNC2: 601032: 42 f2 00 00 movw r0, #8192 +// FUNC2: 601036: c0 f2 60 00 movt r0, #96 +// FUNC2: 60103a: 42 f2 03 01 movw r1, #8195 +// FUNC2: 60103e: c0 f2 60 01 movt r1, #96 +// FUNC2: 601042: 70 47 bx lr diff --git a/test/COFF/arm64-delayimport.yaml b/test/COFF/arm64-delayimport.yaml new file mode 100644 index 000000000000..6d3d70564c04 --- /dev/null +++ b/test/COFF/arm64-delayimport.yaml @@ -0,0 +1,91 @@ +# REQUIRES: aarch64 + +# RUN: yaml2obj < %s > %t.obj +# RUN: lld-link /entry:main /subsystem:console /out:%t.exe %t.obj %p/Inputs/library-arm64.lib /alternatename:__delayLoadHelper2=main /delayload:library.dll +# RUN: llvm-objdump -d %t.exe | FileCheck %s -check-prefix DISASM +# RUN: llvm-readobj -coff-imports %t.exe | FileCheck %s -check-prefix IMPORTS + +# DISASM: 140001014: 11 00 00 d0 adrp x17, #8192 +# DISASM: 140001018: 31 22 00 91 add x17, x17, #8 +# DISASM: 14000101c: fd 7b b3 a9 stp x29, x30, [sp, #-208]! +# DISASM: 140001020: fd 03 00 91 mov x29, sp +# DISASM: 140001024: e0 07 01 a9 stp x0, x1, [sp, #16] +# DISASM: 140001028: e2 0f 02 a9 stp x2, x3, [sp, #32] +# DISASM: 14000102c: e4 17 03 a9 stp x4, x5, [sp, #48] +# DISASM: 140001030: e6 1f 04 a9 stp x6, x7, [sp, #64] +# DISASM: 140001034: e0 87 02 ad stp q0, q1, [sp, #80] +# DISASM: 140001038: e2 8f 03 ad stp q2, q3, [sp, #112] +# DISASM: 14000103c: e4 97 04 ad stp q4, q5, [sp, #144] +# DISASM: 140001040: e6 9f 05 ad stp q6, q7, [sp, #176] +# DISASM: 140001044: e1 03 11 aa mov x1, x17 +# DISASM: 140001048: 00 00 00 b0 adrp x0, #4096 +# DISASM: 14000104c: 00 00 00 91 add x0, x0, #0 +# DISASM: 140001050: ec ff ff 97 bl #-80 <.text> +# DISASM: 140001054: f0 03 00 aa mov x16, x0 +# DISASM: 140001058: e6 9f 45 ad ldp q6, q7, [sp, #176] +# DISASM: 14000105c: e4 97 44 ad ldp q4, q5, [sp, #144] +# DISASM: 140001060: e2 8f 43 ad ldp q2, q3, [sp, #112] +# DISASM: 140001064: e0 87 42 ad ldp q0, q1, [sp, #80] +# DISASM: 140001068: e6 1f 44 a9 ldp x6, x7, [sp, #64] +# DISASM: 14000106c: e4 17 43 a9 ldp x4, x5, [sp, #48] +# DISASM: 140001070: e2 0f 42 a9 ldp x2, x3, [sp, #32] +# DISASM: 140001074: e0 07 41 a9 ldp x0, x1, [sp, #16] +# DISASM: 140001078: fd 7b cd a8 ldp x29, x30, [sp], #208 +# DISASM: 14000107c: 00 02 1f d6 br x16 + +# IMPORTS: Format: COFF-ARM64 +# IMPORTS: Arch: aarch64 +# IMPORTS: AddressSize: 64bit +# IMPORTS: DelayImport { +# IMPORTS: Name: library.dll +# IMPORTS: Attributes: 0x1 +# IMPORTS: ModuleHandle: 0x3000 +# IMPORTS: ImportAddressTable: 0x3008 +# IMPORTS: ImportNameTable: 0x2040 +# IMPORTS: BoundDelayImportTable: 0x0 +# IMPORTS: UnloadDelayImportTable: 0x0 +# IMPORTS: Import { +# IMPORTS: Symbol: function (0) +# IMPORTS: Address: 0x140001014 +# IMPORTS: } +# IMPORTS: } + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_ARM64 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 00000094C0035FD6 + Relocations: + - VirtualAddress: 0 + SymbolName: function + Type: IMAGE_REL_ARM64_BRANCH26 +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 1 + - Name: main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: function + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/arm64-localimport-align.s b/test/COFF/arm64-localimport-align.s new file mode 100644 index 000000000000..4fbc79ec36d7 --- /dev/null +++ b/test/COFF/arm64-localimport-align.s @@ -0,0 +1,24 @@ +// REQUIRES: aarch64 +// RUN: llvm-mc -filetype=obj -triple=aarch64-windows %s -o %t.obj +// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe +// Don't check the output, just make sure it links fine and doesn't +// error out due to a misaligned load. + .text + .globl main + .globl myfunc +main: + adrp x8, __imp_myfunc + ldr x0, [x8, :lo12:__imp_myfunc] + br x0 + ret +myfunc: + ret + + .section .rdata, "dr" + // Start the .rdata section with a 4 byte chunk, to expose the alignment + // of the next chunk in the section. +mydata: + .byte 42 + // The synthesized LocalImportChunk gets stored here in the .rdata + // section, but needs to get proper 8 byte alignment since it is a + // pointer, just like regular LookupChunks in the IAT. diff --git a/test/COFF/arm64-relocs-imports.test b/test/COFF/arm64-relocs-imports.test index c7b8b7c28466..e2c00f189fef 100644 --- a/test/COFF/arm64-relocs-imports.test +++ b/test/COFF/arm64-relocs-imports.test @@ -34,14 +34,14 @@ # BEFORE: 64: e0 03 1f 2a mov w0, wzr # BEFORE: 68: fe 07 41 f8 ldr x30, [sp], #16 # BEFORE: 6c: c0 03 5f d6 ret -# BEFORE: 70: 08 00 00 00 <unknown> -# BEFORE: 74: 00 00 00 00 <unknown> -# BEFORE: 78: 01 00 00 00 <unknown> -# BEFORE: 7c: 01 00 00 00 <unknown> +# BEFORE: 70: 08 00 00 00 udf #8 +# BEFORE: 74: 00 00 00 00 udf #0 +# BEFORE: 78: 01 00 00 00 udf #1 +# BEFORE: 7c: 01 00 00 00 udf #1 # BEFORE: 80: 00 00 00 91 add x0, x0, #0 # BEFORE: 84: 00 00 40 91 add x0, x0, #0, lsl #12 # BEFORE: 88: 00 00 40 f9 ldr x0, [x0] -# BEFORE: 8c: 01 00 00 00 <unknown> +# BEFORE: 8c: 01 00 00 00 udf #1 # BEFORE: 90: 20 1a 09 30 adr x0, #74565 # BEFORE: 94: 01 00 00 54 b.ne #0 # BEFORE: 98: 00 00 00 36 tbz w0, #0, #0 @@ -76,13 +76,13 @@ # AFTER: 140001068: fe 07 41 f8 ldr x30, [sp], #16 # AFTER: 14000106c: c0 03 5f d6 ret # AFTER: 140001070: 10 20 00 40 <unknown> -# AFTER: 140001074: 01 00 00 00 <unknown> -# AFTER: 140001078: 09 20 00 00 <unknown> -# AFTER: 14000107c: 09 00 00 00 <unknown> +# AFTER: 140001074: 01 00 00 00 udf #1 +# AFTER: 140001078: 09 20 00 00 udf #8201 +# AFTER: 14000107c: 09 00 00 00 udf #9 # AFTER: 140001080: 00 20 0e 91 add x0, x0, #904 # AFTER: 140001084: 00 04 40 91 add x0, x0, #1, lsl #12 # AFTER: 140001088: 00 c4 41 f9 ldr x0, [x0, #904] -# AFTER: 14000108c: 03 00 00 00 <unknown> +# AFTER: 14000108c: 03 00 00 00 udf #3 # AFTER: 140001090: e0 95 09 30 adr x0, #78525 # AFTER: 140001094: 41 00 00 54 b.ne #8 # AFTER: 140001098: 20 00 00 36 tbz w0, #0, #4 diff --git a/test/COFF/associative-comdat-mingw.s b/test/COFF/associative-comdat-mingw.s new file mode 100644 index 000000000000..def20cd85294 --- /dev/null +++ b/test/COFF/associative-comdat-mingw.s @@ -0,0 +1,74 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t1.obj +# RUN: llvm-mc -triple=x86_64-windows-gnu %S/Inputs/associative-comdat-mingw-2.s -filetype=obj -o %t2.obj + +# RUN: lld-link -lldmingw -entry:main %t1.obj %t2.obj -out:%t.gc.exe -verbose +# RUN: llvm-readobj -sections %t.gc.exe | FileCheck %s + +# CHECK: Sections [ +# CHECK: Section { +# CHECK: Number: 2 +# CHECK-LABEL: Name: .rdata (2E 72 64 61 74 61 00 00) +# This is the critical check to show that only *one* definition of +# .xdata$foo was retained. This *must* be 0x24 (0x4 for the .xdata +# section and 0x20 for the .ctors/.dtors headers/ends). +# Make sure that no other .xdata sections get included, which would +# increase the size here. +# CHECK-NEXT: VirtualSize: 0x24 + + .text + .def main; + .scl 2; + .type 32; + .endef + .globl main + .p2align 4, 0x90 +main: + call foo + retq + +# Defines .text$foo (which has a leader symbol and is referenced like +# normally), and .xdata$foo (which lacks a leader symbol, which normally +# would be declared associative to the symbol foo). +# .xdata$foo should be implicitly treated as associative to foo and brought +# in, while .xdata$bar, implicitly associative to bar, not included, and +# .xdata$baz not included since there's no symbol baz. + +# GNU binutils ld doesn't do this at all, but always includes all .xdata/.pdata +# comdat sections, even if --gc-sections is used. + + .section .xdata$foo,"dr" + .linkonce discard + .p2align 3 + .long 42 + + .section .xdata$bar,"dr" + .linkonce discard + .p2align 3 + .long 43 + + .section .xdata$baz,"dr" + .linkonce discard + .p2align 3 + .long 44 + + .def foo; + .scl 2; + .type 32; + .endef + .section .text$foo,"xr",discard,foo + .globl foo + .p2align 4 +foo: + ret + + .def bar; + .scl 2; + .type 32; + .endef + .section .text$bar,"xr",discard,bar + .globl bar + .p2align 4 +bar: + ret diff --git a/test/COFF/autoimport-arm-code.s b/test/COFF/autoimport-arm-code.s new file mode 100644 index 000000000000..562a1a959e38 --- /dev/null +++ b/test/COFF/autoimport-arm-code.s @@ -0,0 +1,19 @@ +# REQUIRES: arm + +# RUN: echo -e ".global variable\n.global DllMainCRTStartup\n.thumb\n.text\nDllMainCRTStartup:\nbx lr\n.data\nvariable:\n.long 42" > %t-lib.s +# RUN: llvm-mc -triple=armv7-windows-gnu %t-lib.s -filetype=obj -o %t-lib.obj +# RUN: lld-link -out:%t-lib.dll -dll -entry:DllMainCRTStartup %t-lib.obj -lldmingw -implib:%t-lib.lib + +# RUN: llvm-mc -triple=armv7-windows-gnu %s -filetype=obj -o %t.obj +# RUN: not lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-lib.lib 2>&1 | FileCheck %s + +# CHECK: error: unable to automatically import from variable with relocation type IMAGE_REL_ARM_MOV32T + + .global main + .text + .thumb +main: + movw r0, :lower16:variable + movt r0, :upper16:variable + ldr r0, [r0] + bx lr diff --git a/test/COFF/autoimport-arm-data.s b/test/COFF/autoimport-arm-data.s new file mode 100644 index 000000000000..945d51c9423c --- /dev/null +++ b/test/COFF/autoimport-arm-data.s @@ -0,0 +1,42 @@ +# REQUIRES: arm + +# RUN: echo -e ".global variable\n.global DllMainCRTStartup\n.thumb\n.text\nDllMainCRTStartup:\nbx lr\n.data\nvariable:\n.long 42" > %t-lib.s +# RUN: llvm-mc -triple=armv7-windows-gnu %t-lib.s -filetype=obj -o %t-lib.obj +# RUN: lld-link -out:%t-lib.dll -dll -entry:DllMainCRTStartup %t-lib.obj -lldmingw -implib:%t-lib.lib + +# RUN: llvm-mc -triple=armv7-windows-gnu %s -filetype=obj -o %t.obj +# RUN: lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-lib.lib -verbose + +# RUN: llvm-readobj -coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s +# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=CONTENTS %s + +# IMPORTS: Import { +# IMPORTS-NEXT: Name: autoimport-arm-data.s.tmp-lib.dll +# IMPORTS-NEXT: ImportLookupTableRVA: 0x2050 +# IMPORTS-NEXT: ImportAddressTableRVA: 0x2058 +# IMPORTS-NEXT: Symbol: variable (0) +# IMPORTS-NEXT: } + +# Runtime pseudo reloc list header consisting of 0x0, 0x0, 0x1. +# First runtime pseudo reloc, with import from 0x2058, +# applied at 0x3000, with a size of 32 bits. +# CONTENTS: Contents of section .rdata: +# CONTENTS: 402000 00000000 00000000 01000000 58200000 +# CONTENTS: 402010 00300000 20000000 +# ptr: pointing at the IAT RVA at 0x2058 +# relocs: pointing at the runtime pseudo reloc list at +# 0x2000 - 0x2018. +# CONTENTS: Contents of section .data: +# CONTENTS: 403000 58204000 00204000 18204000 + + .global main + .text + .thumb +main: + bx lr + .data +ptr: + .long variable +relocs: + .long __RUNTIME_PSEUDO_RELOC_LIST__ + .long __RUNTIME_PSEUDO_RELOC_LIST_END__ diff --git a/test/COFF/autoimport-arm64-code.s b/test/COFF/autoimport-arm64-code.s new file mode 100644 index 000000000000..9f5cc8f89425 --- /dev/null +++ b/test/COFF/autoimport-arm64-code.s @@ -0,0 +1,18 @@ +# REQUIRES: aarch64 + +# RUN: echo -e ".global variable\n.global DllMainCRTStartup\n.text\nDllMainCRTStartup:\nret\n.data\nvariable:\n.long 42" > %t-lib.s +# RUN: llvm-mc -triple=aarch64-windows-gnu %t-lib.s -filetype=obj -o %t-lib.obj +# RUN: lld-link -out:%t-lib.dll -dll -entry:DllMainCRTStartup %t-lib.obj -lldmingw -implib:%t-lib.lib + +# RUN: llvm-mc -triple=aarch64-windows-gnu %s -filetype=obj -o %t.obj +# RUN: not lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-lib.lib 2>&1 | FileCheck %s + +# CHECK: error: unable to automatically import from variable with relocation type IMAGE_REL_ARM64_PAGEBASE_REL21 +# CHECK: error: unable to automatically import from variable with relocation type IMAGE_REL_ARM64_PAGEOFFSET_12L + + .global main + .text +main: + adrp x0, variable + ldr w0, [x0, :lo12:variable] + ret diff --git a/test/COFF/autoimport-arm64-data.s b/test/COFF/autoimport-arm64-data.s new file mode 100644 index 000000000000..be4d8706fe3a --- /dev/null +++ b/test/COFF/autoimport-arm64-data.s @@ -0,0 +1,42 @@ +# REQUIRES: aarch64 + +# RUN: echo -e ".global variable\n.global DllMainCRTStartup\n.text\nDllMainCRTStartup:\nret\n.data\nvariable:\n.long 42" > %t-lib.s +# RUN: llvm-mc -triple=aarch64-windows-gnu %t-lib.s -filetype=obj -o %t-lib.obj +# RUN: lld-link -out:%t-lib.dll -dll -entry:DllMainCRTStartup %t-lib.obj -lldmingw -implib:%t-lib.lib + +# RUN: llvm-mc -triple=aarch64-windows-gnu %s -filetype=obj -o %t.obj +# RUN: lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-lib.lib -verbose + +# RUN: llvm-readobj -coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s +# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=CONTENTS %s + +# IMPORTS: Import { +# IMPORTS-NEXT: Name: autoimport-arm64-data.s.tmp-lib.dll +# IMPORTS-NEXT: ImportLookupTableRVA: 0x2060 +# IMPORTS-NEXT: ImportAddressTableRVA: 0x2070 +# IMPORTS-NEXT: Symbol: variable (0) +# IMPORTS-NEXT: } + +# Runtime pseudo reloc list header consisting of 0x0, 0x0, 0x1. +# First runtime pseudo reloc, with import from 0x2070, +# applied at 0x3000, with a size of 32 bits. +# CONTENTS: Contents of section .rdata: +# CONTENTS: 140002000 00000000 00000000 01000000 70200000 +# CONTENTS: 140002010 00300000 40000000 +# ptr: pointing at the IAT RVA at 0x2070 +# relocs: pointing at the runtime pseudo reloc list at +# 0x2000 - 0x2018. +# CONTENTS: Contents of section .data: +# CONTENTS: 140003000 70200040 01000000 00200040 01000000 +# CONTENTS: 140003010 18200040 01000000 + + .global main + .text +main: + ret + .data +ptr: + .quad variable +relocs: + .quad __RUNTIME_PSEUDO_RELOC_LIST__ + .quad __RUNTIME_PSEUDO_RELOC_LIST_END__ diff --git a/test/COFF/autoimport-gnu-implib.s b/test/COFF/autoimport-gnu-implib.s new file mode 100644 index 000000000000..375e0a5857e5 --- /dev/null +++ b/test/COFF/autoimport-gnu-implib.s @@ -0,0 +1,26 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-head.s -filetype=obj -o %t-dabcdh.o +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-data.s -filetype=obj -o %t-dabcds00000.o +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-tail.s -filetype=obj -o %t-dabcdt.o +# RUN: rm -f %t-implib.a +# RUN: llvm-ar rcs %t-implib.a %t-dabcdh.o %t-dabcds00000.o %t-dabcdt.o + +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj +# RUN: lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-implib.a -verbose + +# RUN: llvm-readobj -coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s + +# IMPORTS: Import { +# IMPORTS-NEXT: Name: foo.dll +# IMPORTS-NEXT: ImportLookupTableRVA: +# IMPORTS-NEXT: ImportAddressTableRVA: +# IMPORTS-NEXT: Symbol: data (0) +# IMPORTS-NEXT: } + + .global main + .text +main: + movl data(%rip), %eax + ret + .data diff --git a/test/COFF/autoimport-list-ptrs.s b/test/COFF/autoimport-list-ptrs.s new file mode 100644 index 000000000000..d3c9d3d07dbb --- /dev/null +++ b/test/COFF/autoimport-list-ptrs.s @@ -0,0 +1,20 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj +# RUN: lld-link -lldmingw -out:%t.exe -entry:main %t.obj -verbose + +# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=CONTENTS %s + +# Even if we didn't actually write any pseudo relocations, +# check that the synthetic pointers still are set to a non-null value +# CONTENTS: Contents of section .data: +# CONTENTS: 140003000 00200040 01000000 00200040 01000000 + + .global main + .text +main: + retq + .data +relocs: + .quad __RUNTIME_PSEUDO_RELOC_LIST__ + .quad __RUNTIME_PSEUDO_RELOC_LIST_END__ diff --git a/test/COFF/autoimport-refptr.s b/test/COFF/autoimport-refptr.s new file mode 100644 index 000000000000..4b11a8adde84 --- /dev/null +++ b/test/COFF/autoimport-refptr.s @@ -0,0 +1,65 @@ +# REQUIRES: x86 + +# RUN: echo -e ".global variable\n.global DllMainCRTStartup\n.text\nDllMainCRTStartup:\nret\n.data\nvariable:\n.long 42" > %t-lib.s +# RUN: llvm-mc -triple=x86_64-windows-gnu %t-lib.s -filetype=obj -o %t-lib.obj +# RUN: lld-link -out:%t-lib.dll -dll -entry:DllMainCRTStartup %t-lib.obj -lldmingw -implib:%t-lib.lib + +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj +# RUN: lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-lib.lib -verbose + +# RUN: llvm-readobj -coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s +# RUN: llvm-objdump -d %t.exe | FileCheck -check-prefix=DISASM %s +# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=CONTENTS %s + +# IMPORTS: Import { +# IMPORTS-NEXT: Name: autoimport-refptr.s.tmp-lib.dll +# IMPORTS-NEXT: ImportLookupTableRVA: 0x2050 +# IMPORTS-NEXT: ImportAddressTableRVA: 0x2060 +# IMPORTS-NEXT: Symbol: variable (0) +# IMPORTS-NEXT: } + +# DISASM: Disassembly of section .text: +# DISASM: .text: +# Relative offset at 0x1002 pointing at the IAT at 0x2060 +# DISASM: 140001000: 48 8b 05 59 10 00 00 movq 4185(%rip), %rax +# DISASM: 140001007: 8b 00 movl (%rax), %eax +# Relative offset at 0x100b pointing at the .refptr.localvar stub at +# 0x2000 +# DISASM: 140001009: 48 8b 0d f0 0f 00 00 movq 4080(%rip), %rcx +# DISASM: 140001010: 03 01 addl (%rcx), %eax +# DISASM: 140001012: c3 retq + +# relocs: pointing at an empty list of runtime pseudo relocs. +# localvar: 42 +# CONTENTS: Contents of section .data: +# CONTENTS: 140003000 08200040 01000000 08200040 01000000 +# CONTENTS: 140003010 2a000000 + + .global main + .global localvar + .text +main: + movq .refptr.variable(%rip), %rax + movl (%rax), %eax + movq .refptr.localvar(%rip), %rcx + addl (%rcx), %eax + ret + + .data +relocs: + .quad __RUNTIME_PSEUDO_RELOC_LIST__ + .quad __RUNTIME_PSEUDO_RELOC_LIST_END__ +localvar: + .int 42 + +# Normally the compiler wouldn't emit a stub for a variable that is +# emitted in the same translation unit. + .section .rdata$.refptr.localvar,"dr",discard,.refptr.localvar + .global .refptr.localvar +.refptr.localvar: + .quad localvar + + .section .rdata$.refptr.variable,"dr",discard,.refptr.variable + .global .refptr.variable +.refptr.variable: + .quad variable diff --git a/test/COFF/autoimport-x86.s b/test/COFF/autoimport-x86.s new file mode 100644 index 000000000000..379985e88097 --- /dev/null +++ b/test/COFF/autoimport-x86.s @@ -0,0 +1,53 @@ +# REQUIRES: x86 + +# RUN: echo -e ".global variable\n.global DllMainCRTStartup\n.text\nDllMainCRTStartup:\nret\n.data\nvariable:\n.long 42" > %t-lib.s +# RUN: llvm-mc -triple=x86_64-windows-gnu %t-lib.s -filetype=obj -o %t-lib.obj +# RUN: lld-link -out:%t-lib.dll -dll -entry:DllMainCRTStartup %t-lib.obj -lldmingw -implib:%t-lib.lib + +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj +# RUN: lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-lib.lib -verbose + +# RUN: llvm-readobj -coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s +# RUN: llvm-objdump -d %t.exe | FileCheck -check-prefix=DISASM %s +# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=CONTENTS %s + +# IMPORTS: Import { +# IMPORTS-NEXT: Name: autoimport-x86.s.tmp-lib.dll +# IMPORTS-NEXT: ImportLookupTableRVA: 0x2070 +# IMPORTS-NEXT: ImportAddressTableRVA: 0x2080 +# IMPORTS-NEXT: Symbol: variable (0) +# IMPORTS-NEXT: } + +# DISASM: Disassembly of section .text: +# DISASM: .text: +# Relative offset at 0x1002 pointing at the IAT at 0x2080. +# DISASM: 140001000: 8b 05 7a 10 00 00 movl 4218(%rip), %eax +# DISASM: 140001006: c3 retq + +# Runtime pseudo reloc list header consisting of 0x0, 0x0, 0x1. +# First runtime pseudo reloc, with import from 0x2080, +# applied at 0x1002, with a size of 32 bits. +# Second runtime pseudo reloc, with import from 0x2080, +# applied at 0x3000, with a size of 64 bits. +# CONTENTS: Contents of section .rdata: +# CONTENTS: 140002000 00000000 00000000 01000000 80200000 +# CONTENTS: 140002010 02100000 20000000 80200000 00300000 +# CONTENTS: 140002020 40000000 +# ptr: pointing at the IAT RVA at 0x2080 +# relocs: pointing at the runtime pseudo reloc list at +# 0x2000 - 0x2024. +# CONTENTS: Contents of section .data: +# CONTENTS: 140003000 80200040 01000000 00200040 01000000 +# CONTENTS: 140003010 24200040 01000000 + + .global main + .text +main: + movl variable(%rip), %eax + ret + .data +ptr: + .quad variable +relocs: + .quad __RUNTIME_PSEUDO_RELOC_LIST__ + .quad __RUNTIME_PSEUDO_RELOC_LIST_END__ diff --git a/test/COFF/baserel.test b/test/COFF/baserel.test index 6441bb2be30d..a10d6ed4d08d 100644 --- a/test/COFF/baserel.test +++ b/test/COFF/baserel.test @@ -47,9 +47,9 @@ # RUN: llvm-readobj -file-headers -sections %t.exe | FileCheck %s \ # RUN: --check-prefix=BASEREL-HEADER # -# RN: lld-link /out:%t.exe /entry:main /fixed %t.obj %p/Inputs/std64.lib -# RN: llvm-readobj -file-headers %t.exe | FileCheck %s \ -# RN: --check-prefix=NOBASEREL-HEADER +# RUN: lld-link /out:%t.exe /entry:main /fixed %t.obj %p/Inputs/std64.lib +# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s \ +# RUN: --check-prefix=NOBASEREL-HEADER # # BASEREL-HEADER-NOT: IMAGE_FILE_RELOCS_STRIPPED # diff --git a/test/COFF/broken-arm-reloc.yaml b/test/COFF/broken-arm-reloc.yaml new file mode 100644 index 000000000000..ad4328bcb142 --- /dev/null +++ b/test/COFF/broken-arm-reloc.yaml @@ -0,0 +1,92 @@ +# REQUIRES: arm + +# .global main +# .global variable +# .text +# .thumb +#main: +# movw r0, :lower16:variable +# nop +# movt r0, :upper16:variable +# ldr r0, [r0] +# bx lr +# .data +#variable: +# .long 42 + +# RUN: yaml2obj %s > %t.obj +# RUN: not lld-link -out:%t.exe -entry:main %t.obj 2>&1 | FileCheck %s + +# CHECK: error: unexpected instruction in MOVT instruction in MOV32T relocation + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_ARMNT + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 40F2000000BFC0F2000000687047 + Relocations: + - VirtualAddress: 0 + SymbolName: variable + Type: IMAGE_REL_ARM_MOV32T + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: 2A000000 + - Name: .bss + Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 14 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 2762100735 + Number: 1 + - Name: .data + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 4 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 3482275674 + Number: 2 + - Name: .bss + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 3 + - Name: main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: variable + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/comdat-jumptable.s b/test/COFF/comdat-jumptable.s new file mode 100644 index 000000000000..31a7c5f6bcdf --- /dev/null +++ b/test/COFF/comdat-jumptable.s @@ -0,0 +1,70 @@ +# REQUIRES: x86 +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t1.obj +# RUN: llvm-mc -triple=x86_64-windows-gnu %S/Inputs/comdat-jumptable2.s -filetype=obj -o %t2.obj + +# RUN: llvm-objdump -s %t1.obj | FileCheck --check-prefix=OBJ1 %s +# RUN: llvm-objdump -s %t2.obj | FileCheck --check-prefix=OBJ2 %s + +# RUN: lld-link -lldmingw -entry:main %t1.obj %t2.obj -out:%t.exe +# RUN: llvm-objdump -s %t.exe | FileCheck --check-prefix=EXE %s + +# Test linking cases where comdat functions have an associated jump table +# in a non-comdat rdata (which GCC produces for functions with jump tables). +# In these cases, ld.bfd keeps all rdata sections, but the relocations that +# refer to discarded comdat sections just are emitted as they were originally. + +# In real scenarios, the jump table .rdata section should be identical across +# all object files; here it is different to illustrate more clearly what +# the linker actually does. + +# OBJ1: Contents of section .rdata: +# OBJ1: 0000 aaaaaaaa 14000000 1e000000 28000000 +# OBJ1: 0010 bbbbbbbb + +# OBJ2: Contents of section .rdata: +# OBJ2: 0000 cccccccc 14000000 1e000000 28000000 +# OBJ2: 0010 dddddddd + +# EXE: Contents of section .rdata: +# EXE: 140002000 aaaaaaaa 0c100000 12100000 18100000 +# EXE: 140002010 bbbbbbbb cccccccc 14000000 1e000000 +# EXE: 140002020 28000000 dddddddd + + + .section .text@comdatfunc, "x" + .linkonce discard + .globl comdatfunc +comdatfunc: + leaq .Ljumptable(%rip), %rax + movslq (%rax, %rcx, 4), %rcx + addq %rcx, %rax + jmp *%rax + + .section .rdata, "dr" + .long 0xaaaaaaaa +.Ljumptable: + .long .Ltail1-.Ljumptable + .long .Ltail2-.Ljumptable + .long .Ltail3-.Ljumptable + .long 0xbbbbbbbb + + .section .text@comdatfunc, "x" +# If assembled with binutils, the following line can be kept in: +# .linkonce discard +.Ltail1: + movl $1, %eax + ret +.Ltail2: + movl $2, %eax + ret +.Ltail3: + movl $3, %eax + ret + + + .text + .globl main +main: + call comdatfunc + call otherfunc + ret diff --git a/test/COFF/comdat-weak.test b/test/COFF/comdat-weak.test new file mode 100644 index 000000000000..a2b4688bc4f4 --- /dev/null +++ b/test/COFF/comdat-weak.test @@ -0,0 +1,82 @@ +RUN: lld-link -lldmingw %S/Inputs/inline-weak.o %S/Inputs/inline-weak2.o -out:%t.exe + +When compiling certain forms of templated inline functions, some +versions of GCC (tested with 5.4) produces a weak symbol for the function. +Newer versions of GCC don't do this though. + +The bundled object files are an example of that, they can be produced +with test code like this: + +$ cat inline-weak.h +class MyClass { +public: + template<typename... _Args> int get(_Args&&... args) { + return a; + } +private: + int a; +}; + +$ cat inline-weak.cpp +#include "inline-weak.h" + +int get(MyClass& a); + +int main(int argc, char* argv[]) { + MyClass a; + int ret = a.get(); + ret += get(a); + return ret; +} +extern "C" void mainCRTStartup(void) { + main(0, (char**)0); +} +extern "C" void __main(void) { +} + +$ cat inline-weak2.cpp +#include "inline-weak.h" + +int get(MyClass& a) { + return a.get(); +} + +$ x86_64-w64-mingw32-g++ -std=c++11 -c inline-weak.cpp +$ x86_64-w64-mingw32-g++ -std=c++11 -c inline-weak2.cpp + +$ x86_64-w64-mingw32-nm inline-weak.o | grep MyClass3get +0000000000000000 p .pdata$_ZN7MyClass3getIJEEEiDpOT_ +0000000000000000 t .text$_ZN7MyClass3getIJEEEiDpOT_ +0000000000000000 T .weak._ZN7MyClass3getIIEEEiDpOT_.main +0000000000000000 r .xdata$_ZN7MyClass3getIJEEEiDpOT_ + w _ZN7MyClass3getIIEEEiDpOT_ +0000000000000000 T _ZN7MyClass3getIJEEEiDpOT_ + +$ x86_64-w64-mingw32-nm inline-weak2.o | grep MyClass3get +0000000000000000 p .pdata$_ZN7MyClass3getIJEEEiDpOT_ +0000000000000000 t .text$_ZN7MyClass3getIJEEEiDpOT_ +0000000000000000 T .weak._ZN7MyClass3getIIEEEiDpOT_._Z3getR7MyClass +0000000000000000 r .xdata$_ZN7MyClass3getIJEEEiDpOT_ + w _ZN7MyClass3getIIEEEiDpOT_ +0000000000000000 T _ZN7MyClass3getIJEEEiDpOT_ + +This can't be reproduced by assembling .s files with llvm-mc, since that +always produces a symbol named .weak.<weaksymbol>.default, therefore +the test uses prebuilt object files instead. + +In these cases, the undefined weak symbol points to the regular symbol +.weak._ZN7MyClass3getIIEEEiDpOT_.<othersymbol>, where <othersymbol> +varies among the object files that emit the same function. This regular +symbol points to the same location as the comdat function +_ZN7MyClass3getIJEEEiDpOT_. + +When linking, the comdat section from the second object file gets +discarded, as it matches the one that already exists. This means that +the uniquely named symbol .weak.<weakname>.<othername> points to a +discarded section chunk. + +Previously, this would have triggered adding an Undefined symbol for +this case, which would later break linking. However, also previously, +if the second object file is linked in via a static library, this +leftover symbol is retained as a Lazy symbol, which would make the link +succeed. diff --git a/test/COFF/common-replacement.s b/test/COFF/common-replacement.s new file mode 100644 index 000000000000..115ebe5bfd11 --- /dev/null +++ b/test/COFF/common-replacement.s @@ -0,0 +1,35 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t1.obj +# RUN: llvm-mc -triple=x86_64-windows-gnu %S/Inputs/common-replacement.s -filetype=obj -o %t2.obj + +# RUN: lld-link -lldmingw -entry:main %t1.obj %t2.obj -out:%t.exe -verbose 2>&1 \ +# RUN: | FileCheck -check-prefix VERBOSE %s +# RUN: llvm-readobj -s %t.exe | FileCheck -check-prefix SECTIONS %s + +# VERBOSE: -aligncomm:"foo",2 + +# As long as the .comm symbol is replaced with actual data, RawDataSize +# below should be nonzero. + +# SECTIONS: Name: .data (2E 64 61 74 61 00 00 00) +# SECTIONS-NEXT: VirtualSize: 0x8 +# SECTIONS-NEXT: VirtualAddress: 0x3000 +# SECTIONS-NEXT: RawDataSize: 512 + + + .text + .def main; + .scl 2; + .type 32; + .endef + .globl main + .p2align 4, 0x90 +main: + movl foo(%rip), %eax + retq + +# This produces an aligncomm directive, but when linking in +# Inputs/common-replacement.s, this symbol is replaced by a normal defined +# symbol instead. + .comm foo, 4, 2 diff --git a/test/COFF/could-not-open.test b/test/COFF/could-not-open.test new file mode 100644 index 000000000000..87f11c34e7d4 --- /dev/null +++ b/test/COFF/could-not-open.test @@ -0,0 +1,5 @@ +RUN: not lld-link 01 2>&1 | FileCheck %s + +CHECK: could not open 01 +CHECK-NOT: /machine is not specified +CHECK-NOT: subsystem must be defined diff --git a/test/COFF/crt-dyn-initializer-order.test b/test/COFF/crt-dyn-initializer-order.test new file mode 100644 index 000000000000..963b0657793b --- /dev/null +++ b/test/COFF/crt-dyn-initializer-order.test @@ -0,0 +1,100 @@ +# // a.cpp
+# #include <iostream>
+# #include <vector>
+#
+# template <int Magic> struct TemplatedObject {
+# static std::vector<TemplatedObject<Magic> *> Instances;
+# TemplatedObject() { Instances.push_back(this); }
+# };
+#
+# using Object = TemplatedObject<0>;
+# template <> std::vector<Object *> Object::Instances{};
+# Object idle{};
+#
+# int main() {
+# if (Object::Instances.size() == 0)
+# std::cout << "It's broken" << std::endl;
+# else
+# std::cout << "It works!" << std::endl;
+# return 0;
+# }
+# // using `clang-cl /c a.cpp | lld-link a.obj` works
+# // using `cl /c a.cpp | lld-link a.obj` fails without lld/COFF/Writer.cpp/Writer::sortSectionChunks()
+
+# RUN: yaml2obj %s > %t.obj
+# RUN: yaml2obj %S/Inputs/crt-dyn-initializer-order_1.yaml > %t1.obj
+# RUN: yaml2obj %S/Inputs/crt-dyn-initializer-order_2.yaml > %t2.obj
+
+# CHECK: Name: .CRT
+# CHECK: Characteristics [
+# CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA
+# CHECK-NEXT: IMAGE_SCN_MEM_READ
+# CHECK-NEXT: ]
+# CHECK-NEXT: SectionData (
+
+# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t.obj %t1.obj %t2.obj
+# RUN: llvm-readobj -sections -section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE1
+# CASE1-NEXT: 01020304 55701011 1205
+
+# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t.obj %t2.obj %t1.obj
+# RUN: llvm-readobj -sections -section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE2
+# CASE2-NEXT: 01020304 10111255 7005
+
+# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t1.obj %t2.obj %t.obj
+# RUN: llvm-readobj -sections -section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE3
+# CASE3-NEXT: 01557010 11120203 0405
+
+# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t1.obj %t.obj %t2.obj
+# RUN: llvm-readobj -sections -section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE4
+# CASE4-NEXT: 01557002 03041011 1205
+
+# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t2.obj %t1.obj %t.obj
+# RUN: llvm-readobj -sections -section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE5
+# CASE5-NEXT: 01101112 55700203 0405
+
+# RUN: lld-link /out:%t.dll /entry:__ImageBase /dll %t2.obj %t.obj %t1.obj
+# RUN: llvm-readobj -sections -section-data %t.dll | FileCheck %s --check-prefixes CHECK,CASE6
+# CASE6-NEXT: 01101112 02030455 7005
+
+# CHECK-NEXT: )
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: [ ]
+sections:
+ - Name: '.CRT$XCA'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 01
+ - Name: '.CRT$XCU'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 02
+ - Name: '.CRT$XCU'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_LNK_COMDAT ]
+ Alignment: 1
+ SectionData: 03
+ - Name: '.CRT$XCU'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 04
+ - Name: '.CRT$XCZ'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ SectionData: 05
+symbols:
+ - Name: '.CRT$XCU'
+ Value: 0
+ SectionNumber: 3
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 1
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 1
+ Number: 2
+ Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE
+...
diff --git a/test/COFF/ctors_dtors_priority.s b/test/COFF/ctors_dtors_priority.s index efa03543027b..d50877f5afc5 100644 --- a/test/COFF/ctors_dtors_priority.s +++ b/test/COFF/ctors_dtors_priority.s @@ -1,12 +1,17 @@ # REQUIRES: x86 # RUN: llvm-mc -triple=x86_64-windows-gnu -filetype=obj -o %t.obj %s -# RUN: lld-link -entry:main %t.obj -out:%t.exe +# RUN: lld-link -lldmingw -entry:main %t.obj -out:%t.exe # RUN: llvm-objdump -s %t.exe | FileCheck %s .globl main main: nop +# Check that these symbols point at the right spots. +.data + .quad __CTOR_LIST__ + .quad __DTOR_LIST__ + .section .ctors.00005, "w" .quad 2 .section .ctors, "w" @@ -15,16 +20,26 @@ main: .quad 3 .section .dtors, "w" - .quad 1 + .quad 4 .section .dtors.00100, "w" - .quad 3 + .quad 6 .section .dtors.00005, "w" - .quad 2 + .quad 5 + +# Also test that the .CRT section is merged into .rdata -# CHECK: Contents of section .ctors: -# CHECK-NEXT: 140002000 01000000 00000000 02000000 00000000 -# CHECK-NEXT: 140002010 03000000 00000000 +.section .CRT$XCA, "dw" + .quad 7 + .quad 8 -# CHECK: Contents of section .dtors: -# CHECK-NEXT: 140003000 01000000 00000000 02000000 00000000 -# CHECK-NEXT: 140003010 03000000 00000000 +# CHECK: Contents of section .rdata: +# CHECK-NEXT: 140002000 07000000 00000000 08000000 00000000 +# CHECK-NEXT: 140002010 ffffffff ffffffff 01000000 00000000 +# CHECK-NEXT: 140002020 02000000 00000000 03000000 00000000 +# CHECK-NEXT: 140002030 00000000 00000000 ffffffff ffffffff +# CHECK-NEXT: 140002040 04000000 00000000 05000000 00000000 +# CHECK-NEXT: 140002050 06000000 00000000 00000000 00000000 +# __CTOR_LIST__ pointing at 0x140002010 and +# __DTOR_LIST__ pointing at 0x140002038. +# CHECK-NEXT: Contents of section .data: +# CHECK-NEXT: 140003000 10200040 01000000 38200040 01000000 diff --git a/test/COFF/debug-fastlink.test b/test/COFF/debug-fastlink.test new file mode 100644 index 000000000000..10b414195da3 --- /dev/null +++ b/test/COFF/debug-fastlink.test @@ -0,0 +1,12 @@ +# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj +# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj + +; If /DEBUG:FASTLINK is specified, /DEBUG:FULL is used instead +# RUN: rm -f %t.pdb +# RUN: lld-link /DEBUG /pdb:%t.pdb /DEBUG:FASTLINK /entry:main /nodefaultlib %t1.obj %t2.obj \ +# RUN: 2>&1 | FileCheck %s + +# CHECK: /debug:fastlink unsupported; using /debug:full + +# RUN: ls %t.pdb + diff --git a/test/COFF/debug-reloc.s b/test/COFF/debug-reloc.s index 57ab9bf9cdbc..897f31a6b5ed 100644 --- a/test/COFF/debug-reloc.s +++ b/test/COFF/debug-reloc.s @@ -8,35 +8,35 @@ # RUN: llvm-readobj -file-headers %t.exe | FileCheck %s -check-prefix HEADERS # RUN: llvm-readobj -coff-debug-directory %t.exe | FileCheck %s -check-prefix DEBUG -# SECTIONS: Number: 2 +# SECTIONS: Number: 3 # SECTIONS-NEXT: Name: .buildid (2E 62 75 69 6C 64 69 64) # SECTIONS-NEXT: VirtualSize: 0x35 -# SECTIONS-NEXT: VirtualAddress: 0x2000 -# SECTIONS: Number: 3 +# SECTIONS-NEXT: VirtualAddress: 0x3000 +# SECTIONS: Number: 4 # SECTIONS-NEXT: Name: .data (2E 64 61 74 61 00 00 00) # SECTIONS-NEXT: VirtualSize: 0x8 -# SECTIONS-NEXT: VirtualAddress: 0x3000 +# SECTIONS-NEXT: VirtualAddress: 0x4000 # RELOCS: BaseReloc [ # RELOCS-NEXT: Entry { # RELOCS-NEXT: Type: DIR64 -# RELOCS-NEXT: Address: 0x3000 +# RELOCS-NEXT: Address: 0x4000 # RELOCS-NEXT: } # RELOCS-NEXT: Entry { # RELOCS-NEXT: Type: ABSOLUTE -# RELOCS-NEXT: Address: 0x3000 +# RELOCS-NEXT: Address: 0x4000 # RELOCS-NEXT: } # RELOCS-NEXT: ] -# HEADERS: DebugRVA: 0x2000 +# HEADERS: DebugRVA: 0x3000 # HEADERS: DebugSize: 0x1C # DEBUG: DebugDirectory [ # DEBUG: DebugEntry { # DEBUG: Type: CodeView (0x2) # DEBUG: SizeOfData: 0x19 -# DEBUG: AddressOfRawData: 0x201C -# DEBUG: PointerToRawData: 0x61C +# DEBUG: AddressOfRawData: 0x301C +# DEBUG: PointerToRawData: 0x81C .text .def mainfunc; diff --git a/test/COFF/directives.s b/test/COFF/directives.s new file mode 100644 index 000000000000..9c4b7efd1dc9 --- /dev/null +++ b/test/COFF/directives.s @@ -0,0 +1,46 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -triple=x86_64-windows %s -filetype=obj -o %t.obj + +# RUN: lld-link -dll -out:%t.dll -entry:entry %t.obj -subsystem:console +# RUN: llvm-objdump -p %t.dll | FileCheck %s + +# CHECK: Export Table: +# CHECK: DLL name: directives.s.tmp.dll +# CHECK: Ordinal RVA Name +# CHECK-NEXT: 0 0 +# CHECK-NEXT: 1 0x1000 exportfn1 +# CHECK-NEXT: 2 0x1000 exportfn2 +# CHECK-NEXT: 3 0x1000 exportfn3 +# CHECK-NEXT: 4 0x1000 exportfn4 +# CHECK-NEXT: 5 0x1000 exportfn5 +# CHECK-NEXT: 6 0x1000 exportfn6 + + .global entry + .global exportfn1 + .global exportfn2 + .global exportfn3 + .global exportfn4 + .global exportfn5 + .global exportfn6 + .text +entry: +exportfn1: +exportfn2: +exportfn3: +exportfn4: +exportfn5: +exportfn6: + ret + .section .drectve +# Test that directive strings can be separated by any combination of +# spaces and null bytes. + .ascii "-export:exportfn1 " + .asciz "-export:exportfn2" + .asciz "-export:exportfn3" + .asciz "-export:exportfn4 " + .byte 0 + .ascii " " + .byte 0 + .asciz "-export:exportfn5" + .asciz " -export:exportfn6" diff --git a/test/COFF/duplicate-imp-func.s b/test/COFF/duplicate-imp-func.s new file mode 100644 index 000000000000..fc0cf1ef6ae0 --- /dev/null +++ b/test/COFF/duplicate-imp-func.s @@ -0,0 +1,43 @@ +# REQUIRES: x86 + +# RUN: echo -e ".globl libfunc\n.text\nlibfunc:\nret" > %t.lib.s +# RUN: llvm-mc -triple=x86_64-windows-gnu %t.lib.s -filetype=obj -o %t.lib.o +# RUN: lld-link -lldmingw -dll -out:%t.lib.dll -entry:libfunc %t.lib.o -implib:%t.lib.dll.a + +# RUN: echo -e ".globl helper1\n.text\nhelper1:\ncall libfunc\nret" > %t.helper1.s +# RUN: echo -e ".globl helper2\n.text\nhelper2:\nret\n.globl libfunc\n.globl __imp_libfunc\nlibfunc:\nret\n.data\n__imp_libfunc:\n.quad libfunc" > %t.helper2.s +# RUN: llvm-mc -triple=x86_64-windows-gnu %t.helper1.s -filetype=obj -o %t.helper1.o +# RUN: llvm-mc -triple=x86_64-windows-gnu %t.helper2.s -filetype=obj -o %t.helper2.o + +# RUN: llvm-ar rcs %t.helper.a %t.helper1.o %t.helper2.o + +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.main.o + +# Simulate a setup, where two libraries provide the same import function; +# %t.lib.dll.a is a pure import library which provides "libfunc". +# %t.helper.a is a static library which contains "helper1" and "helper2". +# +# helper1 contains an undefined reference to libfunc. helper2 contains a +# fake local implementation of libfunc, together with the __imp_libfunc +# stub. +# +# %t.lib.dll.a is listed before %t.helper.a on the command line. After +# including helper1, the library member that first declared the Lazy libfunc +# (%t.lib.dll.a) gets enqueued to be loaded. Before that gets done, helper2 +# gets loaded, which also turns out to provide a definition of libfunc. +# Once the import library member from %t.lib.dll.a gets loaded, libfunc +# and __imp_libfunc already are defined. + +# Just check that this fails cleanly (doesn't crash). +# RUN: not lld-link -lldmingw -out:%t.main.exe -entry:main %t.main.o %t.lib.dll.a %t.helper.a + +# Test with %t.helper.a on the command line; in this case we won't try to +# include libfunc from %t.lib.dll.a and everything works fine. +# RUN: lld-link -lldmingw -out:%t.main.exe -entry:main %t.main.o %t.helper.a %t.lib.dll.a + + .globl main + .text +main: + call helper1 + call helper2 + ret diff --git a/test/COFF/entry-inference-mingw.s b/test/COFF/entry-inference-mingw.s new file mode 100644 index 000000000000..cf356205eb22 --- /dev/null +++ b/test/COFF/entry-inference-mingw.s @@ -0,0 +1,44 @@ +# REQUIRES: x86 +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.o + +# RUN: lld-link -lldmingw %t.o -out:%t-default.exe 2>&1 | FileCheck -allow-empty -check-prefix=LINK %s +# RUN: lld-link -lldmingw %t.o -out:%t-cui.exe -subsystem:console 2>&1 | FileCheck -allow-empty -check-prefix=LINK %s +# RUN: lld-link -lldmingw %t.o -out:%t-gui.exe -subsystem:windows 2>&1 | FileCheck -allow-empty -check-prefix=LINK %s + +# RUN: llvm-readobj -file-headers %t-default.exe | FileCheck -check-prefix=CUI %s +# RUN: llvm-readobj -file-headers %t-cui.exe | FileCheck -check-prefix=CUI %s +# RUN: llvm-readobj -file-headers %t-gui.exe | FileCheck -check-prefix=GUI %s + +# Check that this doesn't print any warnings. +# LINK-NOT: found both wmain and main + +# CUI: AddressOfEntryPoint: 0x1001 +# CUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3) + +# GUI: AddressOfEntryPoint: 0x1002 +# GUI: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI (0x2) + + + .text + .globl mainCRTStartup + .globl WinMainCRTStartup +# MinGW only uses the entry points above, these other ones aren't +# used as entry. + .globl main + .globl wmain + .globl wmainCRTStartup + .globl wWinMainCRTStartup +foo: + ret +mainCRTStartup: + ret +WinMainCRTStartup: + ret +main: + ret +wmain: + ret +wmainCRTStartup: + ret +wWinMainCRTStartup: + ret diff --git a/test/COFF/entry-inference.test b/test/COFF/entry-inference.test index 294870bf4185..b58a23a30e80 100644 --- a/test/COFF/entry-inference.test +++ b/test/COFF/entry-inference.test @@ -1,18 +1,26 @@ # RUN: sed -e s/ENTRYNAME/main/ %s | yaml2obj > %t.obj # RUN: not lld-link /out:%t.exe %t.obj > %t.log 2>&1 # RUN: FileCheck -check-prefix=MAIN %s < %t.log +# RUN: not lld-link /nodefaultlib /out:%t.exe %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=MAIN %s < %t.log # RUN: sed s/ENTRYNAME/wmain/ %s | yaml2obj > %t.obj # RUN: not lld-link /out:%t.exe %t.obj > %t.log 2>&1 # RUN: FileCheck -check-prefix=WMAIN %s < %t.log +# RUN: not lld-link /nodefaultlib /out:%t.exe %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=WMAIN %s < %t.log # RUN: sed s/ENTRYNAME/WinMain/ %s | yaml2obj > %t.obj # RUN: not lld-link /out:%t.exe %t.obj > %t.log 2>&1 # RUN: FileCheck -check-prefix=WINMAIN %s < %t.log +# RUN: not lld-link /nodefaultlib /out:%t.exe %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=WINMAIN %s < %t.log # RUN: sed s/ENTRYNAME/wWinMain/ %s | yaml2obj > %t.obj # RUN: not lld-link /out:%t.exe %t.obj > %t.log 2>&1 # RUN: FileCheck -check-prefix=WWINMAIN %s < %t.log +# RUN: not lld-link /nodefaultlib /out:%t.exe %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=WWINMAIN %s < %t.log # MAIN: error: <root>: undefined symbol: mainCRTStartup # WMAIN: error: <root>: undefined symbol: wmainCRTStartup diff --git a/test/COFF/entry-inference3.test b/test/COFF/entry-inference3.test index 7de14e10fe8d..53550f75c6c4 100644 --- a/test/COFF/entry-inference3.test +++ b/test/COFF/entry-inference3.test @@ -1,5 +1,9 @@ -# RUN: yaml2obj < %s > %t.obj -# RUN: not lld-link /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1 +# RUN: sed -e s/ENTRYNAME/mainCRTStartup/ %s | yaml2obj > %t.obj +# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1 +# RUN: FileCheck %s < %t.log + +# RUN: sed -e s/ENTRYNAME/?mainCRTStartup@@YAHXZ/ %s | yaml2obj > %t.obj +# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1 # RUN: FileCheck %s < %t.log # CHECK: Entry name inferred: mainCRTStartup @@ -26,7 +30,7 @@ symbols: NumberOfLinenumbers: 0 CheckSum: 0 Number: 0 - - Name: mainCRTStartup + - Name: "ENTRYNAME" Value: 0 SectionNumber: 1 SimpleType: IMAGE_SYM_TYPE_NULL diff --git a/test/COFF/entry-inference332.test b/test/COFF/entry-inference332.test new file mode 100644 index 000000000000..75c557af47e8 --- /dev/null +++ b/test/COFF/entry-inference332.test @@ -0,0 +1,39 @@ +# RUN: sed -e s/ENTRYNAME/_mainCRTStartup/ %s | yaml2obj > %t.obj +# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1 +# RUN: FileCheck %s < %t.log + +# RUN: sed -e s/ENTRYNAME/?mainCRTStartup@@YAHXZ/ %s | yaml2obj > %t.obj +# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1 +# RUN: FileCheck %s < %t.log + +# CHECK: Entry name inferred: _mainCRTStartup + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_I386 + Characteristics: [] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: B82A000000C3 +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 6 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: "ENTRYNAME" + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/entry-inference4.test b/test/COFF/entry-inference4.test new file mode 100644 index 000000000000..6b6a581f6c9d --- /dev/null +++ b/test/COFF/entry-inference4.test @@ -0,0 +1,68 @@ +# RUN: sed 's/ENTRY1/WinMain/;s/ENTRY2/main/' %s | yaml2obj > %t.obj +# RUN: not lld-link /subsystem:windows /out:%t.exe %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=WINMAIN %s < %t.log + +# RUN: sed 's/ENTRY1/wWinMain/;s/ENTRY2/main/' %s | yaml2obj > %t.obj +# RUN: not lld-link /subsystem:windows /out:%t.exe %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=WWINMAIN %s < %t.log + +# RUN: sed 's/ENTRY1/WinMain/;s/ENTRY2/main/' %s | yaml2obj > %t.obj +# RUN: not lld-link /subsystem:console /out:%t.exe %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=MAIN %s < %t.log + +# RUN: sed 's/ENTRY1/WinMain/;s/ENTRY2/wmain/' %s | yaml2obj > %t.obj +# RUN: not lld-link /subsystem:console /out:%t.exe %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=WMAIN %s < %t.log + +# RUN: sed 's/ENTRY1/wmain/;s/ENTRY2/main/' %s | yaml2obj > %t.obj +# RUN: not lld-link /out:%t.exe %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=MAINWMAIN %s < %t.log + +# RUN: sed 's/ENTRY1/wWinMain/;s/ENTRY2/WinMain/' %s | yaml2obj > %t.obj +# RUN: not lld-link /out:%t.exe %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=WINMAINWWINMAIN %s < %t.log + +# MAIN: error: <root>: undefined symbol: mainCRTStartup +# WMAIN: error: <root>: undefined symbol: wmainCRTStartup +# MAINWMAIN: warning: found both wmain and main; using latter +# MAINWMAIN: error: <root>: undefined symbol: mainCRTStartup +# WINMAIN: error: <root>: undefined symbol: WinMainCRTStartup +# WWINMAIN: error: <root>: undefined symbol: wWinMainCRTStartup +# WINMAINWWINMAIN: warning: found both wWinMain and WinMain; using latter +# WINMAINWWINMAIN: error: <root>: undefined symbol: WinMainCRTStartup + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: B82A000000C3 +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 6 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: ENTRY1 + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: ENTRY2 + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/export-all.s b/test/COFF/export-all.s index 5509a8dbac91..3d80603e2e71 100644 --- a/test/COFF/export-all.s +++ b/test/COFF/export-all.s @@ -3,14 +3,13 @@ # RUN: llvm-mc -triple=i686-windows-gnu %s -filetype=obj -o %t.obj # RUN: lld-link -lldmingw -dll -out:%t.dll -entry:DllMainCRTStartup@12 %t.obj -implib:%t.lib -# RUN: llvm-readobj -coff-exports %t.dll | FileCheck %s +# RUN: llvm-readobj -coff-exports %t.dll | grep Name: | FileCheck %s # RUN: llvm-readobj %t.lib | FileCheck -check-prefix=IMPLIB %s -# CHECK-NOT: Name: DllMainCRTStartup -# CHECK-NOT: Name: _imp__unexported -# CHECK: Name: dataSym -# CHECK: Name: foobar -# CHECK-NOT: Name: unexported +# CHECK: Name: +# CHECK-NEXT: Name: dataSym +# CHECK-NEXT: Name: foobar +# CHECK-EMPTY: # IMPLIB: Symbol: __imp__dataSym # IMPLIB-NOT: Symbol: _dataSym @@ -22,6 +21,7 @@ .global _dataSym .global _unexported .global __imp__unexported +.global .refptr._foobar .text _DllMainCRTStartup@12: ret @@ -34,6 +34,8 @@ _dataSym: .int 4 __imp__unexported: .int _unexported +.refptr._foobar: + .int _foobar # Test specifying -export-all-symbols, on an object file that contains # dllexport directive for some of the symbols. @@ -63,6 +65,7 @@ __imp__unexported: # RUN: mkdir -p %T/libs # RUN: echo -e ".global mingwfunc\n.text\nmingwfunc:\nret\n" > %T/libs/mingwfunc.s # RUN: llvm-mc -triple=x86_64-windows-gnu %T/libs/mingwfunc.s -filetype=obj -o %T/libs/mingwfunc.o +# RUN: rm -f %T/libs/libmingwex.a # RUN: llvm-ar rcs %T/libs/libmingwex.a %T/libs/mingwfunc.o # RUN: echo -e ".global crtfunc\n.text\ncrtfunc:\nret\n" > %T/libs/crtfunc.s # RUN: llvm-mc -triple=x86_64-windows-gnu %T/libs/crtfunc.s -filetype=obj -o %T/libs/crt2.o @@ -74,6 +77,18 @@ __imp__unexported: # CHECK-EXCLUDE-NEXT: foobar @1 # CHECK-EXCLUDE-NEXT: EOF +# Test that libraries included with -wholearchive: are autoexported, even if +# they are in a library that otherwise normally would be excluded. + +# RUN: lld-link -out:%t.dll -dll -entry:DllMainCRTStartup %t.main.obj -lldmingw %T/libs/crt2.o -wholearchive:%T/libs/libmingwex.a -output-def:%t.def +# RUN: echo "EOF" >> %t.def +# RUN: cat %t.def | FileCheck -check-prefix=CHECK-WHOLEARCHIVE %s + +# CHECK-WHOLEARCHIVE: EXPORTS +# CHECK-WHOLEARCHIVE-NEXT: foobar @1 +# CHECK-WHOLEARCHIVE-NEXT: mingwfunc @2 +# CHECK-WHOLEARCHIVE-NEXT: EOF + # Test that we handle import libraries together with -opt:noref. # RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj diff --git a/test/COFF/export.test b/test/COFF/export.test index a00a29c13d4c..8bf8c44c81dc 100644 --- a/test/COFF/export.test +++ b/test/COFF/export.test @@ -97,3 +97,12 @@ FORWARDER: Ordinal RVA Name FORWARDER: 0 0 FORWARDER: 1 0x1010 exportfn FORWARDER: 2 foo (forwarded to kernel32.foobar) + +# RUN: lld-link /out:%t.dll /dll %t.obj /merge:.rdata=.text /export:exportfn1 /export:exportfn2 +# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=MERGE -match-full-lines %s + +MERGE: DLL name: export.test.tmp.dll +MERGE: Ordinal RVA Name +MERGE-NEXT: 0 0 +MERGE-NEXT: 1 0x1008 exportfn1 +MERGE-NEXT: 2 0x1010 exportfn2 diff --git a/test/COFF/force-multiple.test b/test/COFF/force-multiple.test new file mode 100644 index 000000000000..9f60e1394a3e --- /dev/null +++ b/test/COFF/force-multiple.test @@ -0,0 +1,45 @@ +# RUN: yaml2obj < %s > %t1.obj +# RUN: yaml2obj < %s > %t2.obj + +# RUN: not lld-link /out:%t.exe /entry:main %t1.obj %t2.obj >& %t.log +# RUN: FileCheck -check-prefix=ERROR %s < %t.log + +# RUN: lld-link /out:%t.exe /entry:main %t1.obj %t2.obj /force >& %t.log +# RUN: FileCheck -check-prefix=WARN %s < %t.log + +# RUN: lld-link /out:%t.exe /entry:main %t1.obj %t2.obj /force:multiple >& %t.log +# RUN: FileCheck -check-prefix=WARN %s < %t.log + +# ERROR: error: duplicate symbol: main + +# WARN: warning: duplicate symbol: main + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 000000000000 +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 6 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/gfids-export.s b/test/COFF/gfids-export.s new file mode 100644 index 000000000000..87a4f4b47fa3 --- /dev/null +++ b/test/COFF/gfids-export.s @@ -0,0 +1,44 @@ +# REQUIRES: x86 +# RUN: llvm-mc -triple x86_64-pc-win32 %s -filetype=obj -o %t.obj +# RUN: lld-link %t.obj -guard:cf -dll -out:%t.dll -noentry +# RUN: llvm-readobj -coff-load-config %t.dll | FileCheck %s --check-prefix=CHECK + +# There should be a single entry in the table for the exported symbol. +# +# CHECK: GuardFidTable [ +# CHECK-NEXT: 0x180001000 +# CHECK-NEXT: ] + + .def func_export; .scl 2; .type 32; .endef + .globl func_export + .section .text,"xr",one_only,func_export + .p2align 4 +func_export: + movl $1, %eax + .globl label_export +label_export: + movl $2, %eax + ret + + .data + .globl data_export +data_export: + .long 42 + + .section .drectve,"dr" + .ascii " /EXPORT:func_export" + .ascii " /EXPORT:label_export" + .ascii " /EXPORT:data_export" + + +# Load configuration directory entry (winnt.h _IMAGE_LOAD_CONFIG_DIRECTORY64). +# The linker will define the __guard_* symbols. + .section .rdata,"dr" +.globl _load_config_used +_load_config_used: + .long 256 + .fill 124, 1, 0 + .quad __guard_fids_table + .quad __guard_fids_count + .long __guard_flags + .fill 128, 1, 0 diff --git a/test/COFF/gfids-relocations32.s b/test/COFF/gfids-relocations32.s new file mode 100644 index 000000000000..0f7efeb46078 --- /dev/null +++ b/test/COFF/gfids-relocations32.s @@ -0,0 +1,87 @@ +# REQUIRES: x86 +# RUN: llvm-mc -triple i686-pc-win32 %s -filetype=obj -o %t.obj +# RUN: lld-link %t.obj -guard:cf -out:%t.exe -entry:main +# RUN: llvm-readobj -coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK + +# Only f and _main should go in the table. +# (use /lldmap:map.txt to check their addresses). +# +# CHECK: GuardFidTable [ +# CHECK-NEXT: 0x401000 +# CHECK-NEXT: 0x401030 +# CHECK-NEXT: ] + +# The input was loosly based on studying this program: +# +# void foo() { return; } +# void bar() { return; } +# int main() { +# foo(); +# void (*arr[])() = { &bar }; +# (*arr[0])(); +# return 0; +# } +# cl /c a.cc && dumpbin /disasm a.obj > a.txt && +# link a.obj /guard:cf /map:map.txt && dumpbin /loadconfig a.exe + + + + .def f; + .scl 3; + .type 32; + .endef + .section .text,"xr",one_only,f + .p2align 4 +f: movl $1, %eax + ret + + + .def g; + .scl 3; + .type 32; + .endef + .section .text,"xr",one_only,g + .p2align 4 +g: movl $2, %eax + ret + + + .def label; + .scl 6; # StorageClass: Label + .type 0; # Type: Not a function. + .endef + .section .text,"xr",one_only,label + .p2align 4 +label: ret + + + .data + .globl fp + .p2align 4 +fp: .long f # DIR32 relocation to function + .long label # DIR32 relocation to label + + + .def _main; + .scl 2; + .type 32; + .endef + .section .text,"xr",one_only,_main + .globl _main + .p2align 4 +_main: call *fp # DIR32 relocation to data + call g # REL32 relocation to function + ret + + +# Load configuration directory entry (winnt.h _IMAGE_LOAD_CONFIG_DIRECTORY32). +# The linker will define the ___guard_* symbols. + .section .rdata,"dr" +.globl __load_config_used +__load_config_used: + .long 104 # Size. + .fill 76, 1, 0 + .long ___guard_fids_table + .long ___guard_fids_count + .long ___guard_flags + .fill 12, 1, 0 diff --git a/test/COFF/gfids-relocations64.s b/test/COFF/gfids-relocations64.s new file mode 100644 index 000000000000..ae2e687222d5 --- /dev/null +++ b/test/COFF/gfids-relocations64.s @@ -0,0 +1,76 @@ +# REQUIRES: x86 +# RUN: llvm-mc -triple x86_64-pc-win32 %s -filetype=obj -o %t.obj +# RUN: lld-link %t.obj -guard:cf -out:%t.exe -entry:main +# RUN: llvm-readobj -coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK + +# f, g, and main go in the table. +# Including g isn't strictly necessary since it's not an indirect call target, +# however the linker can't know that because relative relocations are used both +# for direct calls and for getting the absolute address of a function. +# (use /lldmap:map.txt to check their addresses). +# +# CHECK: GuardFidTable [ +# CHECK-NEXT: 0x140001000 +# CHECK-NEXT: 0x140001010 +# CHECK-NEXT: 0x140001030 +# CHECK-NEXT: ] + + .def f; + .scl 3; + .type 32; + .endef + .section .text,"xr",one_only,f + .p2align 4 +f: movl $1, %eax + ret + + + .def g; + .scl 3; + .type 32; + .endef + .section .text,"xr",one_only,g + .p2align 4 +g: movl $2, %eax + ret + + + .def label; + .scl 6; # StorageClass: Label + .type 0; # Type: Not a function. + .endef + .section .text,"xr",one_only,label + .p2align 4 +label: ret + + + .data + .globl fp + .p2align 4 +fp: .quad f # DIR32 relocation to function + .quad label # DIR32 relocation to label + + + .def main; + .scl 2; + .type 32; + .endef + .section .text,"xr",one_only,main + .globl main + .p2align 4 +main: call *fp # DIR32 relocation to data + call g # REL32 relocation to function + ret + + +# Load configuration directory entry (winnt.h _IMAGE_LOAD_CONFIG_DIRECTORY64). +# The linker will define the __guard_* symbols. + .section .rdata,"dr" +.globl _load_config_used +_load_config_used: + .long 256 + .fill 124, 1, 0 + .quad __guard_fids_table + .quad __guard_fids_count + .long __guard_flags + .fill 128, 1, 0 diff --git a/test/COFF/gnu-weak.test b/test/COFF/gnu-weak.test new file mode 100644 index 000000000000..20284d7f0243 --- /dev/null +++ b/test/COFF/gnu-weak.test @@ -0,0 +1,52 @@ +RUN: lld-link -lldmingw %S/Inputs/gnu-weak.o %S/Inputs/gnu-weak2.o -out:%t.exe + +GNU ld can handle several definitions of the same weak symbol, and +unless there is a strong definition of it, it just picks the first +weak definition encountered. + +For each of the weak definitions, GNU tools produce a regular symbol +named .weak.<weaksymbol>.<othersymbol>, where the other symbol name is +another symbol defined close by. + +This can't be reproduced by assembling with llvm-mc, as llvm-mc always +produces similar regular symbols named .weak.<weaksymbol>.default. + +The bundled object files can be produced from test code that looks like +this: + +$ cat gnu-weak.c +void weakfunc(void) __attribute__((weak)); +void otherfunc(void); + +__attribute__((weak)) void weakfunc() { +} + +int main(int argc, char* argv[]) { + otherfunc(); + weakfunc(); + return 0; +} +void mainCRTStartup(void) { + main(0, (char**)0); +} +void __main(void) { +} + +$ cat gnu-weak2.c +void weakfunc(void) __attribute__((weak)); + +__attribute__((weak)) void weakfunc() { +} + +void otherfunc(void) { +} + +$ x86_64-w64-mingw32-gcc -c -O2 gnu-weak.c +$ x86_64-w64-mingw32-gcc -c -O2 gnu-weak2.c + +$ x86_64-w64-mingw32-nm gnu-weak.o | grep weakfunc +0000000000000000 T .weak.weakfunc.main + w weakfunc +$ x86_64-w64-mingw32-nm gnu-weak2.o | grep weakfunc +0000000000000000 T .weak.weakfunc.otherfunc + w weakfunc diff --git a/test/COFF/guardcf-align.s b/test/COFF/guardcf-align.s index a0caabc92b0d..449d3fcd2a74 100644 --- a/test/COFF/guardcf-align.s +++ b/test/COFF/guardcf-align.s @@ -1,3 +1,4 @@ +# REQUIRES: x86 # RUN: llvm-mc -triple x86_64-windows-msvc -filetype=obj -o %t.obj %s # RUN: yaml2obj < %p/Inputs/guardcf-align-foobar.yaml \ # RUN: > %T/guardcf-align-foobar.obj diff --git a/test/COFF/header-size.s b/test/COFF/header-size.s new file mode 100644 index 000000000000..3373cdea84f0 --- /dev/null +++ b/test/COFF/header-size.s @@ -0,0 +1,12 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-windows %s -o %t.obj +// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe +// RUN: llvm-readobj -sections %t.exe | FileCheck %s + .globl main +main: + ret + +// Check that the first section data comes at 512 bytes in the file. +// If the size allocated for headers would include size for section +// headers which aren't written, PointerToRawData would be 0x400 instead. +// CHECK: PointerToRawData: 0x200 diff --git a/test/COFF/icf-safe.s b/test/COFF/icf-safe.s new file mode 100644 index 000000000000..d16f21f458fc --- /dev/null +++ b/test/COFF/icf-safe.s @@ -0,0 +1,37 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-win32 %s -o %t1.obj +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-win32 %S/Inputs/icf-safe.s -o %t2.obj +# RUN: lld-link /dll /noentry /out:%t.dll /verbose /opt:noref,icf %t1.obj %t2.obj 2>&1 | FileCheck %s +# RUN: lld-link /dll /noentry /out:%t.dll /verbose /opt:noref,icf /export:g3 /export:g4 %t1.obj %t2.obj 2>&1 | FileCheck --check-prefix=EXPORT %s + +# CHECK-NOT: Selected +# CHECK: Selected g3 +# CHECK-NEXT: Removed g4 +# CHECK-NOT: Removed +# CHECK-NOT: Selected + +# EXPORT-NOT: Selected + +.section .rdata,"dr",one_only,g1 +.globl g1 +g1: +.byte 1 + +.section .rdata,"dr",one_only,g2 +.globl g2 +g2: +.byte 1 + +.section .rdata,"dr",one_only,g3 +.globl g3 +g3: +.byte 2 + +.section .rdata,"dr",one_only,g4 +.globl g4 +g4: +.byte 2 + +.addrsig +.addrsig_sym g1 +.addrsig_sym g2 diff --git a/test/COFF/ignore-many.test b/test/COFF/ignore-many.test new file mode 100644 index 000000000000..31398106c171 --- /dev/null +++ b/test/COFF/ignore-many.test @@ -0,0 +1,16 @@ +Tests /ignore with more than one argument. + +RUN: yaml2obj %S/ignore4217.yaml > %t1.obj +RUN: yaml2obj %S/Inputs/pdb-type-server-missing-2.yaml > %t2.obj +RUN: echo foo > %t3.order + +RUN: lld-link /entry:main /out:%t.exe %t1.obj %t2.obj /order:@%t3.order /debug 2>&1 | FileCheck -check-prefix=WARNINGS %s +RUN: lld-link /entry:main /out:%t.exe %t1.obj %t2.obj /order:@%t3.order /debug /ignore:4217,4099,4037 2>&1 | FileCheck -allow-empty -check-prefix=SUPPRESSED %s + +WARNINGS: locally defined symbol imported +WARNINGS: missing symbol: foo +WARNINGS: warning: Cannot use debug info for + +SUPPRESSED-NOT: locally defined symbol imported +SUPPRESSED-NOT: missing symbol: foo +SUPPRESSED-NOT: warning: Cannot use debug info for diff --git a/test/COFF/imports-gnu-autoexport.s b/test/COFF/imports-gnu-autoexport.s new file mode 100644 index 000000000000..8c204e1c665a --- /dev/null +++ b/test/COFF/imports-gnu-autoexport.s @@ -0,0 +1,25 @@ +# REQUIRES: x86 +# +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-head.s -filetype=obj -o %t-dabcdh.o +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-func.s -filetype=obj -o %t-dabcds00000.o +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-tail.s -filetype=obj -o %t-dabcdt.o +# RUN: rm -f %t-implib.a +# RUN: llvm-ar rcs %t-implib.a %t-dabcdh.o %t-dabcds00000.o %t-dabcdt.o +# RUN: lld-link -lldmingw -dll -out:%t.dll -entry:main -subsystem:console \ +# RUN: %p/Inputs/hello64.obj %p/Inputs/std64.lib %t-implib.a -include:func +# RUN: llvm-readobj -coff-exports %t.dll | FileCheck -check-prefix=EXPORT %s + +# Check that only the single normal symbol was exported, none of the symbols +# from the import library. + +EXPORT: Export { +EXPORT-NEXT: Ordinal: 0 +EXPORT-NEXT: Name: +EXPORT-NEXT: RVA: 0x0 +EXPORT-NEXT: } +EXPORT-NEXT: Export { +EXPORT-NEXT: Ordinal: 1 +EXPORT-NEXT: Name: main +EXPORT-NEXT: RVA: 0x1010 +EXPORT-NEXT: } +EXPORT-NEXT-EMPTY: diff --git a/test/COFF/imports-gnu-only.s b/test/COFF/imports-gnu-only.s new file mode 100644 index 000000000000..8483598ede97 --- /dev/null +++ b/test/COFF/imports-gnu-only.s @@ -0,0 +1,28 @@ +# REQUIRES: x86 +# +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-head.s -filetype=obj -o %t-dabcdh.o +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-func.s -filetype=obj -o %t-dabcds00000.o +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-tail.s -filetype=obj -o %t-dabcdt.o +# RUN: rm -f %t-implib.a +# RUN: llvm-ar rcs %t-implib.a %t-dabcdh.o %t-dabcds00000.o %t-dabcdt.o +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj +# RUN: lld-link -out:%t.exe -entry:main -subsystem:console \ +# RUN: %t.obj %t-implib.a +# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=DATA %s + + .text + .global main +main: + call func + ret + +# Check that the linker inserted the null terminating import descriptor, +# even if there were no normal import libraries, only gnu ones. + +# DATA: Contents of section .rdata: +# First import descriptor +# DATA: 140002000 28200000 00000000 00000000 53200000 +# Last word from first import descriptor, null terminator descriptor +# DATA: 140002010 38200000 00000000 00000000 00000000 +# Null terminator descriptor and import lookup table. +# DATA: 140002020 00000000 00000000 48200000 00000000 diff --git a/test/COFF/imports-gnu.test b/test/COFF/imports-gnu.test new file mode 100644 index 000000000000..e56be2f446b7 --- /dev/null +++ b/test/COFF/imports-gnu.test @@ -0,0 +1,29 @@ +# REQUIRES: x86 +# Verify that the lld can link to GNU import libs. +# +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-head.s -filetype=obj -o %t-dabcdh.o +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-func.s -filetype=obj -o %t-dabcds00000.o +# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-tail.s -filetype=obj -o %t-dabcdt.o +# RUN: rm -f %t-implib.a +# RUN: llvm-ar rcs %t-implib.a %t-dabcdh.o %t-dabcds00000.o %t-dabcdt.o +# Not linking with -lldmingw; one can link to GNU import libs even if not targeting MinGW. +# RUN: lld-link -out:%t.exe -entry:main -subsystem:console \ +# RUN: %p/Inputs/hello64.obj %p/Inputs/std64.lib %t-implib.a -include:func +# RUN: llvm-readobj -coff-imports %t.exe | FileCheck -check-prefix=IMPORT %s + +# Check that import entries from both libraries show up. + +IMPORT: Import { +IMPORT-NEXT: Name: foo.dll +IMPORT-NEXT: ImportLookupTableRVA: +IMPORT-NEXT: ImportAddressTableRVA: +IMPORT-NEXT: Symbol: func (0) +IMPORT-NEXT: } +IMPORT-NEXT: Import { +IMPORT-NEXT: Name: std64.dll +IMPORT-NEXT: ImportLookupTableRVA: +IMPORT-NEXT: ImportAddressTableRVA: +IMPORT-NEXT: Symbol: ExitProcess (0) +IMPORT-NEXT: Symbol: (50) +IMPORT-NEXT: Symbol: MessageBoxA (1) +IMPORT-NEXT: } diff --git a/test/COFF/invalid-debug-type.test b/test/COFF/invalid-debug-type.test index 10264180314d..0fa40b0312b5 100644 --- a/test/COFF/invalid-debug-type.test +++ b/test/COFF/invalid-debug-type.test @@ -1,5 +1,6 @@ # RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj # RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj # RUN: lld-link /debug /debugtype:invalid /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \ -# RUN: %t1.obj %t2.obj +# RUN: %t1.obj %t2.obj 2>&1 | FileCheck %s +# CHECK: /debugtype: unknown option: invalid
\ No newline at end of file diff --git a/test/COFF/invalid-debug.test b/test/COFF/invalid-debug.test new file mode 100644 index 000000000000..67f794f8b1b3 --- /dev/null +++ b/test/COFF/invalid-debug.test @@ -0,0 +1,6 @@ +# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj +# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj +# RUN: not lld-link /debug /debug:invalid /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \ +# RUN: %t1.obj %t2.obj 2>&1 | FileCheck %s + +# CHECK: /debug: unknown option: invalid diff --git a/test/COFF/libname-mingw.test b/test/COFF/libname-mingw.test new file mode 100644 index 000000000000..171164f73461 --- /dev/null +++ b/test/COFF/libname-mingw.test @@ -0,0 +1,8 @@ +# RUN: mkdir -p %t/a +# RUN: cp %p/Inputs/std64.lib %t/a/libstd64.a + +# RUN: lld-link /lldmingw /out:%t.exe /entry:main /verbose \ +# RUN: /defaultlib:std64.lib /subsystem:console %p/Inputs/hello64.obj \ +# RUN: /libpath:%t/a 2>&1 | FileCheck %s + +CHECK: a{{[/\\]}}libstd64.a diff --git a/test/COFF/line-error.yaml b/test/COFF/line-error.yaml new file mode 100644 index 000000000000..55fb723a6abb --- /dev/null +++ b/test/COFF/line-error.yaml @@ -0,0 +1,160 @@ +# RUN: yaml2obj %s -o %t.obj
+# RUN: not lld-link %t.obj /subsystem:console 2>&1 | FileCheck %s
+
+# CHECK: lld-link: error: undefined symbol: function
+# CHECK-NEXT: >>> referenced by {{.*}}line-error.yaml.tmp.obj:(caller1)
+# CHECK-NEXT: >>> referenced by E:\file.cpp:1935
+# CHECK-NEXT: >>> {{.*}}line-error.yaml.tmp.obj:(caller22)
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: [ ]
+sections:
+ - Name: .text
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 16
+ SectionData: 488B0500000000488B51284881C2D80000004889C148FF2500000000
+ Relocations:
+ - VirtualAddress: 3
+ SymbolName: function
+ Type: IMAGE_REL_AMD64_REL32
+ - Name: .text
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 16
+ SectionData: 488B0500000000488B51084881C2D80000004889C148FF2500000000
+ Relocations:
+ - VirtualAddress: 3
+ SymbolName: function
+ Type: IMAGE_REL_AMD64_REL32
+ - Name: '.debug$S'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+ Alignment: 4
+ Subsections:
+ - !FileChecksums
+ Checksums:
+ - FileName: 'E:\file.cpp'
+ Kind: MD5
+ Checksum: D72EDEF8B8E50C364A330F9CB3CD904B
+ - !StringTable
+ Strings:
+ - 'E:\file.cpp'
+ - Name: '.debug$S'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+ Alignment: 4
+ Subsections:
+ - !Lines
+ CodeSize: 28
+ Flags: [ ]
+ RelocOffset: 0
+ RelocSegment: 0
+ Blocks: []
+ Relocations:
+ - VirtualAddress: 12
+ SymbolName: caller1
+ Type: IMAGE_REL_AMD64_SECREL
+ - Name: '.debug$S'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+ Alignment: 4
+ Subsections:
+ - !Lines
+ CodeSize: 28
+ Flags: [ ]
+ RelocOffset: 0
+ RelocSegment: 0
+ Blocks:
+ - FileName: 'E:\file.cpp'
+ Lines:
+ - Offset: 11
+ LineStart: 1935
+ IsStatement: false
+ EndDelta: 0
+ Columns: []
+ Relocations:
+ - VirtualAddress: 12
+ SymbolName: caller22
+ Type: IMAGE_REL_AMD64_SECREL
+symbols:
+ - 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: 2
+ NumberOfLinenumbers: 0
+ CheckSum: 2430089736
+ Number: 1
+ Selection: IMAGE_COMDAT_SELECT_NODUPLICATES
+ - Name: caller1
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: .text
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 28
+ NumberOfRelocations: 2
+ NumberOfLinenumbers: 0
+ CheckSum: 3449717304
+ Number: 2
+ Selection: IMAGE_COMDAT_SELECT_NODUPLICATES
+ - Name: caller22
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: '.debug$S'
+ Value: 0
+ SectionNumber: 3
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 767204
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 4280093374
+ Number: 3
+ - Name: '.debug$S'
+ Value: 0
+ SectionNumber: 4
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 296
+ NumberOfRelocations: 1
+ NumberOfLinenumbers: 0
+ CheckSum: 1957793731
+ Number: 1
+ Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE
+ - Name: '.debug$S'
+ Value: 0
+ SectionNumber: 5
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 276
+ NumberOfRelocations: 1
+ NumberOfLinenumbers: 0
+ CheckSum: 1957793731
+ Number: 2
+ Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE
+ - Name: function
+ Value: 0
+ SectionNumber: 0
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
diff --git a/test/COFF/lto-cache.ll b/test/COFF/lto-cache.ll index ad1a3b71f19a..828f5e5a97c1 100644 --- a/test/COFF/lto-cache.ll +++ b/test/COFF/lto-cache.ll @@ -1,4 +1,6 @@ ; REQUIRES: x86 +; NetBSD: noatime mounts currently inhibit 'touch' from updating atime +; UNSUPPORTED: system-netbsd ; RUN: opt -module-hash -module-summary %s -o %t.o ; RUN: opt -module-hash -module-summary %p/Inputs/lto-cache.ll -o %t2.o diff --git a/test/COFF/lto-chkstk.ll b/test/COFF/lto-chkstk.ll index cf831615ec52..1df93c6b9545 100644 --- a/test/COFF/lto-chkstk.ll +++ b/test/COFF/lto-chkstk.ll @@ -2,6 +2,7 @@ ; RUN: llvm-as -o %t.obj %s ; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %T/lto-chkstk-foo.obj %S/Inputs/lto-chkstk-foo.s ; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %T/lto-chkstk-chkstk.obj %S/Inputs/lto-chkstk-chkstk.s +; RUN: rm -f %t.lib ; RUN: llvm-ar cru %t.lib %T/lto-chkstk-chkstk.obj ; RUN: lld-link /out:%t.exe /entry:main /subsystem:console %t.obj %T/lto-chkstk-foo.obj %t.lib diff --git a/test/COFF/lto-cpu-string.ll b/test/COFF/lto-cpu-string.ll new file mode 100644 index 000000000000..840adcebf46d --- /dev/null +++ b/test/COFF/lto-cpu-string.ll @@ -0,0 +1,21 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t.obj + +; RUN: lld-link %t.obj -noentry -nodefaultlib -out:%t.dll -dll +; RUN: llvm-objdump -d -section=".text" -no-leading-addr -no-show-raw-insn %t.dll | FileCheck %s +; CHECK: nop{{$}} + +; RUN: lld-link -mllvm:-mcpu=znver1 -noentry -nodefaultlib %t.obj -out:%t.znver1.dll -dll +; RUN: llvm-objdump -d -section=".text" -no-leading-addr -no-show-raw-insn %t.znver1.dll | FileCheck -check-prefix=ZNVER1 %s +; ZNVER1: nopw + +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.14.26433" + +define dllexport void @foo() #0 { +entry: + call void asm sideeffect ".p2align 4, 0x90", "~{dirflag},~{fpsr},~{flags}"() + ret void +} + +attributes #0 = { "no-frame-pointer-elim"="true" } diff --git a/test/COFF/msvclto-archive.ll b/test/COFF/msvclto-archive.ll deleted file mode 100644 index f09532721024..000000000000 --- a/test/COFF/msvclto-archive.ll +++ /dev/null @@ -1,40 +0,0 @@ -; REQUIRES: x86 -;; Make sure we re-create archive files to strip bitcode files. - -;; Do not create empty archives because the MSVC linker -;; doesn't support them. -; RUN: llvm-as -o %t.obj %s -; RUN: rm -f %t-main1.a -; RUN: llvm-ar cru %t-main1.a %t.obj -; RUN: mkdir -p %t.dir -; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t.dir/bitcode.obj %p/Inputs/msvclto.s -; RUN: lld-link %t-main1.a %t.dir/bitcode.obj /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \ -; RUN: /entry:main /verbose 2> %t.log || true -; RUN: FileCheck -check-prefix=BC %s < %t.log -; BC-NOT: Creating a temporary archive for - -; RUN: rm -f %t-main2.a -; RUN: llvm-ar cru %t-main2.a %t.dir/bitcode.obj -; RUN: lld-link %t.obj %t-main2.a /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \ -; RUN: /entry:main /verbose 2> %t.log || true -; RUN: FileCheck -check-prefix=OBJ %s < %t.log -; OBJ-NOT: Creating a temporary archive - -;; Make sure that we always rebuild thin archives because -;; the MSVC linker doesn't support thin archives. -; RUN: rm -f %t-main3.a -; RUN: llvm-ar cruT %t-main3.a %t.dir/bitcode.obj -; RUN: lld-link %t.obj %t-main3.a /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \ -; RUN: /entry:main /verbose 2> %t.log || true -; RUN: FileCheck -check-prefix=THIN %s < %t.log -; THIN: Creating a temporary archive - -target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-windows-msvc" - -declare void @foo() - -define i32 @main() { - call void @foo() - ret i32 0 -} diff --git a/test/COFF/msvclto-order.ll b/test/COFF/msvclto-order.ll deleted file mode 100644 index 1758077fe748..000000000000 --- a/test/COFF/msvclto-order.ll +++ /dev/null @@ -1,25 +0,0 @@ -; REQUIRES: x86 -; RUN: opt -thinlto-bc %s -o %t.obj -; RUN: llc -filetype=obj %S/Inputs/msvclto-order-a.ll -o %T/msvclto-order-a.obj -; RUN: llvm-ar crs %T/msvclto-order-a.lib %T/msvclto-order-a.obj -; RUN: llc -filetype=obj %S/Inputs/msvclto-order-b.ll -o %T/msvclto-order-b.obj -; RUN: llvm-ar crs %T/msvclto-order-b.lib %T/msvclto-order-b.obj -; RUN: lld-link /verbose /msvclto /out:%t.exe /entry:main %t.obj \ -; RUN: %T/msvclto-order-a.lib %T/msvclto-order-b.lib 2> %t.log || true -; RUN: FileCheck %s < %t.log - -; CHECK: : link.exe -; CHECK-NOT: .lib{{$}} -; CHECK: lld-msvclto-order-a{{.*}}.obj -; CHECK-NOT: lld-msvclto-order-b{{.*}}.obj -; CHECK: .lib{{$}} - -target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-windows-msvc" - -declare void @foo() - -define i32 @main() { - call void @foo() - ret i32 0 -} diff --git a/test/COFF/msvclto.ll b/test/COFF/msvclto.ll deleted file mode 100644 index b29982737f14..000000000000 --- a/test/COFF/msvclto.ll +++ /dev/null @@ -1,20 +0,0 @@ -; REQUIRES: x86 -; RUN: llvm-as -o %t.obj %s -; RUN: mkdir -p %t.dir -; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t.dir/bitcode.obj %p/Inputs/msvclto.s -; RUN: lld-link %t.obj %t.dir/bitcode.obj /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \ -; RUN: /entry:main /verbose 2> %t.log || true -; RUN: FileCheck %s < %t.log - -; CHECK: /opt:icf /entry:main -; CHECK: /verbose - -target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-windows-msvc" - -declare void @foo() - -define i32 @main() { - call void @foo() - ret i32 0 -} diff --git a/test/COFF/no-idata.s b/test/COFF/no-idata.s new file mode 100644 index 000000000000..d2f78d5598c7 --- /dev/null +++ b/test/COFF/no-idata.s @@ -0,0 +1,20 @@ +# REQUIRES: x86 +# +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj +# RUN: lld-link -out:%t.exe -entry:main -subsystem:console %t.obj +# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=DUMP %s +# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=DIRECTORY %s + + .text + .global main +main: + ret + +# Check that no .idata (.rdata) entries were added, no null terminator +# for the import descriptor table. +# DUMP: Contents of section .text: +# DUMP-NEXT: 140001000 c3 +# DUMP-NEXT-EMPTY: + +# DIRECTORY: ImportTableRVA: 0x0 +# DIRECTORY: ImportTableSize: 0x0 diff --git a/test/COFF/pdb-debug-f.s b/test/COFF/pdb-debug-f.s new file mode 100644 index 000000000000..624c1192914a --- /dev/null +++ b/test/COFF/pdb-debug-f.s @@ -0,0 +1,28 @@ +# REQUIRES: x86 +# RUN: llvm-mc -triple=i386-pc-win32 -filetype=obj -o %t.obj %s +# RUN: lld-link /subsystem:console /debug /nodefaultlib /entry:foo /out:%t.exe /pdb:%t.pdb %t.obj +# RUN: llvm-pdbutil dump -fpo %t.pdb | FileCheck %s + +# CHECK: Old FPO Data +# CHECK-NEXT: ============================================================ +# CHECK-NEXT: RVA | Code | Locals | Params | Prolog | Saved Regs | Use BP | Has SEH | Frame Type +# CHECK-NEXT: 00001002 | 1 | 2 | 3 | 4 | 0 | false | false | FPO + +.text +_foo: +ret + +.global _foo + +.section .debug$F,"dr" + .long _foo@IMGREL+2 + .long 1 # cbProc + .long 2 # cdwLocals; + .short 3 # cdwParams; + .short 4 # flags + # cbProlog : 8; + # cbRegs : 3; + # fHasSEH : 1; + # fUseBP : 1; + # reserved : 1; + # cbFrame : 2;
\ No newline at end of file diff --git a/test/COFF/pdb-framedata.yaml b/test/COFF/pdb-framedata.yaml new file mode 100644 index 000000000000..fad042f392bb --- /dev/null +++ b/test/COFF/pdb-framedata.yaml @@ -0,0 +1,462 @@ +# // Compile with clang-cl -m32 /Z7 /GS- /c t.obj pdb-framedata.cpp +# +# int func(int x, int y) { +# return x + y; +# } +# +# int main(int argc, char **argv) { +# return func(argc, argc+1); +# } + +# RUN: yaml2obj %s -o %t.obj +# RUN: lld-link %t.obj -debug -entry:main -nodefaultlib -debug -out:%t.exe -pdb:%t.pdb +# RUN: llvm-pdbutil dump -fpo %t.pdb | FileCheck %s + +# CHECK: New FPO Data +# CHECK-NEXT: ============================================================ +# CHECK-NEXT: RVA | Code | Locals | Params | Stack | Prolog | Saved Regs | Has SEH | Has C++EH | Start | Program +# CHECK-NEXT: 00001000 | 31 | 0 | 8 | 0 | 6 | 0 | false | false | false | $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = +# CHECK-NEXT: 00001001 | 30 | 0 | 8 | 0 | 5 | 4 | false | false | false | $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = +# CHECK-NEXT: 00001003 | 28 | 0 | 8 | 0 | 3 | 4 | false | false | false | $T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = +# CHECK-NEXT: 00001020 | 53 | 0 | 8 | 0 | 7 | 0 | false | false | false | $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = +# CHECK-NEXT: 00001021 | 52 | 0 | 8 | 0 | 6 | 4 | false | false | false | $T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = +# CHECK-NEXT: 00001023 | 50 | 0 | 8 | 0 | 4 | 4 | false | false | false | $T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = +# CHECK-NEXT: 00001024 | 49 | 0 | 8 | 0 | 3 | 8 | false | false | false | $T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = $esi $T0 8 - ^ = + + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_I386 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 5589E583EC088B450C8B4D088B550803550C8945FC89D0894DF883C4085DC3905589E55683EC148B450C8B4D08C745F8000000008B550883C2018B7508893424895424048945F4894DF0E80000000083C4145E5DC3 + Relocations: + - VirtualAddress: 75 + SymbolName: '?func@@YAHHH@Z' + Type: IMAGE_REL_I386_REL32 + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .bss + Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 202F44454641554C544C49423A6C6962636D742E6C6962202F44454641554C544C49423A6F6C646E616D65732E6C6962 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + Subsections: + - !Symbols + Records: + - Kind: S_COMPILE3 + Compile3Sym: + Flags: [ ] + Machine: Pentium3 + FrontendMajor: 8 + FrontendMinor: 0 + FrontendBuild: 0 + FrontendQFE: 0 + BackendMajor: 8000 + BackendMinor: 0 + BackendBuild: 0 + BackendQFE: 0 + Version: 'clang version 8.0.0 ' + - !FrameData + Frames: + - CodeSize: 31 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 8 + PrologSize: 6 + RvaStart: 0 + SavedRegsSize: 0 + - CodeSize: 30 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 8 + PrologSize: 5 + RvaStart: 1 + SavedRegsSize: 4 + - CodeSize: 28 + FrameFunc: '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 8 + PrologSize: 3 + RvaStart: 3 + SavedRegsSize: 4 + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 31 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4098 + Flags: [ ] + DisplayName: func + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ IsParameter ] + VarName: x + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + Register: 22 + Flags: 0 + BasePointerOffset: 8 + Range: + OffsetStart: 12 + ISectStart: 0 + Range: 19 + Gaps: + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ IsParameter ] + VarName: y + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + Register: 22 + Flags: 0 + BasePointerOffset: 12 + Range: + OffsetStart: 12 + ISectStart: 0 + Range: 19 + Gaps: + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 31 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'D:\src\llvmbuild\cl\Debug\x64\pdb-framedata.cpp' + Lines: + - Offset: 0 + LineStart: 3 + IsStatement: false + EndDelta: 0 + - Offset: 12 + LineStart: 4 + IsStatement: false + EndDelta: 0 + Columns: + - !FrameData + Frames: + - CodeSize: 53 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 8 + PrologSize: 7 + RvaStart: 0 + SavedRegsSize: 0 + - CodeSize: 52 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 8 + PrologSize: 6 + RvaStart: 1 + SavedRegsSize: 4 + - CodeSize: 50 + FrameFunc: '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 8 + PrologSize: 4 + RvaStart: 3 + SavedRegsSize: 4 + - CodeSize: 49 + FrameFunc: '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = $esi $T0 8 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 8 + PrologSize: 3 + RvaStart: 4 + SavedRegsSize: 8 + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 53 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4102 + Flags: [ ] + DisplayName: main + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ IsParameter ] + VarName: argc + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + Register: 22 + Flags: 0 + BasePointerOffset: 8 + Range: + OffsetStart: 52 + ISectStart: 0 + Range: 33 + Gaps: + - Kind: S_LOCAL + LocalSym: + Type: 4099 + Flags: [ IsParameter ] + VarName: argv + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + Register: 22 + Flags: 0 + BasePointerOffset: 12 + Range: + OffsetStart: 52 + ISectStart: 0 + Range: 33 + Gaps: + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 53 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'D:\src\llvmbuild\cl\Debug\x64\pdb-framedata.cpp' + Lines: + - Offset: 0 + LineStart: 7 + IsStatement: false + EndDelta: 0 + - Offset: 20 + LineStart: 8 + IsStatement: false + EndDelta: 0 + Columns: + - !FileChecksums + Checksums: + - FileName: 'D:\src\llvmbuild\cl\Debug\x64\pdb-framedata.cpp' + Kind: MD5 + Checksum: A611B73E19B77B02646FAAF7CAEB025D + - !StringTable + Strings: + - 'D:\src\llvmbuild\cl\Debug\x64\pdb-framedata.cpp' + - '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = ' + - '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + - '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + - '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = $esi $T0 8 - ^ = ' + - '' + Relocations: + - VirtualAddress: 68 + SymbolName: '?func@@YAHHH@Z' + Type: IMAGE_REL_I386_DIR32NB + - VirtualAddress: 208 + SymbolName: '?func@@YAHHH@Z' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 212 + SymbolName: '?func@@YAHHH@Z' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 244 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 248 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 276 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 280 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 296 + SymbolName: '?func@@YAHHH@Z' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 300 + SymbolName: '?func@@YAHHH@Z' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 344 + SymbolName: _main + Type: IMAGE_REL_I386_DIR32NB + - VirtualAddress: 516 + SymbolName: _main + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 520 + SymbolName: _main + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 555 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 559 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 590 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 594 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 612 + SymbolName: _main + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 616 + SymbolName: _main + Type: IMAGE_REL_I386_SECTION + - Name: '.debug$T' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + Types: + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 116, 116 ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 116 + CallConv: NearC + Options: [ None ] + ParameterCount: 2 + ArgumentList: 4096 + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 4097 + Name: func + - Kind: LF_POINTER + Pointer: + ReferentType: 1136 + Attrs: 32778 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 116, 4099 ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 116 + CallConv: NearC + Options: [ None ] + ParameterCount: 2 + ArgumentList: 4100 + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 4101 + Name: main + - Name: .llvm_addrsig + Characteristics: [ IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 0F +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 85 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 1989857796 + Number: 1 + - Name: .data + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 2 + - Name: .bss + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 3 + - Name: .drectve + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 48 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 149686238 + Number: 4 + - Name: '.debug$S' + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 988 + NumberOfRelocations: 18 + NumberOfLinenumbers: 0 + CheckSum: 2571438511 + Number: 5 + - Name: '.debug$T' + Value: 0 + SectionNumber: 6 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 120 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 3148269371 + Number: 6 + - Name: .llvm_addrsig + Value: 0 + SectionNumber: 7 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 1 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 2428444049 + Number: 7 + - Name: '@feat.00' + Value: 1 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: '?func@@YAHHH@Z' + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: _main + Value: 32 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/pdb-global-hashes.test b/test/COFF/pdb-global-hashes.test index 238613cef69c..0ca60057e704 100644 --- a/test/COFF/pdb-global-hashes.test +++ b/test/COFF/pdb-global-hashes.test @@ -4,9 +4,9 @@ RUN: yaml2obj %p/Inputs/pdb-hashes-2-missing.yaml > %t.2.missing.obj RUN: lld-link /debug %t.1.obj %t.2.obj /entry:main /nodefaultlib /PDB:%t.nohash.pdb RUN: lld-link /debug:ghash %t.1.obj %t.2.obj /entry:main /nodefaultlib /PDB:%t.hash.pdb RUN: lld-link /debug:ghash %t.1.obj %t.2.missing.obj /entry:main /nodefaultlib /PDB:%t.mixed.pdb -RUN: llvm-pdbutil dump -types -ids %t.nohash.pdb | FileCheck %s -RUN: llvm-pdbutil dump -types -ids %t.hash.pdb | FileCheck %s -RUN: llvm-pdbutil dump -types -ids %t.mixed.pdb | FileCheck %s +RUN: llvm-pdbutil dump -types -ids -dont-resolve-forward-refs %t.nohash.pdb | FileCheck %s +RUN: llvm-pdbutil dump -types -ids -dont-resolve-forward-refs %t.hash.pdb | FileCheck %s +RUN: llvm-pdbutil dump -types -ids -dont-resolve-forward-refs %t.mixed.pdb | FileCheck %s ; These object files were generated via the following inputs and commands: ; ---------------------------------------------- diff --git a/test/COFF/pdb-globals.test b/test/COFF/pdb-globals.test index db0d3f6d7e8d..ee9c0ef2efee 100644 --- a/test/COFF/pdb-globals.test +++ b/test/COFF/pdb-globals.test @@ -15,6 +15,8 @@ RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s CHECK-LABEL: Global Symbols CHECK-NEXT: ============================================================ CHECK-NEXT: Records +CHECK-NEXT: 340 | S_UDT [size = 20] `HelloPoint` +CHECK-NEXT: original type = 0x1007 CHECK-NEXT: 208 | S_LPROCREF [size = 24] `LocalFunc` CHECK-NEXT: module = 1, sum name = 0, offset = 292 CHECK-NEXT: 160 | S_PROCREF [size = 28] `GlobalFunc` @@ -25,9 +27,11 @@ CHECK-NEXT: 232 | S_GDATA32 [size = 28] `__purecall` CHECK-NEXT: type = 0x0403 (void*), addr = 0003:0004 CHECK-NEXT: 260 | S_GDATA32 [size = 24] `GlobalVar` CHECK-NEXT: type = 0x100B (const int*), addr = 0003:0000 +CHECK-NEXT: 312 | S_UDT [size = 28] `HelloPointTypedef` +CHECK-NEXT: original type = 0x1005 CHECK-NEXT: 284 | S_LDATA32 [size = 28] `ConstantVar` CHECK-NEXT: type = 0x100A (const int), addr = 0002:0000 -CHECK-NEXT: 312 | S_PROCREF [size = 40] `HelloPoint::HelloPoint` +CHECK-NEXT: 360 | S_PROCREF [size = 40] `HelloPoint::HelloPoint` CHECK-NEXT: module = 1, sum name = 0, offset = 376 CHECK-LABEL: Symbols diff --git a/test/COFF/pdb-heapsite.yaml b/test/COFF/pdb-heapsite.yaml index bfdd7b4dc555..966ae4284890 100644 --- a/test/COFF/pdb-heapsite.yaml +++ b/test/COFF/pdb-heapsite.yaml @@ -69,7 +69,7 @@ sections: RegRelativeSym: Offset: 8 Type: 35 - Register: CVRegRSP + Register: RSP VarName: __formal - Kind: S_PROC_ID_END ScopeEndSym: diff --git a/test/COFF/pdb-linker-module.test b/test/COFF/pdb-linker-module.test index 022a447e4d55..48836a91fffb 100644 --- a/test/COFF/pdb-linker-module.test +++ b/test/COFF/pdb-linker-module.test @@ -1,11 +1,11 @@ RUN: echo "/nodefaultlib" > %t.rsp -RUN: lld-link /debug /pdb:%t.pdb @%t.rsp /entry:main %S/Inputs/pdb-diff.obj +RUN: lld-link /debug /pdb:%t.pdb @%t.rsp /entry:"1 "'"'hello'"'" 2" /manifestuac:"level='asInvoker' uiAccess='false'" %S/Inputs/pdb-diff.obj /force RUN: llvm-pdbutil dump -modules %t.pdb | FileCheck --check-prefix=MODS %s RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck --check-prefix=SYMS %s MODS: Mod 0001 | `* Linker *` MODS-NEXT: Obj: ``: -MODS-NEXT: debug stream: 12, # files: 0, has ec info: false +MODS-NEXT: debug stream: 13, # files: 0, has ec info: false MODS-NEXT: pdb file ni: 1 `{{.*}}pdb-linker-module.test.tmp.pdb`, src file ni: 0 `` SYMS: Mod 0001 | `* Linker *` @@ -22,4 +22,4 @@ SYMS-NEXT: - {{.*}}lld-link SYMS-NEXT: - pdb SYMS-NEXT: - {{.*}}pdb-linker-module{{.*}}pdb SYMS-NEXT: - cmd -SYMS-NEXT: - /debug /pdb:{{.*}}pdb-linker-module{{.*}}pdb /nodefaultlib /entry:main {{.*}}pdb-diff.obj +SYMS-NEXT: - /debug /pdb:{{.*}}pdb-linker-module{{.*}}pdb /nodefaultlib "/entry:1 ""hello"" 2" "/manifestuac:level='asInvoker' uiAccess='false'" {{.*}}pdb-diff.obj diff --git a/test/COFF/pdb-options.test b/test/COFF/pdb-options.test index 2bd1d920ee48..f0edc2f3bc79 100644 --- a/test/COFF/pdb-options.test +++ b/test/COFF/pdb-options.test @@ -6,6 +6,11 @@ # RUN: lld-link /pdb:%t.pdb /entry:main /nodefaultlib %t1.obj %t2.obj # RUN: not ls %t.pdb +; If /DEBUG:NONE is specified after /DEBUG, /pdb is ignored. +# RUN: rm -f %t.pdb +# RUN: lld-link /DEBUG /pdb:%t.pdb /DEBUG:NONE /entry:main /nodefaultlib %t1.obj %t2.obj +# RUN: not ls %t.pdb + ; If /DEBUG and /pdb are specified, it uses the specified name. # RUN: lld-link /DEBUG /pdb:%t.pdb /entry:main /nodefaultlib %t1.obj %t2.obj # RUN: ls %t.pdb diff --git a/test/COFF/pdb-procid-remapping.test b/test/COFF/pdb-procid-remapping.test index e42616dae47d..d9b4faa8c0a9 100644 --- a/test/COFF/pdb-procid-remapping.test +++ b/test/COFF/pdb-procid-remapping.test @@ -14,6 +14,7 @@ CHECK-NEXT: type = `0x1004 (int (<no type>))`, debug start = 4, d CHECK-NEXT: 136 | S_FRAMEPROC [size = 32] CHECK-NEXT: size = 40, padding size = 0, offset to padding = 0 CHECK-NEXT: bytes of callee saved registers = 0, exception handler addr = 0000:0000 +CHECK-NEXT: local fp reg = NONE, param fp reg = NONE CHECK-NEXT: flags = has async eh | opt speed CHECK-NEXT: 168 | S_END [size = 4] CHECK-LABEL: Mod 0001 | @@ -23,6 +24,7 @@ CHECK-NEXT: type = `0x1001 (int ())`, debug start = 0, debug end CHECK-NEXT: 136 | S_FRAMEPROC [size = 32] CHECK-NEXT: size = 0, padding size = 0, offset to padding = 0 CHECK-NEXT: bytes of callee saved registers = 0, exception handler addr = 0000:0000 +CHECK-NEXT: local fp reg = NONE, param fp reg = NONE CHECK-NEXT: flags = has async eh | opt speed CHECK-NEXT: 168 | S_END [size = 4] CHECK-LABEL: Mod 0002 | diff --git a/test/COFF/pdb-relative-source-lines.test b/test/COFF/pdb-relative-source-lines.test index 8c0894c21801..865d7a6d8a0a 100644 --- a/test/COFF/pdb-relative-source-lines.test +++ b/test/COFF/pdb-relative-source-lines.test @@ -17,29 +17,89 @@ void bar(void) { $ clang-cl -Xclang -fdebug-compilation-dir -Xclang . -c -Z7 pdb_lines*.c -RUN: yaml2obj %S/Inputs/pdb_lines_1_relative.yaml -o %t.pdb_lines_1_relative.obj -RUN: yaml2obj %S/Inputs/pdb_lines_2_relative.yaml -o %t.pdb_lines_2_relative.obj -RUN: rm -f %t.exe %t.pdb -RUN: lld-link -debug -pdbsourcepath:c:\\src -entry:main -nodefaultlib -out:%t.exe -pdb:%t.pdb %t.pdb_lines_1_relative.obj %t.pdb_lines_2_relative.obj -RUN: llvm-pdbutil pdb2yaml -modules -module-files -subsections=lines,fc %t.pdb | FileCheck %s +/pdbsourcepath: only sets the directory that relative paths are considered +relative to, so this test needs to pass relative paths to lld-link for: +1. The input obj files +2. The /pdb: switch +3. The lld-link invocation itself +To achieve this, put all inputs of the lld-link invocation (including lld-link +itself) in a temp directory that's cwd and then make sure to only use relative +arguments when calling ./lld-link below. +RUN: rm -rf %t +RUN: mkdir %t +RUN: cp lld-link %t/lld-link +RUN: cd %t -CHECK-LABEL: - Module: {{.*}}pdb_lines_1_relative.obj -CHECK-NEXT: ObjFile: {{.*}}pdb_lines_1_relative.obj +RUN: yaml2obj %S/Inputs/pdb_lines_1_relative.yaml -o %t/pdb_lines_1_relative.obj +RUN: yaml2obj %S/Inputs/pdb_lines_2_relative.yaml -o %t/pdb_lines_2_relative.obj +RUN: ./lld-link -debug "-pdbsourcepath:c:\src" -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj +RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck %s +RUN: ./lld-link -debug "-pdbsourcepath:/usr/src" -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj +RUN: llvm-pdbutil pdb2yaml -modules -module-files -module-syms -subsections=lines,fc %t/out.pdb | FileCheck --check-prefix=POSIX %s + +CHECK-LABEL: - Module: 'c:\src{{[\\/]}}pdb_lines_1_relative.obj' +CHECK-NEXT: ObjFile: 'c:\src{{[\\/]}}pdb_lines_1_relative.obj' CHECK: SourceFiles: -CHECK-NEXT: - 'c:{{[\\/]}}src{{[\\/]}}pdb_lines_1.c' -CHECK-NEXT: - 'c:{{[\\/]}}src{{[\\/]}}foo.h' +CHECK-NEXT: - 'c:\src{{[\\/]}}pdb_lines_1.c' +CHECK-NEXT: - 'c:\src{{[\\/]}}foo.h' CHECK: Subsections: -CHECK: - FileName: 'c:{{[\\/]}}src{{[\\/]}}pdb_lines_1.c' -CHECK: - FileName: 'c:{{[\\/]}}src{{[\\/]}}foo.h' +CHECK: - FileName: 'c:\src{{[\\/]}}pdb_lines_1.c' +CHECK: - FileName: 'c:\src{{[\\/]}}foo.h' CHECK: - !FileChecksums -CHECK: - FileName: 'c:{{[\\/]}}src{{[\\/]}}pdb_lines_1.c' -CHECK: - FileName: 'c:{{[\\/]}}src{{[\\/]}}foo.h' +CHECK: - FileName: 'c:\src{{[\\/]}}pdb_lines_1.c' +CHECK: - FileName: 'c:\src{{[\\/]}}foo.h' -CHECK-LABEL: - Module: {{.*}}pdb_lines_2_relative.obj -CHECK-NEXT: ObjFile: {{.*}}pdb_lines_2_relative.obj +CHECK-LABEL: - Module: 'c:\src{{[\\/]}}pdb_lines_2_relative.obj' +CHECK-NEXT: ObjFile: 'c:\src{{[\\/]}}pdb_lines_2_relative.obj' CHECK: SourceFiles: -CHECK-NEXT: - 'c:{{[\\/]}}src{{[\\/]}}pdb_lines_2.c' +CHECK-NEXT: - 'c:\src{{[\\/]}}pdb_lines_2.c' CHECK: Subsections: -CHECK: - FileName: 'c:{{[\\/]}}src{{[\\/]}}pdb_lines_2.c' +CHECK: - FileName: 'c:\src{{[\\/]}}pdb_lines_2.c' CHECK: - !FileChecksums -CHECK: - FileName: 'c:{{[\\/]}}src{{[\\/]}}pdb_lines_2.c' +CHECK: - FileName: 'c:\src{{[\\/]}}pdb_lines_2.c' + +CHECK-LABEL: - Kind: S_ENVBLOCK +CHECK-NEXT: EnvBlockSym: +CHECK-NEXT: Entries: +CHECK-NEXT: - cwd +CHECK-NEXT: - 'c:\src' +CHECK-NEXT: - exe +CHECK-NEXT: - 'c:\src{{[\\/]}}lld-link' +CHECK-NEXT: - pdb +CHECK-NEXT: - 'c:\src{{[\\/]}}out.pdb' +CHECK-NEXT: - cmd +CHECK-NEXT: - '-debug -pdbsourcepath:c:\src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj' + + +POSIX-LABEL: - Module: '/usr/src{{[\\/]}}pdb_lines_1_relative.obj' +POSIX-NEXT: ObjFile: '/usr/src{{[\\/]}}pdb_lines_1_relative.obj' +POSIX: SourceFiles: +POSIX-NEXT: - '/usr/src{{[\\/]}}pdb_lines_1.c' +POSIX-NEXT: - '/usr/src{{[\\/]}}foo.h' +POSIX: Subsections: +POSIX: - FileName: '/usr/src{{[\\/]}}pdb_lines_1.c' +POSIX: - FileName: '/usr/src{{[\\/]}}foo.h' +POSIX: - !FileChecksums +POSIX: - FileName: '/usr/src{{[\\/]}}pdb_lines_1.c' +POSIX: - FileName: '/usr/src{{[\\/]}}foo.h' + +POSIX-LABEL: - Module: '/usr/src{{[\\/]}}pdb_lines_2_relative.obj' +POSIX-NEXT: ObjFile: '/usr/src{{[\\/]}}pdb_lines_2_relative.obj' +POSIX: SourceFiles: +POSIX-NEXT: - '/usr/src{{[\\/]}}pdb_lines_2.c' +POSIX: Subsections: +POSIX: - FileName: '/usr/src{{[\\/]}}pdb_lines_2.c' +POSIX: - !FileChecksums +POSIX: - FileName: '/usr/src{{[\\/]}}pdb_lines_2.c' + +POSIX-LABEL: - Kind: S_ENVBLOCK +POSIX-NEXT: EnvBlockSym: +POSIX-NEXT: Entries: +POSIX-NEXT: - cwd +POSIX-NEXT: - '/usr/src' +POSIX-NEXT: - exe +POSIX-NEXT: - '/usr/src{{[\\/]}}lld-link' +POSIX-NEXT: - pdb +POSIX-NEXT: - '/usr/src{{[\\/]}}out.pdb' +POSIX-NEXT: - cmd +POSIX-NEXT: - '-debug -pdbsourcepath:/usr/src -entry:main -nodefaultlib -out:out.exe -pdb:out.pdb pdb_lines_1_relative.obj pdb_lines_2_relative.obj' diff --git a/test/COFF/pdb-same-name.test b/test/COFF/pdb-same-name.test index 352bfc9f9942..52535107ca16 100644 --- a/test/COFF/pdb-same-name.test +++ b/test/COFF/pdb-same-name.test @@ -14,10 +14,10 @@ RAW: Modules RAW-NEXT: ============================================================ RAW-NEXT: Mod 0000 | `foo.obj`: -RAW-NEXT: Obj: `{{.*}}1\foo.lib`: +RAW-NEXT: Obj: `{{.*}}1{{[\\/]}}foo.lib`: RAW-NEXT: debug stream: 11, # files: 1, has ec info: false RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 `` RAW-NEXT: Mod 0001 | `foo.obj`: -RAW-NEXT: Obj: `{{.*}}2\foo.lib`: +RAW-NEXT: Obj: `{{.*}}2{{[\\/]}}foo.lib`: RAW-NEXT: debug stream: 12, # files: 1, has ec info: false RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 `` diff --git a/test/COFF/pdb-symbol-types.yaml b/test/COFF/pdb-symbol-types.yaml index 0ed1215ec8ee..d8741afd8cde 100644 --- a/test/COFF/pdb-symbol-types.yaml +++ b/test/COFF/pdb-symbol-types.yaml @@ -17,9 +17,13 @@ # CHECK-NEXT: ============================================================ # CHECK-NEXT: Records # CHECK-NEXT: 48 | S_PROCREF [size = 20] `main` -# CHECK-NEXT: module = 1, sum name = 0, offset = 116 +# CHECK-NEXT: module = 1, sum name = 0, offset = 116 +# CHECK-NEXT: 96 | S_UDT [size = 16] `UDT_Foo` +# CHECK-NEXT: original type = 0x1004 +# CHECK-NEXT: 112 | S_UDT [size = 12] `Foo` +# CHECK-NEXT: original type = 0x1004 # CHECK-NEXT: 68 | S_GDATA32 [size = 28] `global_foo` -# CHECK-NEXT: type = 0x1004 (Foo), addr = 0003:0000 +# CHECK-NEXT: type = 0x1004 (Foo), addr = 0003:0000 # CHECK: Symbols # CHECK: ============================================================ diff --git a/test/COFF/pdb-thunk.yaml b/test/COFF/pdb-thunk.yaml index 444800ff9e57..6435a17e8f62 100644 --- a/test/COFF/pdb-thunk.yaml +++ b/test/COFF/pdb-thunk.yaml @@ -84,7 +84,7 @@ sections: RegRelativeSym: Offset: 8 Type: 4097 - Register: CVRegRSP + Register: RSP VarName: this - Kind: S_PROC_ID_END ScopeEndSym: @@ -124,7 +124,7 @@ sections: RegRelativeSym: Offset: 8 Type: 4121 - Register: CVRegRSP + Register: RSP VarName: this - Kind: S_PROC_ID_END ScopeEndSym: @@ -164,7 +164,7 @@ sections: RegRelativeSym: Offset: 48 Type: 4143 - Register: CVRegRSP + Register: RSP VarName: this - Kind: S_PROC_ID_END ScopeEndSym: @@ -208,7 +208,7 @@ sections: RegRelativeSym: Offset: 8 Type: 4143 - Register: CVRegRSP + Register: RSP VarName: this - Kind: S_PROC_ID_END ScopeEndSym: @@ -2176,7 +2176,7 @@ sections: RegRelativeSym: Offset: 8 Type: 4097 - Register: CVRegRSP + Register: RSP VarName: this - Kind: S_PROC_ID_END ScopeEndSym: @@ -2222,7 +2222,7 @@ sections: RegRelativeSym: Offset: 8 Type: 4121 - Register: CVRegRSP + Register: RSP VarName: this - Kind: S_PROC_ID_END ScopeEndSym: diff --git a/test/COFF/pdb-type-server-invalid-signature.yaml b/test/COFF/pdb-type-server-invalid-signature.yaml new file mode 100644 index 000000000000..247e00096235 --- /dev/null +++ b/test/COFF/pdb-type-server-invalid-signature.yaml @@ -0,0 +1,140 @@ + +# RUN: cd %S/Inputs +# RUN: yaml2obj %s -o %t.obj +# RUN: lld-link %t.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main 2>&1 | FileCheck %s +# RUN: cd %S + +# CHECK: warning: Cannot use debug info for {{.*}}.obj +# CHECK-NEXT: The signature does not match; the file(s) might be out of date + +# Also test a valid match + +# RUN: cd %S/Inputs +# RUN: yaml2obj %S/Inputs/pdb-type-server-valid-signature.yaml -o %t2.obj +# RUN: lld-link %t2.obj -out:%t2.exe -debug -pdb:%t2.pdb -nodefaultlib -entry:main 2>&1 | FileCheck %s -check-prefix=VALID-SIGNATURE -allow-empty +# RUN: cd %S + +# VALID-SIGNATURE-NOT: warning: Cannot use debug info for {{.*}}.obj +# VALID-SIGNATURE-NOT: The signature does not match; the file(s) might be out of date + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 3 + DbgStart: 0 + DbgEnd: 2 + FunctionType: 4199 + Flags: [ ] + DisplayName: main + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 3 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'c:\src\llvm-project\build\t.c' + Lines: + - Offset: 0 + LineStart: 1 + IsStatement: true + EndDelta: 0 + Columns: + - !FileChecksums + Checksums: + - FileName: 'c:\src\llvm-project\build\t.c' + Kind: MD5 + Checksum: 270A878DCC1B845655B162F56C4F5020 + - !StringTable + Strings: + - 'c:\src\llvm-project\build\t.c' + Relocations: + - VirtualAddress: 44 + SymbolName: main + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 48 + SymbolName: main + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 100 + SymbolName: main + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 104 + SymbolName: main + Type: IMAGE_REL_AMD64_SECTION + - Name: '.debug$T' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Types: + - Kind: LF_TYPESERVER2 + TypeServer2: + Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}' + Age: 18 + Name: 'pdb-diff-cl.pdb' + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 33C0C3 +symbols: + - Name: '.debug$S' + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 328 + NumberOfRelocations: 4 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: '.debug$T' + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 564 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: '.text$mn' + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 3 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 4021952397 + Number: 0 + - Name: main + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/pdb-type-server-missing.yaml b/test/COFF/pdb-type-server-missing.yaml index fbbb46f6b4fd..1a8c9a05c3d9 100644 --- a/test/COFF/pdb-type-server-missing.yaml +++ b/test/COFF/pdb-type-server-missing.yaml @@ -1,10 +1,25 @@ # This is an object compiled with /Zi (see the LF_TYPESERVER2 record) without an # adjacent type server PDB. Test that LLD fails gracefully on it. +# Also try linking another OBJ with a reference to the same PDB -# RUN: yaml2obj %s -o %t.obj -# RUN: lld-link %t.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main 2>&1 | FileCheck %s +# RUN: yaml2obj %s -o %t1.obj +# RUN: yaml2obj %p/Inputs/pdb-type-server-missing-2.yaml -o %t2.obj +# RUN: lld-link %t1.obj %t2.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main 2>&1 | FileCheck %s -check-prefix=WARN +# RUN: lld-link %t1.obj %t2.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main /ignore:4099 2>&1 | FileCheck %s -check-prefix=IGNORE -allow-empty +# RUN: not lld-link %t1.obj %t2.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main /WX 2>&1 | FileCheck %s -check-prefix=ERR +# RUN: lld-link %t1.obj %t2.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main /ignore:4099 /WX 2>&1 | FileCheck %s -check-prefix=IGNORE-ERR -allow-empty -# CHECK: warning: Type server PDB for {{.*}}.obj is invalid, ignoring debug info. +# WARN: warning: Cannot use debug info for '{{.*}}.obj' [LNK4099] +# WARN-NEXT: {{N|n}}o such file or directory + +# IGNORE-NOT: warning: Cannot use debug info for '{{.*}}.obj' [LNK4099] +# IGNORE-NOT: {{N|n}}o such file or directory + +# ERR: error: Cannot use debug info for '{{.*}}.obj' [LNK4099] +# ERR-NEXT: {{N|n}}o such file or directory + +# IGNORE-ERR-NOT: error: Cannot use debug info for '{{.*}}.obj' [LNK4099] +# IGNORE-ERR-NOT: {{N|n}}o such file or directory --- !COFF header: diff --git a/test/COFF/pdb-type-server-native-errors.yaml b/test/COFF/pdb-type-server-native-errors.yaml new file mode 100644 index 000000000000..bc865411b3ad --- /dev/null +++ b/test/COFF/pdb-type-server-native-errors.yaml @@ -0,0 +1,130 @@ + +# RUN: cd %S/Inputs +# RUN: yaml2obj %s -o %t.obj +# RUN: lld-link %t.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main 2>&1 | FileCheck %s +# RUN: cd %S + +# CHECK: warning: Cannot use debug info for {{.*}}.obj +# CHECK-NEXT: The PDB file is corrupt. MSF superblock is missing + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 3 + DbgStart: 0 + DbgEnd: 2 + FunctionType: 4199 + Flags: [ ] + DisplayName: main + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 3 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'c:\src\llvm-project\build\t.c' + Lines: + - Offset: 0 + LineStart: 1 + IsStatement: true + EndDelta: 0 + Columns: + - !FileChecksums + Checksums: + - FileName: 'c:\src\llvm-project\build\t.c' + Kind: MD5 + Checksum: 270A878DCC1B845655B162F56C4F5020 + - !StringTable + Strings: + - 'c:\src\llvm-project\build\t.c' + Relocations: + - VirtualAddress: 44 + SymbolName: main + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 48 + SymbolName: main + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 100 + SymbolName: main + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 104 + SymbolName: main + Type: IMAGE_REL_AMD64_SECTION + - Name: '.debug$T' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Types: + - Kind: LF_TYPESERVER2 + TypeServer2: + Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}' + Age: 18 + Name: 'bad-block-size.pdb' + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 33C0C3 +symbols: + - Name: '.debug$S' + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 328 + NumberOfRelocations: 4 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: '.debug$T' + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 564 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: '.text$mn' + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 3 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 4021952397 + Number: 0 + - Name: main + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/pdb-type-server-simple.test b/test/COFF/pdb-type-server-simple.test index 51a92db8df7a..f69a34a98855 100644 --- a/test/COFF/pdb-type-server-simple.test +++ b/test/COFF/pdb-type-server-simple.test @@ -62,10 +62,12 @@ CHECK: {{.*}}: `b.c` CHECK-LABEL: Global Symbols CHECK: ============================================================ CHECK-NEXT: Records -CHECK-NEXT: 36 | S_PROCREF [size = 20] `main` -CHECK-NEXT: module = 1, sum name = 0, offset = 104 -CHECK-NEXT: 56 | S_PROCREF [size = 16] `g` -CHECK-NEXT: module = 2, sum name = 0, offset = 104 +CHECK-NEXT: 36 | S_PROCREF [size = 20] `main` +CHECK-NEXT: module = 1, sum name = 0, offset = 104 +CHECK-NEXT: 68 | S_PROCREF [size = 16] `g` +CHECK-NEXT: module = 2, sum name = 0, offset = 104 +CHECK-NEXT: 56 | S_UDT [size = 12] `Foo` +CHECK-NEXT: original type = 0x1006 CHECK-LABEL: Symbols CHECK: ============================================================ @@ -89,7 +91,7 @@ CHECK: size = 0, padding size = 0, offset to padding = 0 CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000 CHECK: flags = has async eh | opt speed CHECK: 180 | S_REGREL32 [size = 16] `p` -CHECK: type = [[FOO_PTR]] (Foo*), register = CVRegRSP, offset = 8 +CHECK: type = [[FOO_PTR]] (Foo*), register = RSP, offset = 8 CHECK: 196 | S_END [size = 4] CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `[[B_BUILD]]` CHECK-LABEL: Mod 0002 | `* Linker *`: diff --git a/test/COFF/pdb.test b/test/COFF/pdb.test index a7b2a215ec6b..5788b516ad84 100644 --- a/test/COFF/pdb.test +++ b/test/COFF/pdb.test @@ -193,25 +193,6 @@ RAW-NEXT: flags = function, addr = 0001:0000 RAW-NEXT: 0 | S_PUB32 [size = 20] `foo` RAW-NEXT: flags = function, addr = 0001:0016 RAW-NOT: S_PUB32 -RAW-NEXT: Hash Bitmap ( -RAW-NEXT: 0000: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 0020: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 0040: 00000000 20000000 00000000 00000000 00000000 00000000 00000000 00000000 |.... ...........................| -RAW-NEXT: 0060: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 0080: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 00A0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 00C0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 00E0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 0100: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 0120: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 0140: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 0160: 01000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 0180: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 01A0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 01C0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 01E0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 |................................| -RAW-NEXT: 0200: 00000000 |....| -RAW-NEXT: ) RAW-NEXT: Hash Entries RAW-NEXT: off = 21, refcnt = 1 RAW-NEXT: off = 1, refcnt = 1 diff --git a/test/COFF/pdbaltpath.test b/test/COFF/pdbaltpath.test new file mode 100644 index 000000000000..952e208867ef --- /dev/null +++ b/test/COFF/pdbaltpath.test @@ -0,0 +1,39 @@ +# RUN: yaml2obj %p/Inputs/empty.yaml > %t.obj + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbaltpath:hello.pdb +# RUN: llvm-readobj -coff-debug-directory %t.exe | FileCheck --check-prefix HELLO %s +# HELLO: PDBFileName: hello.pdb + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbaltpath:%_Pdb% +# RUN: llvm-readobj -coff-debug-directory %t.exe | FileCheck --check-prefix PDBVAR %s +# PDBVAR: PDBFileName: pdbaltpath.test.tmp.pdb + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbaltpath:foo%_ExT%.pdb +# RUN: llvm-readobj -coff-debug-directory %t.exe | FileCheck --check-prefix EXTVAR %s +# EXTVAR: PDBFileName: fooexe.pdb + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbaltpath:%_PDB +# RUN: llvm-readobj -coff-debug-directory %t.exe | FileCheck --check-prefix NOCLOSE %s +# NOCLOSE: PDBFileName: %_PDB + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbaltpath:foo%_PDB +# RUN: llvm-readobj -coff-debug-directory %t.exe | FileCheck --check-prefix NOCLOSE2 %s +# NOCLOSE2: PDBFileName: foo%_PDB + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbaltpath:foo%_PDB%bar%_EXT +# RUN: llvm-readobj -coff-debug-directory %t.exe | FileCheck --check-prefix CLOSEONE %s +# CLOSEONE: PDBFileName: foopdbaltpath.test.tmp.pdbbar%_EXT + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbaltpath:foo%_PDB%bar%_EXT% +# RUN: llvm-readobj -coff-debug-directory %t.exe | FileCheck --check-prefix CLOSETWO %s +# CLOSETWO: PDBFileName: foopdbaltpath.test.tmp.pdbbarexe + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbaltpath:foo%_PDB%bar%_EXT%a +# RUN: llvm-readobj -coff-debug-directory %t.exe | FileCheck --check-prefix CLOSETWO2 %s +# CLOSETWO2: PDBFileName: foopdbaltpath.test.tmp.pdbbarexea + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbaltpath:foo%FoO%bar%r%a 2>&1 | FileCheck --check-prefix UNKNOWN-WARN %s +# RUN: llvm-readobj -coff-debug-directory %t.exe | FileCheck --check-prefix ENVVARS %s +# UNKNOWN-WARN: only %_PDB% and %_EXT% supported in /pdbaltpath:, keeping %FoO% as literal +# UNKNOWN-WARN: only %_PDB% and %_EXT% supported in /pdbaltpath:, keeping %r% as literal +# ENVVARS: PDBFileName: foo%FoO%bar%r%a diff --git a/test/COFF/precomp-link.test b/test/COFF/precomp-link.test new file mode 100644 index 000000000000..b60b0b2f1d77 --- /dev/null +++ b/test/COFF/precomp-link.test @@ -0,0 +1,42 @@ +RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj %S/Inputs/precomp.obj /nodefaultlib /entry:main /debug /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf
+RUN: llvm-pdbutil dump -types %t.pdb | FileCheck %s
+
+RUN: lld-link %S/Inputs/precomp.obj %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf
+RUN: llvm-pdbutil dump -types %t.pdb | FileCheck %s
+
+RUN: lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-invalid.obj %S/Inputs/precomp.obj /nodefaultlib /entry:main /debug /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf 2>&1 | FileCheck %s -check-prefix FAILURE
+
+RUN: not lld-link %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib /entry:main /debug /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf 2>&1 | FileCheck %s -check-prefix FAILURE-MISSING-PRECOMPOBJ
+
+FAILURE: warning: Cannot use debug info for 'precomp-invalid.obj' [LNK4099]
+FAILURE-NEXT: failed to load reference '{{.*}}precomp.obj': The signature does not match; the file(s) might be out of date.
+
+FAILURE-MISSING-PRECOMPOBJ: warning: Cannot use debug info for 'precomp-a.obj' [LNK4099]
+FAILURE-MISSING-PRECOMPOBJ-NEXT: failed to load reference '{{.*}}precomp.obj': The path to this file must be provided on the command-line
+
+CHECK: Types (TPI Stream)
+CHECK-NOT: LF_PRECOMP
+CHECK-NOT: LF_ENDPRECOMP
+
+// precomp.h
+#pragma once
+int Function(char A);
+
+// precomp.cpp
+#include "precomp.h"
+
+// a.cpp
+#include "precomp.h"
+int main(void) {
+ Function('a');
+ return 0;
+}
+
+// b.cpp
+#include "precomp.h"
+int Function(char a) {
+ return (int)a;
+}
+
+// cl.exe precomp.cpp /Z7 /Ycprecomp.h /c
+// cl.exe a.cpp b.cpp /Z7 /Yuprecomp.h /c
diff --git a/test/COFF/reloc-discarded.s b/test/COFF/reloc-discarded.s index aa8fb3c3447a..378804b62312 100644 --- a/test/COFF/reloc-discarded.s +++ b/test/COFF/reloc-discarded.s @@ -10,6 +10,7 @@ # RUN: not lld-link -entry:main -nodefaultlib %t1.obj %t2.obj -out:%t.exe -opt:noref 2>&1 | FileCheck %s # CHECK: error: relocation against symbol in discarded section: assoc_global +# CHECK: >>> referenced by {{.*}}reloc-discarded{{.*}}.obj:(main) .section .bss,"bw",discard,main_global .globl main_global diff --git a/test/COFF/rsds.test b/test/COFF/rsds.test index 6ce92a9c5b03..b2c1be7478f5 100644 --- a/test/COFF/rsds.test +++ b/test/COFF/rsds.test @@ -1,9 +1,9 @@ # RUN: yaml2obj %s > %t.obj # RUN: rm -f %t.dll %t.pdb -# RUN: lld-link /debug /pdbaltpath:test1.pdb /dll /out:%t.dll /entry:DllMain %t.obj +# RUN: lld-link /debug /pdbaltpath:test.pdb /dll /out:%t.dll /entry:DllMain %t.obj # RUN: llvm-readobj -coff-debug-directory %t.dll > %t.1.txt -# RUN: lld-link /debug /pdbaltpath:test2.pdb /dll /out:%t.dll /entry:DllMain %t.obj +# RUN: lld-link /debug /pdbaltpath:test.pdb /dll /out:%t.dll /entry:DllMain %t.obj # RUN: llvm-readobj -coff-debug-directory %t.dll > %t.2.txt # RUN: cat %t.1.txt %t.2.txt | FileCheck %s @@ -12,7 +12,19 @@ # RUN: llvm-readobj -coff-debug-directory %t.dll > %t.3.txt # RUN: lld-link /debug /pdb:%t2.pdb /dll /out:%t.dll /entry:DllMain %t.obj # RUN: llvm-readobj -coff-debug-directory %t.dll > %t.4.txt -# RUN: cat %t.3.txt %t.4.txt | FileCheck %s +# RUN: cat %t.3.txt %t.4.txt | FileCheck --check-prefix TWOPDBS %s + +# RUN: rm -f %t.dll %t.pdb +# RUN: lld-link /Brepro /dll /out:%t.dll /entry:DllMain %t.obj +# RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck --check-prefix REPRO %s + +# RUN: rm -f %t.dll %t.pdb +# RUN: lld-link /Brepro /debug /dll /out:%t.dll /entry:DllMain %t.obj +# RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck --check-prefix REPRODEBUG %s + +# RUN: rm -f %t.dll %t.pdb +# RUN: lld-link /lldmingw /debug:dwarf /dll /out:%t.dll /entry:DllMain %t.obj +# RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck --check-prefix MINGW %s # CHECK: File: [[FILE:.*]].dll # CHECK: DebugDirectory [ @@ -29,7 +41,7 @@ # CHECK: PDBSignature: 0x53445352 # CHECK: PDBGUID: [[GUID:\(([A-Za-z0-9]{2} ?){16}\)]] # CHECK: PDBAge: 1 -# CHECK: PDBFileName: {{.*}}1.pdb +# CHECK: PDBFileName: {{.*}}.pdb # CHECK: } # CHECK: } # CHECK: ] @@ -47,12 +59,114 @@ # CHECK: PDBInfo { # CHECK: PDBSignature: 0x53445352 # CHECK: PDBGUID: [[GUID]] -# CHECK: PDBAge: 2 -# CHECK: PDBFileName: {{.*}}2.pdb +# CHECK: PDBAge: 1 +# CHECK: PDBFileName: {{.*}}.pdb # CHECK: } # CHECK: } # CHECK: ] +# TWOPDBS: File: [[FILE:.*]].dll +# TWOPDBS: DebugDirectory [ +# TWOPDBS: DebugEntry { +# TWOPDBS: Characteristics: 0x0 +# TWOPDBS: TimeDateStamp: +# TWOPDBS: MajorVersion: 0x0 +# TWOPDBS: MinorVersion: 0x0 +# TWOPDBS: Type: CodeView (0x2) +# TWOPDBS: SizeOfData: 0x{{[^0]}} +# TWOPDBS: AddressOfRawData: 0x{{[^0]}} +# TWOPDBS: PointerToRawData: 0x{{[^0]}} +# TWOPDBS: PDBInfo { +# TWOPDBS: PDBSignature: 0x53445352 +# TWOPDBS: PDBGUID: [[GUID:\(([A-Za-z0-9]{2} ?){16}\)]] +# TWOPDBS: PDBAge: 1 +# TWOPDBS: PDBFileName: {{.*}}.pdb +# TWOPDBS: } +# TWOPDBS: } +# TWOPDBS: ] +# TWOPDBS: File: [[FILE]].dll +# TWOPDBS: DebugDirectory [ +# TWOPDBS: DebugEntry { +# TWOPDBS: Characteristics: 0x0 +# TWOPDBS: TimeDateStamp: +# TWOPDBS: MajorVersion: 0x0 +# TWOPDBS: MinorVersion: 0x0 +# TWOPDBS: Type: CodeView (0x2) +# TWOPDBS: SizeOfData: 0x{{[^0]}} +# TWOPDBS: AddressOfRawData: 0x{{[^0]}} +# TWOPDBS: PointerToRawData: 0x{{[^0]}} +# TWOPDBS: PDBInfo { +# TWOPDBS: PDBSignature: 0x53445352 +# TWOPDBS-NOT: PDBGUID: [[GUID]] +# TWOPDBS: PDBAge: 1 +# TWOPDBS: PDBFileName: {{.*}}.pdb +# TWOPDBS: } +# TWOPDBS: } +# TWOPDBS: ] + +# REPRO: File: {{.*}}.dll +# REPRO: DebugDirectory [ +# REPRO: DebugEntry { +# REPRO: Characteristics: 0x0 +# REPRO: TimeDateStamp: +# REPRO: MajorVersion: 0x0 +# REPRO: MinorVersion: 0x0 +# REPRO: Type: Repro (0x10) +# REPRO: SizeOfData: 0x0 +# REPRO: AddressOfRawData: 0x0 +# REPRO: PointerToRawData: 0x0 +# REPRO: } +# REPRO: ] + +# REPRODEBUG: File: {{.*}}.dll +# REPRODEBUG: DebugDirectory [ +# REPRODEBUG: DebugEntry { +# REPRODEBUG: Characteristics: 0x0 +# REPRODEBUG: TimeDateStamp: +# REPRODEBUG: MajorVersion: 0x0 +# REPRODEBUG: MinorVersion: 0x0 +# REPRODEBUG: Type: CodeView (0x2) +# REPRODEBUG: SizeOfData: 0x{{[^0]}} +# REPRODEBUG: AddressOfRawData: 0x{{[^0]}} +# REPRODEBUG: PointerToRawData: 0x{{[^0]}} +# REPRODEBUG: PDBInfo { +# REPRODEBUG: PDBSignature: 0x53445352 +# REPRODEBUG: PDBGUID: +# REPRODEBUG: PDBAge: 1 +# REPRODEBUG: PDBFileName: +# REPRODEBUG: } +# REPRODEBUG: } +# REPRODEBUG: DebugEntry { +# REPRODEBUG: Characteristics: 0x0 +# REPRODEBUG: TimeDateStamp: +# REPRODEBUG: MajorVersion: 0x0 +# REPRODEBUG: MinorVersion: 0x0 +# REPRODEBUG: Type: Repro (0x10) +# REPRODEBUG: SizeOfData: 0x0 +# REPRODEBUG: AddressOfRawData: 0x0 +# REPRODEBUG: PointerToRawData: 0x0 +# REPRODEBUG: } +# REPRODEBUG: ] + +# MINGW: File: {{.*}}.dll +# MINGW: DebugDirectory [ +# MINGW: DebugEntry { +# MINGW: Characteristics: 0x0 +# MINGW: TimeDateStamp: +# MINGW: MajorVersion: 0x0 +# MINGW: MinorVersion: 0x0 +# MINGW: Type: CodeView (0x2) +# MINGW: SizeOfData: 0x{{[^0]}} +# MINGW: AddressOfRawData: 0x{{[^0]}} +# MINGW: PointerToRawData: 0x{{[^0]}} +# MINGW: PDBInfo { +# MINGW: PDBSignature: 0x53445352 +# MINGW: PDBGUID: [[GUID:\(([A-Za-z0-9]{2} ?){16}\)]] +# MINGW: PDBAge: 1 +# MINGW: PDBFileName: +# MINGW: } +# MINGW: } +# MINGW: ] --- !COFF header: Machine: IMAGE_FILE_MACHINE_I386 diff --git a/test/COFF/s_udt.s b/test/COFF/s_udt.s new file mode 100644 index 000000000000..8ad342e4e3d2 --- /dev/null +++ b/test/COFF/s_udt.s @@ -0,0 +1,476 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-windows-msvc < %s > %t.obj +# RUN: lld-link /DEBUG:FULL /nodefaultlib /entry:main %t.obj /PDB:%t.pdb /OUT:%t.exe +# RUN: llvm-pdbutil dump -types -globals -symbols -modi=0 %t.pdb | FileCheck %s + +# CHECK: Types (TPI Stream) +# CHECK-NEXT: ============================================================ +# CHECK: 0x1003 | LF_STRUCTURE [size = 44] `Struct` +# CHECK-NEXT: unique name: `.?AUStruct@@` +# CHECK-NEXT: vtable: <no type>, base list: <no type>, field list: <no type> +# CHECK-NEXT: options: forward ref (-> 0x1006) | has unique name, sizeof 0 +# CHECK-NEXT: 0x1004 | LF_POINTER [size = 12] +# CHECK-NEXT: referent = 0x1003, mode = pointer, opts = None, kind = ptr64 +# CHECK: 0x1006 | LF_STRUCTURE [size = 44] `Struct` +# CHECK-NEXT: unique name: `.?AUStruct@@` +# CHECK-NEXT: vtable: <no type>, base list: <no type>, field list: 0x1005 +# CHECK-NEXT: options: has unique name, sizeof 4 +# CHECK: Global Symbols +# CHECK-NEXT: ============================================================ +# CHECK: {{.*}} | S_UDT [size = 24] `StructTypedef` +# CHECK: original type = 0x1003 +# CHECK: {{.*}} | S_UDT [size = 16] `Struct` +# CHECK: original type = 0x1006 +# CHECK: {{.*}} | S_UDT [size = 20] `IntTypedef` +# CHECK: original type = 0x0074 (int) +# CHECK: Symbols +# CHECK-NEXT: ============================================================ +# CHECK: {{.*}} | S_GPROC32 [size = 44] `main` +# CHECK-NEXT: parent = 0, end = 252, addr = 0001:0000, code size = 52 +# CHECK-NEXT: type = `0x1002 (int (int, char**))`, debug start = 0, debug end = 0, flags = none
+# CHECK-NOT: {{.*}} | S_END +# CHECK: {{.*}} | S_UDT [size = 28] `main::LocalTypedef` +# CHECK-NEXT: original type = 0x1004 +# CHECK: {{.*}} | S_END [size = 4]
+
+# source code to re-generate:
+# clang-cl /Z7 /GS- /GR- /c foo.cpp
+#
+# struct Struct {
+# int x;
+# };
+#
+# using IntTypedef = int;
+# using StructTypedef = Struct;
+# Struct S;
+# StructTypedef SS;
+# IntTypedef I;
+#
+# int main(int argc, char **argv) {
+# using LocalTypedef = Struct*;
+# LocalTypedef SPtr;
+# return I + S.x + SS.x + SPtr->x;
+# } + + .text
+ .def @feat.00;
+ .scl 3;
+ .type 0;
+ .endef
+ .globl @feat.00
+.set @feat.00, 0
+ .intel_syntax noprefix
+ .def main;
+ .scl 2;
+ .type 32;
+ .endef
+ .globl main # -- Begin function main
+ .p2align 4, 0x90
+main: # @main
+.Lfunc_begin0:
+ .cv_func_id 0
+ .cv_file 1 "D:\\src\\llvmbuild\\cl\\Debug\\x64\\foo.cpp" "2B62298EE3EEF94E1D81FDFE18BD46A6" 1
+ .cv_loc 0 1 12 0 # foo.cpp:12:0
+.seh_proc main
+# %bb.0: # %entry
+ sub rsp, 32
+ .seh_stackalloc 32
+ .seh_endprologue
+ mov dword ptr [rsp + 28], 0
+ mov qword ptr [rsp + 16], rdx
+ mov dword ptr [rsp + 12], ecx
+.Ltmp0:
+ .cv_loc 0 1 15 0 # foo.cpp:15:0
+ mov ecx, dword ptr [rip + "?I@@3HA"]
+ add ecx, dword ptr [rip + "?S@@3UStruct@@A"]
+ add ecx, dword ptr [rip + "?SS@@3UStruct@@A"]
+ mov rdx, qword ptr [rsp]
+ add ecx, dword ptr [rdx]
+ mov eax, ecx
+ add rsp, 32
+ ret
+.Ltmp1:
+.Lfunc_end0:
+ .seh_handlerdata
+ .text
+ .seh_endproc
+ # -- End function
+ .bss
+ .globl "?S@@3UStruct@@A" # @"?S@@3UStruct@@A"
+ .p2align 2
+"?S@@3UStruct@@A":
+ .zero 4
+
+ .globl "?SS@@3UStruct@@A" # @"?SS@@3UStruct@@A"
+ .p2align 2
+"?SS@@3UStruct@@A":
+ .zero 4
+
+ .globl "?I@@3HA" # @"?I@@3HA"
+ .p2align 2
+"?I@@3HA":
+ .long 0 # 0x0
+
+ .section .drectve,"yn"
+ .ascii " /DEFAULTLIB:libcmt.lib"
+ .ascii " /DEFAULTLIB:oldnames.lib"
+ .section .debug$S,"dr"
+ .p2align 2
+ .long 4 # Debug section magic
+ .long 241
+ .long .Ltmp3-.Ltmp2 # Subsection size
+.Ltmp2:
+ .short .Ltmp5-.Ltmp4 # Record length
+.Ltmp4:
+ .short 4412 # Record kind: S_COMPILE3
+ .long 1 # Flags and language
+ .short 208 # CPUType
+ .short 8 # Frontend version
+ .short 0
+ .short 0
+ .short 0
+ .short 8000 # Backend version
+ .short 0
+ .short 0
+ .short 0
+ .asciz "clang version 8.0.0 " # Null-terminated compiler version string
+.Ltmp5:
+.Ltmp3:
+ .p2align 2
+ .long 241 # Symbol subsection for main
+ .long .Ltmp7-.Ltmp6 # Subsection size
+.Ltmp6:
+ .short .Ltmp9-.Ltmp8 # Record length
+.Ltmp8:
+ .short 4423 # Record kind: S_GPROC32_ID
+ .long 0 # PtrParent
+ .long 0 # PtrEnd
+ .long 0 # PtrNext
+ .long .Lfunc_end0-main # Code size
+ .long 0 # Offset after prologue
+ .long 0 # Offset before epilogue
+ .long 4099 # Function type index
+ .secrel32 main # Function section relative address
+ .secidx main # Function section index
+ .byte 0 # Flags
+ .asciz "main" # Function name
+.Ltmp9:
+ .short .Ltmp11-.Ltmp10 # Record length
+.Ltmp10:
+ .short 4114 # Record kind: S_FRAMEPROC
+ .long 32 # FrameSize
+ .long 0 # Padding
+ .long 0 # Offset of padding
+ .long 0 # Bytes of callee saved registers
+ .long 0 # Exception handler offset
+ .short 0 # Exception handler section
+ .long 81920 # Flags (defines frame register)
+.Ltmp11:
+ .short .Ltmp13-.Ltmp12 # Record length
+.Ltmp12:
+ .short 4414 # Record kind: S_LOCAL
+ .long 116 # TypeIndex
+ .short 1 # Flags
+ .asciz "argc"
+.Ltmp13:
+ .cv_def_range .Ltmp0 .Ltmp1, "B\021\f\000\000\000"
+ .short .Ltmp15-.Ltmp14 # Record length
+.Ltmp14:
+ .short 4414 # Record kind: S_LOCAL
+ .long 4096 # TypeIndex
+ .short 1 # Flags
+ .asciz "argv"
+.Ltmp15:
+ .cv_def_range .Ltmp0 .Ltmp1, "B\021\020\000\000\000"
+ .short .Ltmp17-.Ltmp16 # Record length
+.Ltmp16:
+ .short 4414 # Record kind: S_LOCAL
+ .long 4101 # TypeIndex
+ .short 0 # Flags
+ .asciz "SPtr"
+.Ltmp17:
+ .cv_def_range .Ltmp0 .Ltmp1, "B\021\000\000\000\000"
+ .short .Ltmp19-.Ltmp18 # Record length
+.Ltmp18:
+ .short 4360 # Record kind: S_UDT
+ .long 4101 # Type
+ .asciz "main::LocalTypedef"
+.Ltmp19:
+ .short 2 # Record length
+ .short 4431 # Record kind: S_PROC_ID_END
+.Ltmp7:
+ .p2align 2
+ .cv_linetable 0, main, .Lfunc_end0
+ .long 241 # Symbol subsection for globals
+ .long .Ltmp21-.Ltmp20 # Subsection size
+.Ltmp20:
+ .short .Ltmp23-.Ltmp22 # Record length
+.Ltmp22:
+ .short 4365 # Record kind: S_GDATA32
+ .long 4103 # Type
+ .secrel32 "?S@@3UStruct@@A" # DataOffset
+ .secidx "?S@@3UStruct@@A" # Segment
+ .asciz "S" # Name
+.Ltmp23:
+ .short .Ltmp25-.Ltmp24 # Record length
+.Ltmp24:
+ .short 4365 # Record kind: S_GDATA32
+ .long 4100 # Type
+ .secrel32 "?SS@@3UStruct@@A" # DataOffset
+ .secidx "?SS@@3UStruct@@A" # Segment
+ .asciz "SS" # Name
+.Ltmp25:
+ .short .Ltmp27-.Ltmp26 # Record length
+.Ltmp26:
+ .short 4365 # Record kind: S_GDATA32
+ .long 116 # Type
+ .secrel32 "?I@@3HA" # DataOffset
+ .secidx "?I@@3HA" # Segment
+ .asciz "I" # Name
+.Ltmp27:
+.Ltmp21:
+ .p2align 2
+ .long 241
+ .long .Ltmp29-.Ltmp28 # Subsection size
+.Ltmp28:
+ .short .Ltmp31-.Ltmp30 # Record length
+.Ltmp30:
+ .short 4360 # Record kind: S_UDT
+ .long 4103 # Type
+ .asciz "Struct"
+.Ltmp31:
+ .short .Ltmp33-.Ltmp32 # Record length
+.Ltmp32:
+ .short 4360 # Record kind: S_UDT
+ .long 4100 # Type
+ .asciz "StructTypedef"
+.Ltmp33:
+ .short .Ltmp35-.Ltmp34 # Record length
+.Ltmp34:
+ .short 4360 # Record kind: S_UDT
+ .long 116 # Type
+ .asciz "IntTypedef"
+.Ltmp35:
+.Ltmp29:
+ .p2align 2
+ .cv_filechecksums # File index to string table offset subsection
+ .cv_stringtable # String table
+ .long 241
+ .long .Ltmp37-.Ltmp36 # Subsection size
+.Ltmp36:
+ .short 6 # Record length
+ .short 4428 # Record kind: S_BUILDINFO
+ .long 4108 # LF_BUILDINFO index
+.Ltmp37:
+ .p2align 2
+ .section .debug$T,"dr"
+ .p2align 2
+ .long 4 # Debug section magic
+ # Pointer (0x1000) {
+ # TypeLeafKind: LF_POINTER (0x1002)
+ # PointeeType: char* (0x670)
+ # PtrType: Near64 (0xC)
+ # PtrMode: Pointer (0x0)
+ # IsFlat: 0
+ # IsConst: 0
+ # IsVolatile: 0
+ # IsUnaligned: 0
+ # IsRestrict: 0
+ # IsThisPtr&: 0
+ # IsThisPtr&&: 0
+ # SizeOf: 8
+ # }
+ .byte 0x0a, 0x00, 0x02, 0x10
+ .byte 0x70, 0x06, 0x00, 0x00
+ .byte 0x0c, 0x00, 0x01, 0x00
+ # ArgList (0x1001) {
+ # TypeLeafKind: LF_ARGLIST (0x1201)
+ # NumArgs: 2
+ # Arguments [
+ # ArgType: int (0x74)
+ # ArgType: char** (0x1000)
+ # ]
+ # }
+ .byte 0x0e, 0x00, 0x01, 0x12
+ .byte 0x02, 0x00, 0x00, 0x00
+ .byte 0x74, 0x00, 0x00, 0x00
+ .byte 0x00, 0x10, 0x00, 0x00
+ # Procedure (0x1002) {
+ # TypeLeafKind: LF_PROCEDURE (0x1008)
+ # ReturnType: int (0x74)
+ # CallingConvention: NearC (0x0)
+ # FunctionOptions [ (0x0)
+ # ]
+ # NumParameters: 2
+ # ArgListType: (int, char**) (0x1001)
+ # }
+ .byte 0x0e, 0x00, 0x08, 0x10
+ .byte 0x74, 0x00, 0x00, 0x00
+ .byte 0x00, 0x00, 0x02, 0x00
+ .byte 0x01, 0x10, 0x00, 0x00
+ # FuncId (0x1003) {
+ # TypeLeafKind: LF_FUNC_ID (0x1601)
+ # ParentScope: 0x0
+ # FunctionType: int (int, char**) (0x1002)
+ # Name: main
+ # }
+ .byte 0x12, 0x00, 0x01, 0x16
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x02, 0x10, 0x00, 0x00
+ .byte 0x6d, 0x61, 0x69, 0x6e
+ .byte 0x00, 0xf3, 0xf2, 0xf1
+ # Struct (0x1004) {
+ # TypeLeafKind: LF_STRUCTURE (0x1505)
+ # MemberCount: 0
+ # Properties [ (0x280)
+ # ForwardReference (0x80)
+ # HasUniqueName (0x200)
+ # ]
+ # FieldList: 0x0
+ # DerivedFrom: 0x0
+ # VShape: 0x0
+ # SizeOf: 0
+ # Name: Struct
+ # LinkageName: .?AUStruct@@
+ # }
+ .byte 0x2a, 0x00, 0x05, 0x15
+ .byte 0x00, 0x00, 0x80, 0x02
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x00, 0x00, 0x53, 0x74
+ .byte 0x72, 0x75, 0x63, 0x74
+ .byte 0x00, 0x2e, 0x3f, 0x41
+ .byte 0x55, 0x53, 0x74, 0x72
+ .byte 0x75, 0x63, 0x74, 0x40
+ .byte 0x40, 0x00, 0xf2, 0xf1
+ # Pointer (0x1005) {
+ # TypeLeafKind: LF_POINTER (0x1002)
+ # PointeeType: Struct (0x1004)
+ # PtrType: Near64 (0xC)
+ # PtrMode: Pointer (0x0)
+ # IsFlat: 0
+ # IsConst: 0
+ # IsVolatile: 0
+ # IsUnaligned: 0
+ # IsRestrict: 0
+ # IsThisPtr&: 0
+ # IsThisPtr&&: 0
+ # SizeOf: 8
+ # }
+ .byte 0x0a, 0x00, 0x02, 0x10
+ .byte 0x04, 0x10, 0x00, 0x00
+ .byte 0x0c, 0x00, 0x01, 0x00
+ # FieldList (0x1006) {
+ # TypeLeafKind: LF_FIELDLIST (0x1203)
+ # DataMember {
+ # TypeLeafKind: LF_MEMBER (0x150D)
+ # AccessSpecifier: Public (0x3)
+ # Type: int (0x74)
+ # FieldOffset: 0x0
+ # Name: x
+ # }
+ # }
+ .byte 0x0e, 0x00, 0x03, 0x12
+ .byte 0x0d, 0x15, 0x03, 0x00
+ .byte 0x74, 0x00, 0x00, 0x00
+ .byte 0x00, 0x00, 0x78, 0x00
+ # Struct (0x1007) {
+ # TypeLeafKind: LF_STRUCTURE (0x1505)
+ # MemberCount: 1
+ # Properties [ (0x200)
+ # HasUniqueName (0x200)
+ # ]
+ # FieldList: <field list> (0x1006)
+ # DerivedFrom: 0x0
+ # VShape: 0x0
+ # SizeOf: 4
+ # Name: Struct
+ # LinkageName: .?AUStruct@@
+ # }
+ .byte 0x2a, 0x00, 0x05, 0x15
+ .byte 0x01, 0x00, 0x00, 0x02
+ .byte 0x06, 0x10, 0x00, 0x00
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x04, 0x00, 0x53, 0x74
+ .byte 0x72, 0x75, 0x63, 0x74
+ .byte 0x00, 0x2e, 0x3f, 0x41
+ .byte 0x55, 0x53, 0x74, 0x72
+ .byte 0x75, 0x63, 0x74, 0x40
+ .byte 0x40, 0x00, 0xf2, 0xf1
+ # StringId (0x1008) {
+ # TypeLeafKind: LF_STRING_ID (0x1605)
+ # Id: 0x0
+ # StringData: D:\src\llvmbuild\cl\Debug\x64\foo.cpp
+ # }
+ .byte 0x2e, 0x00, 0x05, 0x16
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x44, 0x3a, 0x5c, 0x73
+ .byte 0x72, 0x63, 0x5c, 0x6c
+ .byte 0x6c, 0x76, 0x6d, 0x62
+ .byte 0x75, 0x69, 0x6c, 0x64
+ .byte 0x5c, 0x63, 0x6c, 0x5c
+ .byte 0x44, 0x65, 0x62, 0x75
+ .byte 0x67, 0x5c, 0x78, 0x36
+ .byte 0x34, 0x5c, 0x66, 0x6f
+ .byte 0x6f, 0x2e, 0x63, 0x70
+ .byte 0x70, 0x00, 0xf2, 0xf1
+ # UdtSourceLine (0x1009) {
+ # TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
+ # UDT: Struct (0x1007)
+ # SourceFile: D:\src\llvmbuild\cl\Debug\x64\foo.cpp (0x1008)
+ # LineNumber: 1
+ # }
+ .byte 0x0e, 0x00, 0x06, 0x16
+ .byte 0x07, 0x10, 0x00, 0x00
+ .byte 0x08, 0x10, 0x00, 0x00
+ .byte 0x01, 0x00, 0x00, 0x00
+ # StringId (0x100A) {
+ # TypeLeafKind: LF_STRING_ID (0x1605)
+ # Id: 0x0
+ # StringData: D:\\src\\llvmbuild\\cl\\Debug\\x64
+ # }
+ .byte 0x2a, 0x00, 0x05, 0x16
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x44, 0x3a, 0x5c, 0x5c
+ .byte 0x73, 0x72, 0x63, 0x5c
+ .byte 0x5c, 0x6c, 0x6c, 0x76
+ .byte 0x6d, 0x62, 0x75, 0x69
+ .byte 0x6c, 0x64, 0x5c, 0x5c
+ .byte 0x63, 0x6c, 0x5c, 0x5c
+ .byte 0x44, 0x65, 0x62, 0x75
+ .byte 0x67, 0x5c, 0x5c, 0x78
+ .byte 0x36, 0x34, 0x00, 0xf1
+ # StringId (0x100B) {
+ # TypeLeafKind: LF_STRING_ID (0x1605)
+ # Id: 0x0
+ # StringData: foo.cpp
+ # }
+ .byte 0x0e, 0x00, 0x05, 0x16
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x66, 0x6f, 0x6f, 0x2e
+ .byte 0x63, 0x70, 0x70, 0x00
+ # BuildInfo (0x100C) {
+ # TypeLeafKind: LF_BUILDINFO (0x1603)
+ # NumArgs: 5
+ # Arguments [
+ # ArgType: D:\\src\\llvmbuild\\cl\\Debug\\x64 (0x100A)
+ # ArgType: 0x0
+ # ArgType: foo.cpp (0x100B)
+ # ArgType: 0x0
+ # ArgType: 0x0
+ # ]
+ # }
+ .byte 0x1a, 0x00, 0x03, 0x16
+ .byte 0x05, 0x00, 0x0a, 0x10
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x00, 0x00, 0x0b, 0x10
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x00, 0x00, 0x00, 0x00
+ .byte 0x00, 0x00, 0xf2, 0xf1
+
+ .addrsig
+ .addrsig_sym "?S@@3UStruct@@A"
+ .addrsig_sym "?SS@@3UStruct@@A"
+ .addrsig_sym "?I@@3HA"
diff --git a/test/COFF/subsystem-inference-mingw.s b/test/COFF/subsystem-inference-mingw.s new file mode 100644 index 000000000000..3339e6408af1 --- /dev/null +++ b/test/COFF/subsystem-inference-mingw.s @@ -0,0 +1,17 @@ +# REQUIRES: x86 +# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.o + +# RUN: lld-link -lldmingw %t.o -out:%t.exe +# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s + +# CHECK: AddressOfEntryPoint: 0x1001 +# CHECK: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3) + + .text + .globl foo + .globl mainCRTStartup +foo: + ret +mainCRTStartup: + call foo + ret diff --git a/test/COFF/subsystem-inference2.test b/test/COFF/subsystem-inference2.test new file mode 100644 index 000000000000..0c159a7ded55 --- /dev/null +++ b/test/COFF/subsystem-inference2.test @@ -0,0 +1,54 @@ +# RUN: yaml2obj %s > %t.obj +# RUN: lld-link /out:%t.exe %t.obj 2>&1 | FileCheck -check-prefix=WARN %s +# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s + +# WARN: warning: found main and WinMain; defaulting to /subsystem:console +# CHECK: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: B82A000000C3 +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 6 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: WinMain + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: mainCRTStartup + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: WinMainCRTStartup + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/subsystem-inference32.test b/test/COFF/subsystem-inference32.test new file mode 100644 index 000000000000..8e66a85a7920 --- /dev/null +++ b/test/COFF/subsystem-inference32.test @@ -0,0 +1,74 @@ +# RUN: sed -e s/ENTRYNAME/_main/ %s | yaml2obj > %t.obj +# RUN: lld-link /out:%t.exe %t.obj +# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=MAIN %s + +# RUN: sed s/ENTRYNAME/_wmain/ %s | yaml2obj > %t.obj +# RUN: lld-link /out:%t.exe %t.obj +# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=WMAIN %s + +# RUN: sed s/ENTRYNAME/_WinMain@16/ %s | yaml2obj > %t.obj +# RUN: lld-link /out:%t.exe %t.obj +# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=WINMAIN %s + +# RUN: sed s/ENTRYNAME/_wWinMain@16/ %s | yaml2obj > %t.obj +# RUN: lld-link /out:%t.exe %t.obj +# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=WWINMAIN %s + +# MAIN: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI +# WMAIN: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI +# WINMAIN: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI +# WWINMAIN: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_GUI + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_I386 + Characteristics: [] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: B82A000000C3 +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 6 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: ENTRYNAME + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: _mainCRTStartup + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: _wmainCRTStartup + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: _WinMainCRTStartup + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: _wWinMainCRTStartup + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/thinlto-archives.ll b/test/COFF/thinlto-archives.ll index 9a47a3a6feb6..6a27115705b1 100644 --- a/test/COFF/thinlto-archives.ll +++ b/test/COFF/thinlto-archives.ll @@ -6,9 +6,17 @@ ; RUN: opt -thinlto-bc -o %T/thinlto-archives/b/bar.obj %S/Inputs/bar.ll ; RUN: llvm-ar crs %T/thinlto-archives/a.lib %T/thinlto-archives/a/bar.obj ; RUN: llvm-ar crs %T/thinlto-archives/b.lib %T/thinlto-archives/b/bar.obj -; RUN: lld-link /out:%T/thinlto-archives/main.exe -entry:main \ -; RUN: -subsystem:console %T/thinlto-archives/main.obj \ +; RUN: lld-link -out:%T/thinlto-archives/main.exe -entry:main \ +; RUN: -lldsavetemps -subsystem:console %T/thinlto-archives/main.obj \ ; RUN: %T/thinlto-archives/a.lib %T/thinlto-archives/b.lib +; RUN: FileCheck %s < %T/thinlto-archives/main.exe.resolution.txt + +; CHECK: {{/thinlto-archives/main.obj$}} +; CHECK: {{^-r=.*/thinlto-archives/main.obj,main,px$}} +; CHECK: {{/thinlto-archives/a.libbar.obj$}} +; CHECK-NEXT: {{^-r=.*/thinlto-archives/a.libbar.obj,foo,p$}} +; CHECK-NEXT: {{/thinlto-archives/b.libbar.obj$}} +; CHECK-NEXT: {{^-r=.*/thinlto-archives/b.libbar.obj,bar,p$}} target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-windows-msvc" diff --git a/test/COFF/undefined-symbol-cv.s b/test/COFF/undefined-symbol-cv.s index 31a44c384c75..e730c5dfc9f4 100644 --- a/test/COFF/undefined-symbol-cv.s +++ b/test/COFF/undefined-symbol-cv.s @@ -2,19 +2,19 @@ # RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s # RUN: not lld-link /out:%t.exe %t.obj 2>&1 | FileCheck %s -# CHECK: error: undefined symbol: ?foo@@YAHXZ +# CHECK: error: undefined symbol: "int __cdecl foo(void)" (?foo@@YAHXZ) # CHECK-NEXT: >>> referenced by file1.cpp:1 # CHECK-NEXT: >>> {{.*}}.obj:(main) # CHECK-NEXT: >>> referenced by file1.cpp:2 # CHECK-NEXT: >>> {{.*}}.obj:(main) - -# CHECK: error: undefined symbol: ?bar@@YAHXZ +# CHECK-EMPTY: +# CHECK-NEXT: error: undefined symbol: "int __cdecl bar(void)" (?bar@@YAHXZ) # CHECK-NEXT: >>> referenced by file2.cpp:3 # CHECK-NEXT: >>> {{.*}}.obj:(main) # CHECK-NEXT: >>> referenced by file1.cpp:4 # CHECK-NEXT: >>> {{.*}}.obj:(f1) - -# CHECK: error: undefined symbol: ?baz@@YAHXZ +# CHECK-EMPTY: +# CHECK-NEXT: error: undefined symbol: "int __cdecl baz(void)" (?baz@@YAHXZ) # CHECK-NEXT: >>> referenced by file1.cpp:5 # CHECK-NEXT: >>> {{.*}}.obj:(f2) diff --git a/test/COFF/undefined-symbol.s b/test/COFF/undefined-symbol.s index 5d002d82d23c..31da50a9e181 100644 --- a/test/COFF/undefined-symbol.s +++ b/test/COFF/undefined-symbol.s @@ -2,15 +2,15 @@ # RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s # RUN: not lld-link /out:%t.exe %t.obj 2>&1 | FileCheck %s -# CHECK: error: undefined symbol: ?foo@@YAHXZ +# CHECK: error: undefined symbol: "int __cdecl foo(void)" (?foo@@YAHXZ) # CHECK-NEXT: >>> referenced by {{.*}}.obj:(main) # CHECK-NEXT: >>> referenced by {{.*}}.obj:(main) - -# CHECK: error: undefined symbol: ?bar@@YAHXZ +# CHECK-EMPTY: +# CHECK-NEXT: error: undefined symbol: "int __cdecl bar(void)" (?bar@@YAHXZ) # CHECK-NEXT: >>> referenced by {{.*}}.obj:(main) # CHECK-NEXT: >>> referenced by {{.*}}.obj:(f1) - -# CHECK: error: undefined symbol: ?baz@@YAHXZ +# CHECK-EMPTY: +# CHECK-NEXT: error: undefined symbol: "__declspec(dllimport) int __cdecl baz(void)" (__imp_?baz@@YAHXZ) # CHECK-NEXT: >>> referenced by {{.*}}.obj:(f2) .section .text,"xr",one_only,main @@ -27,4 +27,4 @@ f1: .section .text,"xr",one_only,f2 .globl f2 f2: - call "?baz@@YAHXZ" + callq *"__imp_?baz@@YAHXZ"(%rip) diff --git a/test/COFF/wholearchive.s b/test/COFF/wholearchive.s index 6a601eba6b0d..cb19d4ddde07 100644 --- a/test/COFF/wholearchive.s +++ b/test/COFF/wholearchive.s @@ -1,6 +1,7 @@ # REQUIRES: x86 # RUN: yaml2obj < %p/Inputs/export.yaml > %t.archive.obj +# RUN: rm -f %t.archive.lib # RUN: llvm-ar rcs %t.archive.lib %t.archive.obj # RUN: llvm-mc -triple=x86_64-windows-msvc %s -filetype=obj -o %t.main.obj |
