]> granicus.if.org Git - llvm/commitdiff
[COFF] Make the weak aliases optional
authorMartin Storsjo <martin@martin.st>
Wed, 16 Aug 2017 05:22:49 +0000 (05:22 +0000)
committerMartin Storsjo <martin@martin.st>
Wed, 16 Aug 2017 05:22:49 +0000 (05:22 +0000)
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.

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

Differential Revision: https://reviews.llvm.org/D36633

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310991 91177308-0d34-0410-b5e6-96231b3b80d8

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

index f6db943c2de860fdb6b42c56a43c298ad55added..cf9c80a06f49a9ad35a42188f983bc820542c806 100644 (file)
@@ -99,7 +99,8 @@ struct COFFShortExport {
 std::error_code writeImportLibrary(StringRef ImportName,
                                    StringRef Path,
                                    ArrayRef<COFFShortExport> Exports,
-                                   COFF::MachineTypes Machine);
+                                   COFF::MachineTypes Machine,
+                                   bool MakeWeakAliases);
 
 } // namespace object
 } // namespace llvm
index 8d0f82e2b92f8cdbe3de7964e406362849e7b094..8383edf45af16335df8cbf1f1213a3efc6a3a212 100644 (file)
@@ -560,7 +560,7 @@ NewArchiveMember ObjectFactory::createWeakExternal(StringRef Sym,
 
 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 @@ std::error_code writeImportLibrary(StringRef ImportName, StringRef Path,
     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 c0b09ca106fdd444cb110a1448565fe063ab9d8d..40fc48f9803ef58425f8afd6003de50e0a61ca50 100644 (file)
@@ -171,7 +171,7 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef<const char *> ArgsArr) {
     }
   }
 
-  if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine))
+  if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine, true))
     return 1;
   return 0;
 }