13#ifndef LLVM_EXECUTIONENGINE_ORC_COFFPLATFORM_H
14#define LLVM_EXECUTIONENGINE_ORC_COFFPLATFORM_H
44 JITDylib &PlatformJD,
const char *OrcRuntimePath,
46 const char *VCRuntimePath =
nullptr,
47 std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
71 return Name.startswith(
".CRT");
77 using COFFJITDylibDepInfo = std::vector<ExecutorAddr>;
78 using COFFJITDylibDepInfoMap =
79 std::vector<std::pair<ExecutorAddr, COFFJITDylibDepInfo>>;
80 using COFFObjectSectionsMap =
82 using PushInitializersSendResultFn =
94 void modifyPassConfig(MaterializationResponsibility &MR,
99 getSyntheticSymbolDependencies(MaterializationResponsibility &MR)
override;
103 Error notifyFailed(MaterializationResponsibility &MR)
override {
107 Error notifyRemovingResources(JITDylib &JD,
ResourceKey K)
override {
111 void notifyTransferringResources(JITDylib &JD,
ResourceKey DstKey,
115 using InitSymbolDepMap =
116 DenseMap<MaterializationResponsibility *, JITLinkSymbolSet>;
118 Error associateJITDylibHeaderSymbol(jitlink::LinkGraph &
G,
119 MaterializationResponsibility &MR,
122 Error preserveInitializerSections(jitlink::LinkGraph &
G,
123 MaterializationResponsibility &MR);
124 Error registerObjectPlatformSections(jitlink::LinkGraph &
G, JITDylib &JD);
125 Error registerObjectPlatformSectionsInBootstrap(jitlink::LinkGraph &
G,
128 std::mutex PluginMutex;
130 InitSymbolDepMap InitSymbolDeps;
133 struct JDBootstrapState {
134 JITDylib *JD =
nullptr;
136 ExecutorAddr HeaderAddr;
137 std::list<COFFObjectSectionsMap> ObjectSectionsMaps;
138 SmallVector<std::pair<std::string, ExecutorAddr>> Initializers;
141 static bool supportedTarget(
const Triple &TT);
143 COFFPlatform(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
144 JITDylib &PlatformJD,
const char *OrcRuntimePath,
146 const char *VCRuntimePath, Error &Err);
149 Error associateRuntimeSupportFunctions(JITDylib &PlatformJD);
152 Error bootstrapCOFFRuntime(JITDylib &PlatformJD);
155 Error runSymbolIfExists(JITDylib &PlatformJD, StringRef SymbolName);
158 Error runBootstrapInitializers(JDBootstrapState &BState);
159 Error runBootstrapSubsectionInitializers(JDBootstrapState &BState,
160 StringRef Start, StringRef End);
163 Expected<JITDylibDepMap> buildJDDepMap(JITDylib &JD);
165 Expected<MemoryBufferRef> getPerJDObjectFile();
170 void pushInitializersLoop(PushInitializersSendResultFn SendResult,
173 void rt_pushInitializers(PushInitializersSendResultFn SendResult,
174 ExecutorAddr JDHeaderAddr);
176 void rt_lookupSymbol(SendSymbolAddressFn SendResult, ExecutorAddr Handle,
177 StringRef SymbolName);
179 ExecutionSession &ES;
180 ObjectLinkingLayer &ObjLinkingLayer;
183 std::unique_ptr<COFFVCRuntimeBootstrapper> VCRuntimeBootstrap;
184 std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer;
185 std::unique_ptr<object::Archive> OrcRuntimeArchive;
186 bool StaticVCRuntime;
188 SymbolStringPtr COFFHeaderStartSymbol;
191 std::map<JITDylib *, JDBootstrapState> JDBootstrapStates;
192 std::atomic<bool> Bootstrapping;
194 ExecutorAddr orc_rt_coff_platform_bootstrap;
195 ExecutorAddr orc_rt_coff_platform_shutdown;
196 ExecutorAddr orc_rt_coff_register_object_sections;
197 ExecutorAddr orc_rt_coff_deregister_object_sections;
198 ExecutorAddr orc_rt_coff_register_jitdylib;
199 ExecutorAddr orc_rt_coff_deregister_jitdylib;
201 DenseMap<JITDylib *, ExecutorAddr> JITDylibToHeaderAddr;
202 DenseMap<ExecutorAddr, JITDylib *> HeaderAddrToJITDylib;
204 DenseMap<JITDylib *, SymbolLookupSet> RegisteredInitSymbols;
206 std::set<std::string> DylibsToPreload;
208 std::mutex PlatformMutex;
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.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
An ExecutionSession represents a running JIT program.
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.
IntrusiveRefCntPtr< JITDylib > JITDylibSP
This is an optimization pass for GlobalISel generic memory operations.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...