[PATCH] D36633: [COFF] Make the weak aliases optional

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 13:00:59 PDT 2017


mstorsjo created this revision.
Herald added a subscriber: mehdi_amini.

When creating an import library from lld, the cases with Name != ExtName shouldn't end up as a weak alias, but as a real export of the new name, which is what actually is exported from the DLL.

This restores the behaviour of renamed exports to what it was in 4.0 - this is a regression since the introduction of llvm-dlltool.

The other half of this commit, including a test, goes into lld.


https://reviews.llvm.org/D36633

Files:
  include/llvm/Object/COFFImportFile.h
  lib/Object/COFFImportFile.cpp
  lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp


Index: lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
===================================================================
--- lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
+++ lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
@@ -171,7 +171,7 @@
     }
   }
 
-  if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine))
+  if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine, true))
     return 1;
   return 0;
 }
Index: lib/Object/COFFImportFile.cpp
===================================================================
--- lib/Object/COFFImportFile.cpp
+++ lib/Object/COFFImportFile.cpp
@@ -560,7 +560,7 @@
 
 std::error_code writeImportLibrary(StringRef ImportName, StringRef Path,
                                    ArrayRef<COFFShortExport> Exports,
-                                   MachineTypes Machine) {
+                                   MachineTypes Machine, bool MakeWeakAliases) {
 
   std::vector<NewArchiveMember> Members;
   ObjectFactory OF(llvm::sys::path::filename(ImportName), Machine);
@@ -578,7 +578,7 @@
     if (E.Private)
       continue;
 
-    if (E.isWeak()) {
+    if (E.isWeak() && MakeWeakAliases) {
       Members.push_back(OF.createWeakExternal(E.Name, E.ExtName, false));
       Members.push_back(OF.createWeakExternal(E.Name, E.ExtName, true));
       continue;
Index: include/llvm/Object/COFFImportFile.h
===================================================================
--- include/llvm/Object/COFFImportFile.h
+++ include/llvm/Object/COFFImportFile.h
@@ -99,7 +99,8 @@
 std::error_code writeImportLibrary(StringRef ImportName,
                                    StringRef Path,
                                    ArrayRef<COFFShortExport> Exports,
-                                   COFF::MachineTypes Machine);
+                                   COFF::MachineTypes Machine,
+                                   bool MakeWeakAliases);
 
 } // namespace object
 } // namespace llvm


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36633.110791.patch
Type: text/x-patch
Size: 1953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170811/b69de440/attachment.bin>


More information about the llvm-commits mailing list