summaryrefslogtreecommitdiff
path: root/test/pecoff/importlib.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/pecoff/importlib.test')
-rw-r--r--test/pecoff/importlib.test55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/pecoff/importlib.test b/test/pecoff/importlib.test
new file mode 100644
index 0000000000000..28e74f9dc78d1
--- /dev/null
+++ b/test/pecoff/importlib.test
@@ -0,0 +1,55 @@
+# REQUIRES: x86
+
+# Verify that lld can handle .lib files. "main.obj" refers "var" and
+# "fn" defined in "vars.lib".
+#
+# RUN: yaml2obj %p/Inputs/vars-main-x86.obj.yaml > %t.obj
+#
+# RUN: lld -flavor link /out:%t1.exe /subsystem:console /entry:main /opt:noref \
+# RUN: -- %t.obj %p/Inputs/vars.lib
+# RUN: llvm-objdump -d %t1.exe | FileCheck -check-prefix=TEXT %s
+# RUN: llvm-readobj -coff-imports %t1.exe | FileCheck -check-prefix=IMPORT %s
+#
+# RUN: lld -flavor link /out:%t2.exe /subsystem:console /entry:main /opt:noref \
+# RUN: /libpath:%p/Inputs -- %t.obj vars.lib
+# RUN: llvm-objdump -d %t2.exe | FileCheck -check-prefix=TEXT %s
+# RUN: llvm-readobj -coff-imports %t2.exe | FileCheck -check-prefix=IMPORT %s
+#
+# RUN: lld -flavor link /out:%t3.exe /subsystem:console /entry:main /opt:noref \
+# RUN: /libpath:%p/Inputs /defaultlib:vars.lib -- %t.obj
+# RUN: llvm-objdump -d %t3.exe | FileCheck -check-prefix=TEXT %s
+# RUN: llvm-readobj -coff-imports %t3.exe | FileCheck -check-prefix=IMPORT %s
+#
+# RUN: env LIB=%p/Inputs lld -flavor link /out:%t4.exe /subsystem:console \
+# RUN: /opt:noref /entry:main -- %t.obj vars.lib
+# RUN: llvm-objdump -d %t4.exe | FileCheck -check-prefix=TEXT %s
+# RUN: llvm-readobj -coff-imports %t4.exe | FileCheck -check-prefix=IMPORT %s
+#
+# RUN: env LINK="/out:%t5.exe /subsystem:console /entry:main /opt:noref \
+# RUN: -- %t.obj" lld -flavor link %p/Inputs/vars.lib
+# RUN: llvm-objdump -d %t5.exe | FileCheck -check-prefix=TEXT %s
+# RUN: llvm-readobj -coff-imports %t5.exe | FileCheck -check-prefix=IMPORT %s
+
+TEXT: Disassembly of section .text:
+TEXT-NEXT: .text:
+TEXT-NEXT: pushl %ebp
+TEXT-NEXT: movl %esp, %ebp
+TEXT-NEXT: pushl %esi
+TEXT-NEXT: calll *{{[0-9]+}}
+TEXT-NEXT: movl {{[0-9]+}}, %ecx
+TEXT-NEXT: movl (%ecx), %esi
+TEXT-NEXT: addl %eax, %esi
+TEXT-NEXT: calll *{{[0-9]+}}
+TEXT-NEXT: addl %esi, %eax
+TEXT-NEXT: popl %esi
+TEXT-NEXT: popl %ebp
+TEXT-NEXT: ret
+
+IMPORT: Import {
+IMPORT-NEXT: Name: vars.dll
+IMPORT-NEXT: ImportLookupTableRVA: 0x4000
+IMPORT-NEXT: ImportAddressTableRVA: 0x2000
+IMPORT-NEXT: Symbol: _name_with_underscore (0)
+IMPORT-NEXT: Symbol: fn (1)
+IMPORT-NEXT: Symbol: (1)
+IMPORT-NEXT: }