[llvm-branch-commits] [llvm-branch] r309837 - Merging r309555:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Aug 2 10:31:02 PDT 2017


Author: hans
Date: Wed Aug  2 10:31:02 2017
New Revision: 309837

URL: http://llvm.org/viewvc/llvm-project?rev=309837&view=rev
Log:
Merging r309555:
------------------------------------------------------------------------
r309555 | mstorsjo | 2017-07-31 04:18:41 -0700 (Mon, 31 Jul 2017) | 10 lines

[llvm-dlltool] Write correct weak externals

Previously, the created object files for the import library were broken.
Write the symbol table before the string table. Simplify the code by
using a separate variable Prefix instead of duplicating a few lines.

Also update the coff-weak-exports to actually check that the generated
weak symbols can be found as intended.

Differential Revision: https://reviews.llvm.org/D36065
------------------------------------------------------------------------

Modified:
    llvm/branches/release_50/   (props changed)
    llvm/branches/release_50/lib/Object/COFFImportFile.cpp
    llvm/branches/release_50/test/DllTool/coff-weak-exports.def

Propchange: llvm/branches/release_50/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug  2 10:31:02 2017
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,308483-308484,308503,308808,308813,308891,308906,308950,308963,308978,308986,309113,309302,309321,309323,309325,309330,309343,309353,309355,309422,309481,309483,309495,309561,309594
+/llvm/trunk:155241,308483-308484,308503,308808,308813,308891,308906,308950,308963,308978,308986,309113,309302,309321,309323,309325,309330,309343,309353,309355,309422,309481,309483,309495,309555,309561,309594

Modified: llvm/branches/release_50/lib/Object/COFFImportFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/lib/Object/COFFImportFile.cpp?rev=309837&r1=309836&r2=309837&view=diff
==============================================================================
--- llvm/branches/release_50/lib/Object/COFFImportFile.cpp (original)
+++ llvm/branches/release_50/lib/Object/COFFImportFile.cpp Wed Aug  2 10:31:02 2017
@@ -542,15 +542,12 @@ NewArchiveMember ObjectFactory::createWe
   SymbolTable[2].Name.Offset.Offset = sizeof(uint32_t);
 
   //__imp_ String Table
-  if (Imp) {
-    SymbolTable[3].Name.Offset.Offset = sizeof(uint32_t) + Sym.size() + 7;
-    writeStringTable(Buffer, {std::string("__imp_").append(Sym),
-                              std::string("__imp_").append(Weak)});
-  } else {
-    SymbolTable[3].Name.Offset.Offset = sizeof(uint32_t) + Sym.size() + 1;
-    writeStringTable(Buffer, {Sym, Weak});
-  }
+  StringRef Prefix = Imp ? "__imp_" : "";
+  SymbolTable[3].Name.Offset.Offset =
+      sizeof(uint32_t) + Sym.size() + Prefix.size() + 1;
   append(Buffer, SymbolTable);
+  writeStringTable(Buffer, {(Prefix + Sym).str(),
+                            (Prefix + Weak).str()});
 
   // Copied here so we can still use writeStringTable
   char *Buf = Alloc.Allocate<char>(Buffer.size());

Modified: llvm/branches/release_50/test/DllTool/coff-weak-exports.def
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/test/DllTool/coff-weak-exports.def?rev=309837&r1=309836&r2=309837&view=diff
==============================================================================
--- llvm/branches/release_50/test/DllTool/coff-weak-exports.def (original)
+++ llvm/branches/release_50/test/DllTool/coff-weak-exports.def Wed Aug  2 10:31:02 2017
@@ -1,19 +1,11 @@
 ; RUN: llvm-dlltool -m i386:x86-64 --input-def %s --output-lib %t.a
-; RUN: llvm-readobj -coff-exports %t.a | FileCheck %s
+; RUN: llvm-nm %t.a | FileCheck %s
 
 LIBRARY test.dll
 EXPORTS
 TestFunction==AltTestFunction
 
-; CHECK: File: test.dll
-; CHECK: Format: COFF-x86-64
-; CHECK: Arch: x86_64
-; CHECK: AddressSize: 64bit
-; CHECK: File: test.dll
-; CHECK: Format: COFF-x86-64
-; CHECK: Arch: x86_64
-; CHECK: AddressSize: 64bit
-; CHECK: File: test.dll
-; CHECK: Format: COFF-x86-64
-; CHECK: Arch: x86_64
-; CHECK: AddressSize: 64bit
+; CHECK:      U AltTestFunction
+; CHECK-NEXT: w TestFunction
+; CHECK:      U __imp_AltTestFunction
+; CHECK-NEXT: w __imp_TestFunction




More information about the llvm-branch-commits mailing list