[PATCH] D36065: [llvm-dlltool] Write correct weak externals

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 04:19:43 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL309555: [llvm-dlltool] Write correct weak externals (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D36065?vs=108882&id=108897#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36065

Files:
  llvm/trunk/lib/Object/COFFImportFile.cpp
  llvm/trunk/test/DllTool/coff-weak-exports.def


Index: llvm/trunk/lib/Object/COFFImportFile.cpp
===================================================================
--- llvm/trunk/lib/Object/COFFImportFile.cpp
+++ llvm/trunk/lib/Object/COFFImportFile.cpp
@@ -545,15 +545,12 @@
   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());
Index: llvm/trunk/test/DllTool/coff-weak-exports.def
===================================================================
--- llvm/trunk/test/DllTool/coff-weak-exports.def
+++ llvm/trunk/test/DllTool/coff-weak-exports.def
@@ -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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36065.108897.patch
Type: text/x-patch
Size: 1980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170731/cafad5ff/attachment.bin>


More information about the llvm-commits mailing list