13#ifndef LLVM_EXECUTIONENGINE_ORC_ELFNIXPLATFORM_H
14#define LLVM_EXECUTIONENGINE_ORC_ELFNIXPLATFORM_H
49 std::vector<ELFNixJITDylibInitializers>;
52 std::vector<ELFNixJITDylibDeinitializers>;
97 JITDylib &PlatformJD, std::unique_ptr<DefinitionGenerator> OrcRuntime,
98 std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
103 JITDylib &PlatformJD,
const char *OrcRuntimePath,
104 std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
136 void modifyPassConfig(MaterializationResponsibility &MR,
141 getSyntheticSymbolDependencies(MaterializationResponsibility &MR)
override;
145 Error notifyFailed(MaterializationResponsibility &MR)
override {
149 Error notifyRemovingResources(JITDylib &JD,
ResourceKey K)
override {
153 void notifyTransferringResources(JITDylib &JD,
ResourceKey DstKey,
157 using InitSymbolDepMap =
158 DenseMap<MaterializationResponsibility *, JITLinkSymbolSet>;
160 void addInitializerSupportPasses(MaterializationResponsibility &MR,
161 jitlink::PassConfiguration &
Config);
163 void addDSOHandleSupportPasses(MaterializationResponsibility &MR,
164 jitlink::PassConfiguration &
Config);
166 void addEHAndTLVSupportPasses(MaterializationResponsibility &MR,
167 jitlink::PassConfiguration &
Config);
169 Error preserveInitSections(jitlink::LinkGraph &
G,
170 MaterializationResponsibility &MR);
172 Error registerInitSections(jitlink::LinkGraph &
G, JITDylib &JD);
174 Error fixTLVSectionsAndEdges(jitlink::LinkGraph &
G, JITDylib &JD);
176 std::mutex PluginMutex;
178 InitSymbolDepMap InitSymbolDeps;
181 using SendInitializerSequenceFn =
182 unique_function<void(Expected<ELFNixJITDylibInitializerSequence>)>;
184 using SendDeinitializerSequenceFn =
185 unique_function<void(Expected<ELFNixJITDylibDeinitializerSequence>)>;
187 using SendSymbolAddressFn = unique_function<void(Expected<ExecutorAddr>)>;
189 static bool supportedTarget(
const Triple &TT);
191 ELFNixPlatform(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
192 JITDylib &PlatformJD,
193 std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator,
197 Error associateRuntimeSupportFunctions(JITDylib &PlatformJD);
199 void getInitializersBuildSequencePhase(SendInitializerSequenceFn SendResult,
201 std::vector<JITDylibSP> DFSLinkOrder);
203 void getInitializersLookupPhase(SendInitializerSequenceFn SendResult,
206 void rt_getInitializers(SendInitializerSequenceFn SendResult,
209 void rt_getDeinitializers(SendDeinitializerSequenceFn SendResult,
210 ExecutorAddr Handle);
212 void rt_lookupSymbol(SendSymbolAddressFn SendResult, ExecutorAddr Handle,
213 StringRef SymbolName);
216 Error bootstrapELFNixRuntime(JITDylib &PlatformJD);
218 Error registerInitInfo(JITDylib &JD,
219 ArrayRef<jitlink::Section *> InitSections);
221 Error registerPerObjectSections(
const ELFPerObjectSectionsToRegister &POSR);
223 Expected<uint64_t> createPThreadKey();
225 ExecutionSession &ES;
226 ObjectLinkingLayer &ObjLinkingLayer;
228 SymbolStringPtr DSOHandleSymbol;
229 std::atomic<bool> RuntimeBootstrapped{
false};
231 ExecutorAddr orc_rt_elfnix_platform_bootstrap;
232 ExecutorAddr orc_rt_elfnix_platform_shutdown;
233 ExecutorAddr orc_rt_elfnix_register_object_sections;
234 ExecutorAddr orc_rt_elfnix_create_pthread_key;
236 DenseMap<JITDylib *, SymbolLookupSet> RegisteredInitSymbols;
240 std::mutex PlatformMutex;
241 DenseMap<JITDylib *, ELFNixJITDylibInitializers> InitSeqs;
242 std::vector<ELFPerObjectSectionsToRegister> BootstrapPOSRs;
244 DenseMap<ExecutorAddr, JITDylib *> HandleAddrToJITDylib;
245 DenseMap<JITDylib *, uint64_t> JITDylibToPThreadKey;
259 return SPSELFPerObjectSectionsToRegister::AsArgList::size(
265 return SPSELFPerObjectSectionsToRegister::AsArgList::serialize(
271 return SPSELFPerObjectSectionsToRegister::AsArgList::deserialize(
291 return SPSELFNixJITDylibInitializers::AsArgList::size(
297 return SPSELFNixJITDylibInitializers::AsArgList::serialize(
303 return SPSELFNixJITDylibInitializers::AsArgList::deserialize(
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
An ExecutionSession represents a running JIT program.
Represents an address in the executor process.
Represents a JIT'd dynamic library.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
Plugin instances can be added to the ObjectLinkingLayer to receive callbacks when code is loaded or e...
DenseMap< SymbolStringPtr, JITLinkSymbolSet > SyntheticSymbolDependenciesMap
An ObjectLayer implementation built on JITLink.
API to remove / transfer ownership of JIT resources.
Output char buffer with overflow check.
SPS tag type for sequences.
static size_t size(const ELFNixJITDylibDeinitializers &MOJDDs)
static bool serialize(SPSOutputBuffer &OB, const ELFNixJITDylibDeinitializers &MOJDDs)
static bool deserialize(SPSInputBuffer &IB, ELFNixJITDylibDeinitializers &MOJDDs)
static bool deserialize(SPSInputBuffer &IB, ELFNixJITDylibInitializers &MOJDIs)
static size_t size(const ELFNixJITDylibInitializers &MOJDIs)
static bool serialize(SPSOutputBuffer &OB, const ELFNixJITDylibInitializers &MOJDIs)
static bool serialize(SPSOutputBuffer &OB, const ELFPerObjectSectionsToRegister &MOPOSR)
static size_t size(const ELFPerObjectSectionsToRegister &MOPOSR)
static bool deserialize(SPSInputBuffer &IB, ELFPerObjectSectionsToRegister &MOPOSR)
Specialize to describe how to serialize/deserialize to/from the given concrete type.
std::vector< ELFNixJITDylibDeinitializers > ELFNixJITDylibDeinitializerSequence
std::vector< ELFNixJITDylibInitializers > ELFNixJITDylibInitializerSequence
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...
ExecutorAddr DSOHandleAddress
StringMap< SectionList > InitSections
ELFNixJITDylibInitializers(std::string Name, ExecutorAddr DSOHandleAddress)
std::vector< ExecutorAddrRange > SectionList
ExecutorAddrRange EHFrameSection
ExecutorAddrRange ThreadDataSection
Represents an address range in the exceutor process.