summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/Orc
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-08-31 00:53:17 +0000
committerLang Hames <lhames@gmail.com>2018-08-31 00:53:17 +0000
commit6d32002e2bb0897836618f9ddb0b320a83583316 (patch)
treea1a265bd7ff46d1bf0ea7412b4ba46d1ddb48345 /llvm/lib/ExecutionEngine/Orc
parentf1126325e8f6b26514ea2bc75b7db81cc2e5cccf (diff)
downloadbcm5719-llvm-6d32002e2bb0897836618f9ddb0b320a83583316.tar.gz
bcm5719-llvm-6d32002e2bb0897836618f9ddb0b320a83583316.zip
[ORC] Add utilities to RTDyldObjectLinkingLayer2 to simplify symbol flag
management and materialization responsibility registration. The setOverrideObjectFlagsWithResponsibilityFlags method instructs RTDyldObjectlinkingLayer2 to override the symbol flags produced by RuntimeDyld with the flags provided by the MaterializationResponsibility instance. This can be used to enable symbol visibility (hidden/exported) for COFF object files, which do not currently support the SF_Exported flag. The setAutoClaimResponsibilityForObjectSymbols method instructs RTDyldObjectLinkingLayer2 to claim responsibility for any symbols provided by a given object file that were not already in the MaterializationResponsibility instance. Setting this flag allows higher-level program representations (e.g. LLVM IR) to be added based on only a subset of the symbols they provide, without having to write intervening layers to scan and add the additional symbols. This trades diagnostic quality for convenience however: If all symbols are enumerated up-front then clashes can be detected and reported early. If this option is set, clashes for the additional symbols may not be detected until late, and detection may depend on the flow of control through JIT'd code. llvm-svn: 341154
Diffstat (limited to 'llvm/lib/ExecutionEngine/Orc')
-rw-r--r--llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
index f82f5ecfed5..db3934d7597 100644
--- a/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
@@ -69,7 +69,7 @@ RTDyldObjectLinkingLayer2::RTDyldObjectLinkingLayer2(
NotifyLoadedFunction NotifyLoaded, NotifyEmittedFunction NotifyEmitted)
: ObjectLayer(ES), GetMemoryManager(GetMemoryManager),
NotifyLoaded(std::move(NotifyLoaded)),
- NotifyEmitted(std::move(NotifyEmitted)), ProcessAllSections(false) {}
+ NotifyEmitted(std::move(NotifyEmitted)) {}
void RTDyldObjectLinkingLayer2::emit(MaterializationResponsibility R,
VModuleKey K,
@@ -118,10 +118,38 @@ void RTDyldObjectLinkingLayer2::emit(MaterializationResponsibility R,
}
}
+ SymbolFlagsMap ExtraSymbolsToClaim;
SymbolMap Symbols;
- for (auto &KV : RTDyld->getSymbolTable())
- if (!InternalSymbols.count(KV.first))
- Symbols[ES.getSymbolStringPool().intern(KV.first)] = KV.second;
+ for (auto &KV : RTDyld->getSymbolTable()) {
+ // Scan the symbols and add them to the Symbols map for resolution.
+
+ // We never claim internal symbols.
+ if (InternalSymbols.count(KV.first))
+ continue;
+
+ auto InternedName = ES.getSymbolStringPool().intern(KV.first);
+ auto Flags = KV.second.getFlags();
+
+ // Override object flags and claim responsibility for symbols if
+ // requested.
+ if (OverrideObjectFlags || AutoClaimObjectSymbols) {
+ auto I = R.getSymbols().find(InternedName);
+
+ if (OverrideObjectFlags && I != R.getSymbols().end())
+ Flags = JITSymbolFlags::stripTransientFlags(I->second);
+ else if (AutoClaimObjectSymbols && I == R.getSymbols().end())
+ ExtraSymbolsToClaim[InternedName] = Flags;
+ }
+
+ Symbols[InternedName] = JITEvaluatedSymbol(KV.second.getAddress(), Flags);
+ }
+
+ if (!ExtraSymbolsToClaim.empty())
+ if (auto Err = R.defineMaterializing(ExtraSymbolsToClaim)) {
+ ES.reportError(std::move(Err));
+ R.failMaterialization();
+ return;
+ }
R.resolve(Symbols);
}
OpenPOWER on IntegriCloud