diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-06-11 21:42:18 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-06-11 21:42:18 +0000 |
commit | 82e657b509b33611620076ab8065cb485b54c348 (patch) | |
tree | 989fe170397732716a20469e7b64b2036027f1c0 /llvm/lib/Object/IRObjectFile.cpp | |
parent | 485ad4860e7b26200a25c7fc593828d91b0520cf (diff) | |
download | bcm5719-llvm-82e657b509b33611620076ab8065cb485b54c348.tar.gz bcm5719-llvm-82e657b509b33611620076ab8065cb485b54c348.zip |
Object: Prepend __imp_ when mangling a dllimport symbol in IRObjectFile.
We cannot prepend __imp_ in the IR mangler because a function reference may
be emitted unmangled in a constant initializer. The linker is expected to
resolve such references to thunks. This is covered by the new test case.
Strictly speaking we ought to emit two undefined symbols, one with __imp_ and
one without, as we cannot know which symbol the final object file will refer
to. However, this would require rather intrusive changes to IRObjectFile,
and lld works fine without it for now.
This reimplements r239437, which was reverted in r239502.
Differential Revision: http://reviews.llvm.org/D10400
llvm-svn: 239560
Diffstat (limited to 'llvm/lib/Object/IRObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/IRObjectFile.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Object/IRObjectFile.cpp b/llvm/lib/Object/IRObjectFile.cpp index e89cb8ead36..b3d5db85ed5 100644 --- a/llvm/lib/Object/IRObjectFile.cpp +++ b/llvm/lib/Object/IRObjectFile.cpp @@ -198,6 +198,9 @@ std::error_code IRObjectFile::printSymbolName(raw_ostream &OS, return std::error_code(); } + if (GV->hasDLLImportStorageClass()) + OS << "__imp_"; + if (Mang) Mang->getNameWithPrefix(OS, GV, false); else |