mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[ORC] Honor linker private global prefix on symbol names.
If a symbol name begins with the linker private global prefix (as described by the DataLayout) then it should be treated as non-exported, regardless of its LLVM IR visibility value.
This commit is contained in:
parent
f19eede4be
commit
710863f2b4
@ -20,6 +20,8 @@
|
||||
using namespace llvm;
|
||||
|
||||
JITSymbolFlags llvm::JITSymbolFlags::fromGlobalValue(const GlobalValue &GV) {
|
||||
assert(GV.hasName() && "Can't get flags for anonymous symbol");
|
||||
|
||||
JITSymbolFlags Flags = JITSymbolFlags::None;
|
||||
if (GV.hasWeakLinkage() || GV.hasLinkOnceLinkage())
|
||||
Flags |= JITSymbolFlags::Weak;
|
||||
@ -34,6 +36,16 @@ JITSymbolFlags llvm::JITSymbolFlags::fromGlobalValue(const GlobalValue &GV) {
|
||||
isa<Function>(cast<GlobalAlias>(GV).getAliasee()))
|
||||
Flags |= JITSymbolFlags::Callable;
|
||||
|
||||
// Check for a linker-private-global-prefix on the symbol name, in which
|
||||
// case it must be marked as non-exported.
|
||||
if (auto *M = GV.getParent()) {
|
||||
const auto &DL = M->getDataLayout();
|
||||
StringRef LPGP = DL.getLinkerPrivateGlobalPrefix();
|
||||
if (!LPGP.empty() && GV.getName().front() == '\01' &&
|
||||
GV.getName().substr(1).startswith(LPGP))
|
||||
Flags &= ~JITSymbolFlags::Exported;
|
||||
}
|
||||
|
||||
return Flags;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,18 @@
|
||||
; RUN: lli -jit-kind=orc-lazy %s
|
||||
|
||||
define private void @_ZL3foov() {
|
||||
define private void @foo() {
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"\01l_bar"() {
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
define i32 @main(i32 %argc, i8** nocapture readnone %argv) {
|
||||
entry:
|
||||
tail call void @_ZL3foov()
|
||||
call void @foo()
|
||||
call void @"\01l_bar"()
|
||||
ret i32 0
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user