diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-08-02 17:31:02 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-08-02 17:31:02 +0000 |
commit | ef9cccfdac036df338778d1a949ad5c9ca10d335 (patch) | |
tree | 469a9dfb691f7992fef135ecc03ef60a6a4a9a7f /lib/Object | |
parent | f02b39ca4c14050d0fb9f5427c8be8b106a5de79 (diff) |
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
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@309837 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object')
-rw-r--r-- | lib/Object/COFFImportFile.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/Object/COFFImportFile.cpp b/lib/Object/COFFImportFile.cpp index d1f46fdfa292..a515bc8ad16d 100644 --- a/lib/Object/COFFImportFile.cpp +++ b/lib/Object/COFFImportFile.cpp @@ -542,15 +542,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()); |