]> granicus.if.org Git - llvm/commitdiff
Merging r310991:
authorHans Wennborg <hans@hanshq.net>
Thu, 17 Aug 2017 17:04:53 +0000 (17:04 +0000)
committerHans Wennborg <hans@hanshq.net>
Thu, 17 Aug 2017 17:04:53 +0000 (17:04 +0000)
------------------------------------------------------------------------
r310991 | mstorsjo | 2017-08-15 22:22:49 -0700 (Tue, 15 Aug 2017) | 13 lines

[COFF] Make the weak aliases optional

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/branches/release_50@311100 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 83a11cb6db059ef1ed16cd737224e67c7286a3c6..ff039463d08c8744c7bc022e13ee35fce09772f9 100644 (file)
@@ -557,7 +557,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);
@@ -575,7 +575,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 a7de7930607469617b975f5781358e8f8faf7111..a56fb9ee2c9ecf259a166c1a202a0fa43fc8d463 100644 (file)
@@ -154,7 +154,7 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef<const char *> ArgsArr) {
   if (Path.empty())
     Path = getImplibPath(Def->OutputFile);
 
-  if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine))
+  if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine, true))
     return 1;
   return 0;
 }