21#define DEBUG_TYPE "orc"
55 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override {
58 const auto &
TT =
CP.getExecutionSession().getTargetTriple();
60 switch (
TT.getArch()) {
69 auto G = std::make_unique<jitlink::LinkGraph>(
70 "<COFFHeaderMU>", TT, PointerSize, Endianness,
72 auto &HeaderSection =
G->createSection(
"__header", MemProt::Read);
73 auto &HeaderBlock = createHeaderBlock(*
G, HeaderSection);
76 auto &ImageBaseSymbol =
G->addDefinedSymbol(
77 HeaderBlock, 0, *
R->getInitializerSymbol(), HeaderBlock.getSize(),
78 jitlink::Linkage::Strong, jitlink::Scope::Default,
false,
true);
80 addImageBaseRelocationEdge(HeaderBlock, ImageBaseSymbol);
82 CP.getObjectLinkingLayer().emit(std::move(R), std::move(
G));
102 struct HeaderBlockContent {
104 COFFHeaderMaterializationUnit::NTHeader NTHeader;
109 HeaderBlockContent Hdr = {};
112 Hdr.DOSHeader.Magic[0] =
'M';
113 Hdr.DOSHeader.Magic[1] =
'Z';
114 Hdr.DOSHeader.AddressOfNewExeHeader =
115 offsetof(HeaderBlockContent, NTHeader);
117 Hdr.NTHeader.PEMagic = PEMagic;
120 switch (
G.getTargetTriple().getArch()) {
128 auto HeaderContent =
G.allocateContent(
129 ArrayRef<char>(
reinterpret_cast<const char *
>(&Hdr),
sizeof(Hdr)));
131 return G.createContentBlock(HeaderSection, HeaderContent,
ExecutorAddr(), 8,
137 auto ImageBaseOffset =
offsetof(HeaderBlockContent, NTHeader) +
138 offsetof(NTHeader, OptionalHeader) +
164 JITDylib &PlatformJD,
const char *OrcRuntimePath,
166 const char *VCRuntimePath,
167 std::optional<SymbolAliasMap> RuntimeAliases) {
171 return make_error<StringError>(
"Unsupported COFFPlatform triple: " +
183 return std::move(Err);
189 {{ES.
intern(
"__orc_rt_jit_dispatch"),
190 {EPC.getJITDispatchInfo().JITDispatchFunction.getValue(),
192 {ES.
intern(
"__orc_rt_jit_dispatch_ctx"),
193 {EPC.getJITDispatchInfo().JITDispatchContext.getValue(),
195 return std::move(Err);
202 ES, ObjLinkingLayer, PlatformJD, OrcRuntimePath,
203 std::move(LoadDynLibrary), StaticVCRuntime, VCRuntimePath, Err));
205 return std::move(Err);
210 auto PerJDObj = OrcRuntimeArchive->findSym(
"__orc_rt_coff_per_jd_marker");
212 return PerJDObj.takeError();
215 return make_error<StringError>(
"Could not find per jd object file",
218 auto Buffer = (*PerJDObj)->getAsBinary();
220 return Buffer.takeError();
222 return (*Buffer)->getMemoryBufferRef();
226 ArrayRef<std::pair<const char *, const char *>> AL) {
227 for (
auto &KV : AL) {
228 auto AliasName = ES.
intern(KV.first);
229 assert(!Aliases.
count(AliasName) &&
"Duplicate symbol name in alias map");
230 Aliases[std::move(AliasName)] = {ES.
intern(KV.second),
236 if (
auto Err = JD.
define(std::make_unique<COFFHeaderMaterializationUnit>(
237 *
this, COFFHeaderStartSymbol)))
240 if (
auto Err = ES.
lookup({&JD}, COFFHeaderStartSymbol).takeError())
249 auto PerJDObj = getPerJDObjectFile();
251 return PerJDObj.takeError();
255 return I.takeError();
257 if (
auto Err = ObjLinkingLayer.
add(
261 if (!Bootstrapping) {
262 auto ImportedLibs = StaticVCRuntime
263 ? VCRuntimeBootstrap->loadStaticVCRuntime(JD)
264 : VCRuntimeBootstrap->loadDynamicVCRuntime(JD);
266 return ImportedLibs.takeError();
267 for (
auto &
Lib : *ImportedLibs)
268 if (
auto Err = LoadDynLibrary(JD,
Lib))
271 if (
auto Err = VCRuntimeBootstrap->initializeStaticVCRuntime(JD))
280 std::lock_guard<std::mutex> Lock(PlatformMutex);
281 auto I = JITDylibToHeaderAddr.find(&JD);
282 if (
I != JITDylibToHeaderAddr.end()) {
283 assert(HeaderAddrToJITDylib.count(
I->second) &&
284 "HeaderAddrToJITDylib missing entry");
285 HeaderAddrToJITDylib.erase(
I->second);
286 JITDylibToHeaderAddr.erase(
I);
298 RegisteredInitSymbols[&JD].add(InitSym,
302 dbgs() <<
"COFFPlatform: Registered init symbol " << *InitSym <<
" for MU "
320 static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
321 {
"_CxxThrowException",
"__orc_rt_coff_cxx_throw_exception"},
322 {
"_onexit",
"__orc_rt_coff_onexit_per_jd"},
323 {
"atexit",
"__orc_rt_coff_atexit_per_jd"}};
330 static const std::pair<const char *, const char *>
331 StandardRuntimeUtilityAliases[] = {
332 {
"__orc_rt_run_program",
"__orc_rt_coff_run_program"},
333 {
"__orc_rt_jit_dlerror",
"__orc_rt_coff_jit_dlerror"},
334 {
"__orc_rt_jit_dlopen",
"__orc_rt_coff_jit_dlopen"},
335 {
"__orc_rt_jit_dlclose",
"__orc_rt_coff_jit_dlclose"},
336 {
"__orc_rt_jit_dlsym",
"__orc_rt_coff_jit_dlsym"},
337 {
"__orc_rt_log_error",
"__orc_rt_log_error_to_stderr"}};
340 StandardRuntimeUtilityAliases);
343bool COFFPlatform::supportedTarget(
const Triple &TT) {
344 switch (TT.getArch()) {
354 JITDylib &PlatformJD,
const char *OrcRuntimePath,
355 LoadDynamicLibrary LoadDynamicLibrary,
356 bool StaticVCRuntime,
const char *VCRuntimePath,
358 : ES(ES), ObjLinkingLayer(ObjLinkingLayer),
359 LoadDynLibrary(
std::
move(LoadDynamicLibrary)),
360 StaticVCRuntime(StaticVCRuntime),
361 COFFHeaderStartSymbol(ES.intern(
"__ImageBase")) {
365 auto OrcRuntimeArchiveGenerator =
367 if (!OrcRuntimeArchiveGenerator) {
368 Err = OrcRuntimeArchiveGenerator.takeError();
373 if (!ArchiveBuffer) {
377 OrcRuntimeArchiveBuffer = std::move(*ArchiveBuffer);
379 std::make_unique<object::Archive>(*OrcRuntimeArchiveBuffer, Err);
383 Bootstrapping.store(
true);
384 ObjLinkingLayer.
addPlugin(std::make_unique<COFFPlatformPlugin>(*
this));
390 Err = VCRT.takeError();
393 VCRuntimeBootstrap = std::move(*VCRT);
395 for (
auto &
Lib : (*OrcRuntimeArchiveGenerator)->getImportedDynamicLibraries())
396 DylibsToPreload.insert(
Lib);
399 StaticVCRuntime ? VCRuntimeBootstrap->loadStaticVCRuntime(PlatformJD)
400 : VCRuntimeBootstrap->loadDynamicVCRuntime(PlatformJD);
402 Err = ImportedLibs.takeError();
406 for (
auto &
Lib : *ImportedLibs)
407 DylibsToPreload.insert(
Lib);
409 PlatformJD.
addGenerator(std::move(*OrcRuntimeArchiveGenerator));
418 for (
auto&
Lib : DylibsToPreload)
419 if (
auto E2 = LoadDynLibrary(PlatformJD,
Lib)) {
425 if (
auto E2 = VCRuntimeBootstrap->initializeStaticVCRuntime(PlatformJD)) {
431 if (
auto E2 = associateRuntimeSupportFunctions(PlatformJD)) {
439 if (
auto E2 = bootstrapCOFFRuntime(PlatformJD)) {
444 Bootstrapping.store(
false);
445 JDBootstrapStates.clear();
449COFFPlatform::buildJDDepMap(
JITDylib &JD) {
451 JITDylibDepMap JDDepMap;
454 while (!Worklist.empty()) {
455 auto CurJD = Worklist.
back();
458 auto &
DM = JDDepMap[CurJD];
460 DM.reserve(
O.size());
462 if (KV.first == CurJD)
466 std::lock_guard<std::mutex> Lock(PlatformMutex);
467 if (!JITDylibToHeaderAddr.count(KV.first)) {
469 dbgs() <<
"JITDylib unregistered to COFFPlatform detected in "
471 << CurJD->getName() <<
"\n";
476 DM.push_back(KV.first);
478 if (!JDDepMap.count(KV.first)) {
479 Worklist.push_back(KV.first);
480 JDDepMap[KV.first] = {};
485 return std::move(JDDepMap);
489void COFFPlatform::pushInitializersLoop(PushInitializersSendResultFn SendResult,
491 JITDylibDepMap &JDDepMap) {
496 while (!Worklist.empty()) {
497 auto CurJD = Worklist.back();
500 auto RISItr = RegisteredInitSymbols.find(CurJD);
501 if (RISItr != RegisteredInitSymbols.end()) {
502 NewInitSymbols[CurJD] = std::move(RISItr->second);
503 RegisteredInitSymbols.erase(RISItr);
506 for (
auto *DepJD : JDDepMap[CurJD])
507 if (!Visited.count(DepJD)) {
508 Worklist.push_back(DepJD);
509 Visited.insert(DepJD);
516 if (NewInitSymbols.
empty()) {
518 COFFJITDylibDepInfoMap DIM;
519 DIM.reserve(JDDepMap.size());
520 for (
auto &KV : JDDepMap) {
521 std::lock_guard<std::mutex> Lock(PlatformMutex);
522 COFFJITDylibDepInfo DepInfo;
523 DepInfo.reserve(KV.second.size());
524 for (
auto &Dep : KV.second) {
525 DepInfo.push_back(JITDylibToHeaderAddr[Dep]);
527 auto H = JITDylibToHeaderAddr[KV.first];
528 DIM.push_back(std::make_pair(
H, std::move(DepInfo)));
535 lookupInitSymbolsAsync(
536 [
this, SendResult = std::move(SendResult), &JD,
537 JDDepMap = std::move(JDDepMap)](
Error Err)
mutable {
539 SendResult(std::move(Err));
541 pushInitializersLoop(std::move(SendResult), JD, JDDepMap);
543 ES, std::move(NewInitSymbols));
546void COFFPlatform::rt_pushInitializers(PushInitializersSendResultFn SendResult,
550 std::lock_guard<std::mutex> Lock(PlatformMutex);
551 auto I = HeaderAddrToJITDylib.find(JDHeaderAddr);
552 if (
I != HeaderAddrToJITDylib.end())
557 dbgs() <<
"COFFPlatform::rt_pushInitializers(" << JDHeaderAddr <<
") ";
559 dbgs() <<
"pushing initializers for " << JD->getName() <<
"\n";
561 dbgs() <<
"No JITDylib for header address.\n";
566 make_error<StringError>(
"No JITDylib with header addr " +
572 auto JDDepMap = buildJDDepMap(*JD);
574 SendResult(JDDepMap.takeError());
578 pushInitializersLoop(std::move(SendResult), JD, *JDDepMap);
581void COFFPlatform::rt_lookupSymbol(SendSymbolAddressFn SendResult,
584 dbgs() <<
"COFFPlatform::rt_lookupSymbol(\""
591 std::lock_guard<std::mutex> Lock(PlatformMutex);
592 auto I = HeaderAddrToJITDylib.find(Handle);
593 if (
I != HeaderAddrToJITDylib.end())
599 dbgs() <<
" No JITDylib for handle "
602 SendResult(make_error<StringError>(
"No JITDylib associated with handle " +
609 class RtLookupNotifyComplete {
611 RtLookupNotifyComplete(SendSymbolAddressFn &&SendResult)
612 : SendResult(
std::
move(SendResult)) {}
615 assert(
Result->size() == 1 &&
"Unexpected result map count");
618 SendResult(
Result.takeError());
623 SendSymbolAddressFn SendResult;
632Error COFFPlatform::associateRuntimeSupportFunctions(
JITDylib &PlatformJD) {
635 using LookupSymbolSPSSig =
637 WFs[ES.
intern(
"__orc_rt_coff_symbol_lookup_tag")] =
639 &COFFPlatform::rt_lookupSymbol);
640 using PushInitializersSPSSig =
642 WFs[ES.
intern(
"__orc_rt_coff_push_initializers_tag")] =
644 this, &COFFPlatform::rt_pushInitializers);
649Error COFFPlatform::runBootstrapInitializers(JDBootstrapState &BState) {
652 runBootstrapSubsectionInitializers(BState,
".CRT$XIA",
".CRT$XIZ"))
655 if (
auto Err = runSymbolIfExists(*BState.JD,
"__run_after_c_init"))
659 runBootstrapSubsectionInitializers(BState,
".CRT$XCA",
".CRT$XCZ"))
664Error COFFPlatform::runBootstrapSubsectionInitializers(JDBootstrapState &BState,
667 for (
auto &Initializer : BState.Initializers)
668 if (Initializer.first >= Start && Initializer.first <= End &&
669 Initializer.second) {
673 return Res.takeError();
678Error COFFPlatform::bootstrapCOFFRuntime(
JITDylib &PlatformJD) {
684 {ES.
intern(
"__orc_rt_coff_platform_bootstrap"),
685 &orc_rt_coff_platform_bootstrap},
686 {ES.
intern(
"__orc_rt_coff_platform_shutdown"),
687 &orc_rt_coff_platform_shutdown},
688 {ES.
intern(
"__orc_rt_coff_register_jitdylib"),
689 &orc_rt_coff_register_jitdylib},
690 {ES.
intern(
"__orc_rt_coff_deregister_jitdylib"),
691 &orc_rt_coff_deregister_jitdylib},
692 {ES.
intern(
"__orc_rt_coff_register_object_sections"),
693 &orc_rt_coff_register_object_sections},
694 {ES.
intern(
"__orc_rt_coff_deregister_object_sections"),
695 &orc_rt_coff_deregister_object_sections},
700 if (
auto Err = ES.
callSPSWrapper<
void()>(orc_rt_coff_platform_bootstrap))
705 for (
auto KV : JDBootstrapStates) {
706 auto &JDBState = KV.second;
708 orc_rt_coff_register_jitdylib, JDBState.JDName,
709 JDBState.HeaderAddr))
712 for (
auto &ObjSectionMap : JDBState.ObjectSectionsMaps)
715 orc_rt_coff_register_object_sections, JDBState.HeaderAddr,
716 ObjSectionMap,
false))
721 for (
auto KV : JDBootstrapStates) {
722 auto &JDBState = KV.second;
723 if (
auto Err = runBootstrapInitializers(JDBState))
735 {{ES.
intern(SymbolName), &jit_function}});
736 if (!AfterCLookupErr) {
739 return Res.takeError();
743 return AfterCLookupErr;
748void COFFPlatform::COFFPlatformPlugin::modifyPassConfig(
752 bool IsBootstrapping =
CP.Bootstrapping.load();
755 if (InitSymbol ==
CP.COFFHeaderStartSymbol) {
758 return associateJITDylibHeaderSymbol(
G, MR, IsBootstrapping);
763 return preserveInitializerSections(
G, MR);
767 if (!IsBootstrapping)
770 return registerObjectPlatformSections(
G, JD);
775 return registerObjectPlatformSectionsInBootstrap(
G, JD);
780COFFPlatform::COFFPlatformPlugin::getSyntheticSymbolDependencies(
782 std::lock_guard<std::mutex> Lock(PluginMutex);
783 auto I = InitSymbolDeps.find(&MR);
784 if (
I != InitSymbolDeps.end()) {
785 SyntheticSymbolDependenciesMap
Result;
787 InitSymbolDeps.erase(&MR);
790 return SyntheticSymbolDependenciesMap();
793Error COFFPlatform::COFFPlatformPlugin::associateJITDylibHeaderSymbol(
795 bool IsBootstraping) {
797 return Sym->getName() == *CP.COFFHeaderStartSymbol;
799 assert(
I !=
G.defined_symbols().end() &&
"Missing COFF header start symbol");
802 std::lock_guard<std::mutex> Lock(
CP.PlatformMutex);
803 auto HeaderAddr = (*I)->getAddress();
804 CP.JITDylibToHeaderAddr[&JD] = HeaderAddr;
805 CP.HeaderAddrToJITDylib[HeaderAddr] = &JD;
806 if (!IsBootstraping) {
807 G.allocActions().push_back(
810 CP.orc_rt_coff_register_jitdylib, JD.getName(), HeaderAddr)),
812 CP.orc_rt_coff_deregister_jitdylib, HeaderAddr))});
814 G.allocActions().push_back(
817 CP.orc_rt_coff_deregister_jitdylib, HeaderAddr))});
818 JDBootstrapState BState;
820 BState.JDName = JD.getName();
821 BState.HeaderAddr = HeaderAddr;
822 CP.JDBootstrapStates.emplace(&JD, BState);
828Error COFFPlatform::COFFPlatformPlugin::registerObjectPlatformSections(
830 COFFObjectSectionsMap ObjSecs;
831 auto HeaderAddr =
CP.JITDylibToHeaderAddr[&JD];
832 assert(HeaderAddr &&
"Must be registered jitdylib");
833 for (
auto &S :
G.sections()) {
836 ObjSecs.push_back(std::make_pair(S.getName().str(),
Range.getRange()));
839 G.allocActions().push_back(
840 {
cantFail(WrapperFunctionCall::Create<SPSCOFFRegisterObjectSectionsArgs>(
841 CP.orc_rt_coff_register_object_sections, HeaderAddr, ObjSecs,
true)),
843 WrapperFunctionCall::Create<SPSCOFFDeregisterObjectSectionsArgs>(
844 CP.orc_rt_coff_deregister_object_sections, HeaderAddr,
850Error COFFPlatform::COFFPlatformPlugin::preserveInitializerSections(
852 JITLinkSymbolSet InitSectionSymbols;
853 for (
auto &Sec :
G.sections())
855 for (
auto *
B : Sec.blocks())
856 if (!
B->edges_empty())
857 InitSectionSymbols.insert(
858 &
G.addAnonymousSymbol(*
B, 0, 0,
false,
true));
860 std::lock_guard<std::mutex> Lock(PluginMutex);
861 InitSymbolDeps[&MR] = InitSectionSymbols;
865Error COFFPlatform::COFFPlatformPlugin::
868 std::lock_guard<std::mutex> Lock(
CP.PlatformMutex);
869 auto HeaderAddr =
CP.JITDylibToHeaderAddr[&JD];
870 COFFObjectSectionsMap ObjSecs;
871 for (
auto &S :
G.sections()) {
874 ObjSecs.push_back(std::make_pair(S.getName().str(),
Range.getRange()));
877 G.allocActions().push_back(
880 WrapperFunctionCall::Create<SPSCOFFDeregisterObjectSectionsArgs>(
881 CP.orc_rt_coff_deregister_object_sections, HeaderAddr,
884 auto &BState =
CP.JDBootstrapStates[&JD];
885 BState.ObjectSectionsMaps.push_back(std::move(ObjSecs));
888 for (
auto &S :
G.sections())
890 for (
auto *
B : S.blocks()) {
891 if (
B->edges_empty())
893 for (
auto &
E :
B->edges())
894 BState.Initializers.push_back(std::make_pair(
#define offsetof(TYPE, MEMBER)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static RegisterPass< DebugifyModulePass > DM("debugify", "Attach debug info to everything")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Implements a dense probed hash-table based set.
Helper for Errors used as out-parameters.
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.
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
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.
Triple - Helper class for working with autoconf configuration names.
const std::string & str() const
An Addressable with content and edges.
Represents a section address range via a pair of Block pointers to the first and last Blocks in the s...
Represents an object file section.
static Expected< std::unique_ptr< COFFVCRuntimeBootstrapper > > Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, const char *RuntimePath=nullptr)
Try to create a COFFVCRuntimeBootstrapper instance.
static std::unique_ptr< DLLImportDefinitionGenerator > Create(ExecutionSession &ES, ObjectLinkingLayer &L)
Creates a DLLImportDefinitionGenerator instance.
An ExecutionSession represents a running JIT program.
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
const Triple & getTargetTriple() const
Return the triple for the executor.
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
JITDylib & createBareJITDylib(std::string Name)
Add a new bare JITDylib to this ExecutionSession.
static JITDispatchHandlerFunction wrapAsyncWithSPS(HandlerT &&H)
Wrap a handler that takes concrete argument types (and a sender for a concrete return type) to produc...
void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete, RegisterDependenciesFunction RegisterDependencies)
Search the given JITDylibs for the given symbols.
Error registerJITDispatchHandlers(JITDylib &JD, JITDispatchHandlerAssociationMap WFs)
For each tag symbol name, associate the corresponding AsyncHandlerWrapperFunction with the address of...
decltype(auto) runSessionLocked(Func &&F)
Run the given lambda with the session mutex locked.
Represents an address in the executor process.
uint64_t getValue() const
virtual Expected< int32_t > runAsVoidFunction(ExecutorAddr VoidFnAddr)=0
Run function with a int (*)(void) signature.
Represents a JIT'd dynamic library.
Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)
Define all symbols provided by the materialization unit to be part of this JITDylib.
void addToLinkOrder(JITDylib &JD, JITDylibLookupFlags JDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Add the given JITDylib to the link order for definitions in this JITDylib.
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization pseudo-symbol, if any.
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
virtual StringRef getName() const =0
Return the name of this materialization unit.
virtual void materialize(std::unique_ptr< MaterializationResponsibility > R)=0
Implementations of this method should materialize all symbols in the materialzation unit,...
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization symbol for this MaterializationUnit (if any).
An ObjectLayer implementation built on JITLink.
ObjectLinkingLayer & addPlugin(std::unique_ptr< Plugin > P)
Add a pass-config modifier.
Error add(ResourceTrackerSP, std::unique_ptr< jitlink::LinkGraph > G)
Add a LinkGraph to the JITDylib targeted by the given tracker.
API to remove / transfer ownership of JIT resources.
JITDylib & getJITDylib() const
Return the JITDylib targeted by this tracker.
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Load(ObjectLayer &L, const char *FileName, GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibraryDefinitionGenerator from the given path.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Pointer to a pooled string representing a symbol name.
Used to notify clients when symbols can not be found during a lookup.
A utility class for serializing to a blob from a variadic list.
SPS tag type for expecteds, which are either a T or a string representing an error.
SPS tag type for sequences.
static Expected< WrapperFunctionCall > Create(ExecutorAddr FnAddr, const ArgTs &...Args)
Create a WrapperFunctionCall using the given SPS serializer to serialize the arguments.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_FILE_MACHINE_AMD64
static const char PEMagic[]
constexpr uint64_t PointerSize
aarch64 pointer size.
@ Pointer64
A plain 64-bit pointer value relocation.
const char * getGenericEdgeKindName(Edge::Kind K)
Returns the string name of the given generic edge kind, or "unknown" otherwise.
constexpr support::endianness Endianness
The endianness of all multi-byte encoded values in MessagePack.
JITDylibSearchOrder makeJITDylibSearchOrder(ArrayRef< JITDylib * > JDs, JITDylibLookupFlags Flags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Convenience function for creating a search order from an ArrayRef of JITDylib*, all with the same fla...
std::vector< std::pair< JITDylib *, JITDylibLookupFlags > > JITDylibSearchOrder
A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search order during symbol lookup.
std::unique_ptr< ReExportsMaterializationUnit > symbolAliases(SymbolAliasMap Aliases)
Create a ReExportsMaterializationUnit with the given aliases.
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
@ MatchExportedSymbolsOnly
void lookupAndRecordAddrs(unique_function< void(Error)> OnRecorded, ExecutionSession &ES, LookupKind K, const JITDylibSearchOrder &SearchOrder, std::vector< std::pair< SymbolStringPtr, ExecutorAddr * > > Pairs, SymbolLookupFlags LookupFlags=SymbolLookupFlags::RequiredSymbol)
Record addresses of the given symbols in the given ExecutorAddrs.
static void addAliases(ExecutionSession &ES, SymbolAliasMap &Aliases, ArrayRef< std::pair< const char *, const char * > > AL)
Expected< MaterializationUnit::Interface > getObjectFileInterface(ExecutionSession &ES, MemoryBufferRef ObjBuffer)
Returns a MaterializationUnit::Interface for the object file contained in the given buffer,...
RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
bool isCOFFInitializerSection(StringRef Name)
@ Ready
Emitted to memory, but waiting on transitive dependencies.
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
void sort(IteratorTy Start, IteratorTy End)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
void consumeError(Error Err)
Consume a Error without doing anything.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...
LinkGraphPassList PostAllocationPasses
Post-allocation passes.
LinkGraphPassList PostFixupPasses
Post-fixup passes.
LinkGraphPassList PrePrunePasses
Pre-prune passes.