Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / COFF / link-dll-i386.s
blob7121678770109cc38cf83af0e47a84477cfa655f
1 # REQUIRES: x86
3 ## Test creating a DLL and linking against the DLL without using an import
4 ## library.
6 ## Test on i386 with cdecl decorated symbols.
8 ## Linking the executable with -opt:noref, to make sure that we don't
9 ## pull in more import entries than what's needed, even if not running GC.
11 # RUN: split-file %s %t.dir
13 # RUN: llvm-mc -filetype=obj -triple=i386-windows-gnu %t.dir/lib.s -o %t.lib.o
14 # RUN: lld-link -safeseh:no -noentry -dll -def:%t.dir/lib.def %t.lib.o -out:%t.lib.dll -implib:%t.implib.lib
15 # RUN: llvm-mc -filetype=obj -triple=i386-windows-gnu %t.dir/main.s -o %t.main.o
16 # RUN: lld-link -lldmingw %t.main.o -out:%t.main.exe %t.lib.dll -opt:noref -verbose 2>&1 | FileCheck --check-prefix=LOG %s
17 # RUN: llvm-readobj --coff-imports %t.main.exe | FileCheck %s
19 #--- lib.s
20 .text
21 .global _func1
22 _func1:
23 ret
24 .global _func2
25 _func2:
26 ret
27 .global _func3
28 _func3:
29 ret
30 .data
31 .global _variable
32 _variable:
33 .int 42
35 #--- lib.def
36 EXPORTS
37 func1
38 func2
39 func3
40 variable
42 #--- main.s
43 .text
44 .global _mainCRTStartup
45 _mainCRTStartup:
46 call _func2
47 movl .refptr._variable, %eax
48 movl (%eax), %eax
49 ret
51 .section .rdata$.refptr._variable,"dr",discard,.refptr._variable
52 .globl .refptr._variable
53 .refptr._variable:
54 .long _variable
56 # CHECK: Import {
57 # CHECK-NEXT: Name: link-dll-i386.s.tmp.lib.dll
58 # CHECK-NEXT: ImportLookupTableRVA:
59 # CHECK-NEXT: ImportAddressTableRVA
60 # CHECK-NEXT: Symbol: func2
61 # CHECK-NEXT: Symbol: variable
62 # CHECK-NEXT: }
64 # LOG: Automatically importing _variable from link-dll-i386.s.tmp.lib.dll