1# REQUIRES: x86 2 3## Test creating a DLL and linking against the DLL without using an import 4## library. 5 6## Test on i386 with cdecl decorated symbols. 7 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. 10 11# RUN: split-file %s %t.dir 12 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 18 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 34 35#--- lib.def 36EXPORTS 37func1 38func2 39func3 40variable 41 42#--- main.s 43.text 44.global _mainCRTStartup 45_mainCRTStartup: 46 call _func2 47 movl .refptr._variable, %eax 48 movl (%eax), %eax 49 ret 50 51.section .rdata$.refptr._variable,"dr",discard,.refptr._variable 52.globl .refptr._variable 53.refptr._variable: 54 .long _variable 55 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: } 63 64# LOG: Automatically importing _variable from link-dll-i386.s.tmp.lib.dll 65