Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit ef9cccf

Browse files
committed
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
1 parent f02b39c commit ef9cccf

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

lib/Object/COFFImportFile.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -542,15 +542,12 @@ NewArchiveMember ObjectFactory::createWeakExternal(StringRef Sym,
542542
SymbolTable[2].Name.Offset.Offset = sizeof(uint32_t);
543543

544544
//__imp_ String Table
545-
if (Imp) {
546-
SymbolTable[3].Name.Offset.Offset = sizeof(uint32_t) + Sym.size() + 7;
547-
writeStringTable(Buffer, {std::string("__imp_").append(Sym),
548-
std::string("__imp_").append(Weak)});
549-
} else {
550-
SymbolTable[3].Name.Offset.Offset = sizeof(uint32_t) + Sym.size() + 1;
551-
writeStringTable(Buffer, {Sym, Weak});
552-
}
545+
StringRef Prefix = Imp ? "__imp_" : "";
546+
SymbolTable[3].Name.Offset.Offset =
547+
sizeof(uint32_t) + Sym.size() + Prefix.size() + 1;
553548
append(Buffer, SymbolTable);
549+
writeStringTable(Buffer, {(Prefix + Sym).str(),
550+
(Prefix + Weak).str()});
554551

555552
// Copied here so we can still use writeStringTable
556553
char *Buf = Alloc.Allocate<char>(Buffer.size());

test/DllTool/coff-weak-exports.def

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
; RUN: llvm-dlltool -m i386:x86-64 --input-def %s --output-lib %t.a
2-
; RUN: llvm-readobj -coff-exports %t.a | FileCheck %s
2+
; RUN: llvm-nm %t.a | FileCheck %s
33

44
LIBRARY test.dll
55
EXPORTS
66
TestFunction==AltTestFunction
77

8-
; CHECK: File: test.dll
9-
; CHECK: Format: COFF-x86-64
10-
; CHECK: Arch: x86_64
11-
; CHECK: AddressSize: 64bit
12-
; CHECK: File: test.dll
13-
; CHECK: Format: COFF-x86-64
14-
; CHECK: Arch: x86_64
15-
; CHECK: AddressSize: 64bit
16-
; CHECK: File: test.dll
17-
; CHECK: Format: COFF-x86-64
18-
; CHECK: Arch: x86_64
19-
; CHECK: AddressSize: 64bit
8+
; CHECK: U AltTestFunction
9+
; CHECK-NEXT: w TestFunction
10+
; CHECK: U __imp_AltTestFunction
11+
; CHECK-NEXT: w __imp_TestFunction

0 commit comments

Comments
 (0)