aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/COFFImportFile.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2017-07-31 11:18:41 +0000
committerMartin Storsjo <martin@martin.st>2017-07-31 11:18:41 +0000
commit4a5764e3caf49e1b290a0a0e7b588e2109f4f292 (patch)
tree2a636d20db93fbbde5b7fe2f42ef6bb9d27bd7fe /llvm/lib/Object/COFFImportFile.cpp
parent15cf379519ae473c4446ac8efb7f7bb995c5a5f3 (diff)
downloadllvm-4a5764e3caf49e1b290a0a0e7b588e2109f4f292.zip
llvm-4a5764e3caf49e1b290a0a0e7b588e2109f4f292.tar.gz
llvm-4a5764e3caf49e1b290a0a0e7b588e2109f4f292.tar.bz2
[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 llvm-svn: 309555
Diffstat (limited to 'llvm/lib/Object/COFFImportFile.cpp')
-rw-r--r--llvm/lib/Object/COFFImportFile.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/Object/COFFImportFile.cpp b/llvm/lib/Object/COFFImportFile.cpp
index 77cb625..670c4bb 100644
--- a/llvm/lib/Object/COFFImportFile.cpp
+++ b/llvm/lib/Object/COFFImportFile.cpp
@@ -545,15 +545,12 @@ NewArchiveMember ObjectFactory::createWeakExternal(StringRef Sym,
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());