diff --git a/lld/test/COFF/export.test b/lld/test/COFF/export.test --- a/lld/test/COFF/export.test +++ b/lld/test/COFF/export.test @@ -68,10 +68,10 @@ # RUN: llvm-nm -M %t.lib | FileCheck --check-prefix=SYMTAB %s SYMTAB: __imp_exportfn1 in export.test.tmp.DLL -SYMTAB: exportfn1 in export.test.tmp.DLL SYMTAB: __imp_exportfn2 in export.test.tmp.DLL -SYMTAB: exportfn2 in export.test.tmp.DLL SYMTAB: __imp_exportfn3 in export.test.tmp.DLL +SYMTAB: exportfn1 in export.test.tmp.DLL +SYMTAB: exportfn2 in export.test.tmp.DLL SYMTAB: exportfn3 in export.test.tmp.DLL # RUN: lld-link /out:%t.dll /dll %t.obj /export:foo=kernel32.foobar diff --git a/llvm/lib/Object/COFFImportFile.cpp b/llvm/lib/Object/COFFImportFile.cpp --- a/llvm/lib/Object/COFFImportFile.cpp +++ b/llvm/lib/Object/COFFImportFile.cpp @@ -611,7 +611,7 @@ } return writeArchive(Path, Members, /*WriteSymtab*/ true, - object::Archive::K_GNU, + MinGW ? object::Archive::K_GNU : object::Archive::K_COFF, /*Deterministic*/ true, /*Thin*/ false); } diff --git a/llvm/test/tools/llvm-dlltool/coff-exports.def b/llvm/test/tools/llvm-dlltool/coff-exports.def --- a/llvm/test/tools/llvm-dlltool/coff-exports.def +++ b/llvm/test/tools/llvm-dlltool/coff-exports.def @@ -1,13 +1,16 @@ ; RUN: llvm-dlltool -m i386:x86-64 --input-def %s --output-lib %t.a ; RUN: llvm-readobj %t.a | FileCheck %s +; RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=SYMTAB %s ; RUN: llvm-dlltool -m arm64 --input-def %s --output-lib %t.a ; RUN: llvm-readobj %t.a | FileCheck %s +; RUN: llvm-nm --print-armap %t.a | FileCheck --check-prefix=SYMTAB %s LIBRARY test.dll EXPORTS TestFunction1 TestFunction2; TestFunction3 ; This is a comment +AnotherFunction ; CHECK: File: test.dll ; CHECK: Format: COFF-import-file @@ -21,3 +24,9 @@ ; CHECK: Name type: name ; CHECK-NEXT: Symbol: __imp_TestFunction3{{$}} ; CHECK-NEXT: Symbol: TestFunction3{{$}} + +; SYMTAB: Archive map +; SYMTAB: TestFunction1 in test.dll +; SYMTAB: TestFunction2 in test.dll +; SYMTAB: TestFunction3 in test.dll +; SYMTAB: AnotherFunction in test.dll diff --git a/llvm/test/tools/llvm-lib/implibs.test b/llvm/test/tools/llvm-lib/implibs.test --- a/llvm/test/tools/llvm-lib/implibs.test +++ b/llvm/test/tools/llvm-lib/implibs.test @@ -13,7 +13,12 @@ Test that import libraries can be created from a def file -RUN: echo -e "NAME lib.dll\nEXPORTS\nMyFunc" > %t/implib.def +RUN: echo -e "NAME lib.dll\nEXPORTS\nMyFunc\nAnotherFunc" > %t/implib.def RUN: llvm-lib -out:%t/implib.lib -def:%t/implib.def -machine:x64 RUN: llvm-ar t %t/implib.lib | FileCheck %s + +RUN: llvm-nm --print-armap %t/implib.lib | FileCheck --check-prefix=SYMTAB %s +SYMTAB: Archive map +SYMTAB-NEXT: AnotherFunc in lib.dll +SYMTAB-NEXT: MyFunc in lib.dll