[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / COFF / link-dll.s
blob997c5b02c7abacde5d09c826e73f9d9d13e90806
1 # REQUIRES: x86
3 ## Test creating a DLL and linking against the DLL without using an import
4 ## library.
6 ## Explicitly creating an import library but naming it differently than the
7 ## DLL, to avoid any risk of implicitly referencing it instead of the DLL
8 ## itself.
10 ## Linking the executable with -opt:noref, to make sure that we don't
11 ## pull in more import entries than what's needed, even if not running GC.
13 # RUN: split-file %s %t.dir
15 # RUN: llvm-mc -filetype=obj -triple=x86_64-windows-gnu %t.dir/lib.s -o %t.lib.o
16 # RUN: lld-link -noentry -dll -def:%t.dir/lib.def %t.lib.o -out:%t.lib.dll -implib:%t.implib.lib
17 # RUN: llvm-mc -filetype=obj -triple=x86_64-windows-gnu %t.dir/main.s -o %t.main.o
18 # RUN: lld-link -lldmingw %t.main.o -out:%t.main.exe %t.lib.dll -opt:noref -verbose 2>&1 | FileCheck --check-prefix=LOG %s
19 # RUN: llvm-readobj --coff-imports %t.main.exe | FileCheck %s
21 #--- lib.s
22 .text
23 .global func1
24 func1:
25 ret
26 .global func2
27 func2:
28 ret
29 .global func3
30 func3:
31 ret
32 .data
33 .global variable
34 variable:
35 .int 42
37 #--- lib.def
38 EXPORTS
39 func1
40 func2
41 func3
42 variable
44 #--- main.s
45 .text
46 .global mainCRTStartup
47 mainCRTStartup:
48 call func2
49 movq .refptr.variable(%rip), %rax
50 movl (%rax), %eax
51 ret
53 .section .rdata$.refptr.variable,"dr",discard,.refptr.variable
54 .globl .refptr.variable
55 .refptr.variable:
56 .quad variable
58 # CHECK: Import {
59 # CHECK-NEXT: Name: link-dll.s.tmp.lib.dll
60 # CHECK-NEXT: ImportLookupTableRVA:
61 # CHECK-NEXT: ImportAddressTableRVA
62 # CHECK-NEXT: Symbol: func2
63 # CHECK-NEXT: Symbol: variable
64 # CHECK-NEXT: }
66 # LOG: Automatically importing variable from link-dll.s.tmp.lib.dll