[PATCH] D59742: [llvm-dlltool] Set a proper machine type for weak symbol object files

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 23 13:45:42 PDT 2019


mstorsjo created this revision.
mstorsjo added reviewers: rnk, ruiu, pcc.
Herald added subscribers: dexonsmith, steven_wu, inglorion, mehdi_amini.
Herald added a project: LLVM.

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 hasn't had issues with the bogus machine field though.


Repository:
  rL LLVM

https://reviews.llvm.org/D59742

Files:
  lib/Object/COFFImportFile.cpp
  test/tools/llvm-dlltool/coff-weak-exports.def


Index: test/tools/llvm-dlltool/coff-weak-exports.def
===================================================================
--- test/tools/llvm-dlltool/coff-weak-exports.def
+++ 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 @@
 ; CHECK-NEXT: W __imp_ImpLibName2
 ; CHECK:      T ImpLibName3
 ; CHECK-NEXT: T __imp_ImpLibName3
+
+; ARCH-NOT: unknown arch
Index: lib/Object/COFFImportFile.cpp
===================================================================
--- lib/Object/COFFImportFile.cpp
+++ lib/Object/COFFImportFile.cpp
@@ -496,7 +496,7 @@
 
   // COFF Header
   coff_file_header Header{
-      u16(0),
+      u16(Machine),
       u16(NumberOfSections),
       u32(0),
       u32(sizeof(Header) + (NumberOfSections * sizeof(coff_section))),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59742.192015.patch
Type: text/x-patch
Size: 970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190323/b64125f1/attachment.bin>


More information about the llvm-commits mailing list