From: Martin Storsjo Date: Tue, 26 Mar 2019 09:02:44 +0000 (+0000) Subject: [llvm-dlltool] Set a proper machine type for weak symbol object files X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b28ef618dab3056eb1ce524dd504f9031ab88dc;p=llvm [llvm-dlltool] Set a proper machine type for weak symbol object files This makes GNU binutils not reject the libraries outright. GNU ld handles weak externals slightly differently though, so it can't use them for aliases in import libraries, but this makes GNU ld able to use the rest of the import libraries. LLD accepted object files with machine type 0 aka IMAGE_FILE_MACHINE_UNKNOWN. Differential Revision: https://reviews.llvm.org/D59742 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356982 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Object/COFFImportFile.cpp b/lib/Object/COFFImportFile.cpp index e8d2edd2d2b..f821b51a9e1 100644 --- a/lib/Object/COFFImportFile.cpp +++ b/lib/Object/COFFImportFile.cpp @@ -495,7 +495,7 @@ NewArchiveMember ObjectFactory::createWeakExternal(StringRef Sym, // COFF Header coff_file_header Header{ - u16(0), + u16(Machine), u16(NumberOfSections), u32(0), u32(sizeof(Header) + (NumberOfSections * sizeof(coff_section))), diff --git a/test/tools/llvm-dlltool/coff-weak-exports.def b/test/tools/llvm-dlltool/coff-weak-exports.def index dbc59be8ae1..60f835233a5 100644 --- a/test/tools/llvm-dlltool/coff-weak-exports.def +++ b/test/tools/llvm-dlltool/coff-weak-exports.def @@ -1,5 +1,6 @@ ; RUN: llvm-dlltool -m i386:x86-64 --input-def %s --output-lib %t.a ; RUN: llvm-nm %t.a | FileCheck %s +; RUN: llvm-readobj %t.a | FileCheck -check-prefix=ARCH %s LIBRARY test.dll EXPORTS @@ -26,3 +27,5 @@ ImpLibName3 = kernel32.Sleep ; CHECK-NEXT: W __imp_ImpLibName2 ; CHECK: T ImpLibName3 ; CHECK-NEXT: T __imp_ImpLibName3 + +; ARCH-NOT: unknown arch