21#define DEBUG_TYPE "orc"
35class SPSMachOExecutorSymbolFlags;
47 return SPSMachOJITDylibDepInfo::AsArgList::serialize(OB, DDI.
Sealed,
53 return SPSMachOJITDylibDepInfo::AsArgList::deserialize(IB, DDI.
Sealed,
62 using UT = std::underlying_type_t<MachOPlatform::MachOExecutorSymbolFlags>;
90using SPSRegisterSymbolsArgs =
93 SPSMachOExecutorSymbolFlags>>>;
95std::unique_ptr<jitlink::LinkGraph> createPlatformGraph(
MachOPlatform &MOP,
101 switch (
TT.getArch()) {
111 return std::make_unique<jitlink::LinkGraph>(
117class MachOPlatformCompleteBootstrapMaterializationUnit
120 using SymbolTableVector =
124 MachOPlatformCompleteBootstrapMaterializationUnit(
134 MOP(MOP), PlatformJDName(PlatformJDName),
135 CompleteBootstrapSymbol(std::move(CompleteBootstrapSymbol)),
136 SymTab(std::move(SymTab)), DeferredAAs(std::move(DeferredAAs)),
137 MachOHeaderAddr(MachOHeaderAddr), PlatformBootstrap(PlatformBootstrap),
138 PlatformShutdown(PlatformShutdown), RegisterJITDylib(RegisterJITDylib),
139 DeregisterJITDylib(DeregisterJITDylib),
140 RegisterObjectSymbolTable(RegisterObjectSymbolTable),
141 DeregisterObjectSymbolTable(DeregisterObjectSymbolTable) {}
144 return "MachOPlatformCompleteBootstrap";
147 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override {
148 using namespace jitlink;
149 auto G = createPlatformGraph(MOP,
"<OrcRTCompleteBootstrap>");
150 auto &PlaceholderSection =
151 G->createSection(
"__orc_rt_cplt_bs", MemProt::Read);
152 auto &PlaceholderBlock =
153 G->createZeroFillBlock(PlaceholderSection, 1,
ExecutorAddr(), 1, 0);
154 G->addDefinedSymbol(PlaceholderBlock, 0, *CompleteBootstrapSymbol, 1,
155 Linkage::Strong, Scope::Hidden,
false,
true);
158 G->allocActions().reserve(DeferredAAs.size() + 3);
161 G->allocActions().push_back(
167 G->allocActions().push_back(
170 RegisterJITDylib, PlatformJDName, MachOHeaderAddr)),
172 DeregisterJITDylib, MachOHeaderAddr))});
175 G->allocActions().push_back(
176 {
cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
177 RegisterObjectSymbolTable, MachOHeaderAddr, SymTab)),
178 cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
179 DeregisterObjectSymbolTable, MachOHeaderAddr, SymTab))});
182 std::move(DeferredAAs.begin(), DeferredAAs.end(),
183 std::back_inserter(
G->allocActions()));
194 SymbolTableVector SymTab;
205static StringRef ObjCRuntimeObjectSectionsData[] = {
213static StringRef ObjCRuntimeObjectSectionsText[] = {
220static StringRef ObjCRuntimeObjectSectionName =
221 "__llvm_jitlink_ObjCRuntimeRegistrationObject";
223static StringRef ObjCImageInfoSymbolName =
224 "__llvm_jitlink_macho_objc_imageinfo";
226struct ObjCImageInfoFlags {
229 bool HasCategoryClassProperties;
230 bool HasSignedObjCClassROs;
232 static constexpr uint32_t SIGNED_CLASS_RO = (1 << 4);
233 static constexpr uint32_t HAS_CATEGORY_CLASS_PROPERTIES = (1 << 6);
235 explicit ObjCImageInfoFlags(
uint32_t RawFlags) {
236 HasSignedObjCClassROs = RawFlags & SIGNED_CLASS_RO;
237 HasCategoryClassProperties = RawFlags & HAS_CATEGORY_CLASS_PROPERTIES;
238 SwiftABIVersion = (RawFlags >> 8) & 0xFF;
239 SwiftVersion = (RawFlags >> 16) & 0xFFFF;
244 if (HasCategoryClassProperties)
245 Result |= HAS_CATEGORY_CLASS_PROPERTIES;
246 if (HasSignedObjCClassROs)
247 Result |= SIGNED_CLASS_RO;
248 Result |= (SwiftABIVersion << 8);
249 Result |= (SwiftVersion << 16);
258std::optional<MachOPlatform::HeaderOptions::BuildVersionOpts>
264 switch (TT.getOS()) {
266 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_IOSSIMULATOR
267 : MachO::PLATFORM_IOS;
273 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_TVOSSIMULATOR
274 : MachO::PLATFORM_TVOS;
277 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_WATCHOSSIMULATOR
278 : MachO::PLATFORM_WATCHOS;
281 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_XROS_SIMULATOR
282 : MachO::PLATFORM_XROS;
293 std::unique_ptr<DefinitionGenerator> OrcRuntime,
296 std::optional<SymbolAliasMap> RuntimeAliases) {
301 if (!supportedTarget(ES.getTargetTriple()))
302 return make_error<StringError>(
"Unsupported MachOPlatform triple: " +
303 ES.getTargetTriple().str(),
306 auto &EPC = ES.getExecutorProcessControl();
314 return std::move(Err);
317 if (
auto Err = PlatformJD.
define(
319 {EPC.getJITDispatchInfo().JITDispatchFunction,
321 {ES.intern(
"___orc_rt_jit_dispatch_ctx"),
322 {EPC.getJITDispatchInfo().JITDispatchContext,
324 return std::move(Err);
329 ObjLinkingLayer, PlatformJD, std::move(OrcRuntime),
330 std::move(PlatformJDOpts), std::move(BuildMachOHeaderMU), Err));
332 return std::move(Err);
340 std::optional<SymbolAliasMap> RuntimeAliases) {
343 auto OrcRuntimeArchiveGenerator =
345 if (!OrcRuntimeArchiveGenerator)
346 return OrcRuntimeArchiveGenerator.takeError();
348 return Create(ObjLinkingLayer, PlatformJD,
349 std::move(*OrcRuntimeArchiveGenerator),
350 std::move(PlatformJDOpts), std::move(BuildMachOHeaderMU),
351 std::move(RuntimeAliases));
359 if (
auto Err = JD.
define(BuildMachOHeaderMU(*
this, std::move(Opts))))
362 return ES.lookup({&JD}, MachOHeaderStartSymbol).takeError();
366 std::lock_guard<std::mutex> Lock(PlatformMutex);
367 auto I = JITDylibToHeaderAddr.find(&JD);
368 if (
I != JITDylibToHeaderAddr.end()) {
369 assert(HeaderAddrToJITDylib.count(
I->second) &&
370 "HeaderAddrToJITDylib missing entry");
371 HeaderAddrToJITDylib.erase(
I->second);
372 JITDylibToHeaderAddr.erase(
I);
374 JITDylibToPThreadKey.erase(&JD);
385 RegisteredInitSymbols[&JD].add(InitSym,
388 dbgs() <<
"MachOPlatform: Registered init symbol " << *InitSym <<
" for MU "
399 ArrayRef<std::pair<const char *, const char *>> AL) {
400 for (
auto &KV : AL) {
401 auto AliasName = ES.
intern(KV.first);
402 assert(!Aliases.
count(AliasName) &&
"Duplicate symbol name in alias map");
403 Aliases[std::move(AliasName)] = {ES.
intern(KV.second),
418 static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
419 {
"___cxa_atexit",
"___orc_rt_macho_cxa_atexit"}};
426 static const std::pair<const char *, const char *>
427 StandardRuntimeUtilityAliases[] = {
428 {
"___orc_rt_run_program",
"___orc_rt_macho_run_program"},
429 {
"___orc_rt_jit_dlerror",
"___orc_rt_macho_jit_dlerror"},
430 {
"___orc_rt_jit_dlopen",
"___orc_rt_macho_jit_dlopen"},
431 {
"___orc_rt_jit_dlupdate",
"___orc_rt_macho_jit_dlupdate"},
432 {
"___orc_rt_jit_dlclose",
"___orc_rt_macho_jit_dlclose"},
433 {
"___orc_rt_jit_dlsym",
"___orc_rt_macho_jit_dlsym"},
434 {
"___orc_rt_log_error",
"___orc_rt_log_error_to_stderr"}};
437 StandardRuntimeUtilityAliases);
442 static const std::pair<const char *, const char *>
443 StandardLazyCompilationAliases[] = {
444 {
"__orc_rt_reenter",
"__orc_rt_sysv_reenter"},
445 {
"__orc_rt_resolve_tag",
"___orc_rt_resolve_tag"}};
448 StandardLazyCompilationAliases);
451bool MachOPlatform::supportedTarget(
const Triple &TT) {
452 switch (TT.getArch()) {
462 switch (
G.getTargetTriple().getArch()) {
478 if (
Sym.isCallable())
484MachOPlatform::MachOPlatform(
486 std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator,
490 ObjLinkingLayer(ObjLinkingLayer),
491 BuildMachOHeaderMU(
std::
move(BuildMachOHeaderMU)) {
493 ObjLinkingLayer.
addPlugin(std::make_unique<MachOPlatformPlugin>(*
this));
494 PlatformJD.
addGenerator(std::move(OrcRuntimeGenerator));
554 if ((Err = PlatformJD.
define(
555 this->BuildMachOHeaderMU(*
this, std::move(PlatformJDOpts)))))
557 if ((Err = ES.
lookup(&PlatformJD, MachOHeaderStartSymbol).takeError()))
564 {PlatformBootstrap.Name, PlatformShutdown.Name,
565 RegisterJITDylib.Name, DeregisterJITDylib.Name,
566 RegisterObjectSymbolTable.Name,
567 DeregisterObjectSymbolTable.Name,
568 RegisterObjectPlatformSections.Name,
569 DeregisterObjectPlatformSections.Name,
570 CreatePThreadKey.Name}))
576 std::unique_lock<std::mutex> Lock(BI.Mutex);
577 BI.CV.wait(Lock, [&]() {
return BI.ActiveGraphs == 0; });
582 auto BootstrapCompleteSymbol = ES.
intern(
"__orc_rt_macho_complete_bootstrap");
583 if ((Err = PlatformJD.
define(
584 std::make_unique<MachOPlatformCompleteBootstrapMaterializationUnit>(
585 *
this, PlatformJD.
getName(), BootstrapCompleteSymbol,
586 std::move(BI.SymTab), std::move(BI.DeferredAAs),
587 BI.MachOHeaderAddr, PlatformBootstrap.Addr,
588 PlatformShutdown.Addr, RegisterJITDylib.Addr,
589 DeregisterJITDylib.Addr, RegisterObjectSymbolTable.Addr,
590 DeregisterObjectSymbolTable.Addr))))
594 std::move(BootstrapCompleteSymbol))
599 if ((Err = associateRuntimeSupportFunctions()))
603Error MachOPlatform::associateRuntimeSupportFunctions() {
606 using PushInitializersSPSSig =
608 WFs[ES.
intern(
"___orc_rt_macho_push_initializers_tag")] =
610 this, &MachOPlatform::rt_pushInitializers);
612 using PushSymbolsSPSSig =
614 WFs[ES.
intern(
"___orc_rt_macho_push_symbols_tag")] =
616 &MachOPlatform::rt_pushSymbols);
621void MachOPlatform::pushInitializersLoop(
622 PushInitializersSendResultFn SendResult,
JITDylibSP JD) {
628 while (!Worklist.empty()) {
631 auto DepJD = Worklist.back();
635 if (JDDepMap.count(DepJD))
639 auto &DM = JDDepMap[DepJD];
640 DepJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
642 if (KV.first == DepJD)
644 DM.push_back(KV.first);
645 Worklist.push_back(KV.first);
650 auto RISItr = RegisteredInitSymbols.find(DepJD);
651 if (RISItr != RegisteredInitSymbols.end()) {
652 NewInitSymbols[DepJD] = std::move(RISItr->second);
653 RegisteredInitSymbols.erase(RISItr);
660 if (NewInitSymbols.
empty()) {
669 std::lock_guard<std::mutex> Lock(PlatformMutex);
670 for (
auto &KV : JDDepMap) {
671 auto I = JITDylibToHeaderAddr.find(KV.first);
672 if (
I != JITDylibToHeaderAddr.end())
673 HeaderAddrs[KV.first] =
I->second;
678 MachOJITDylibDepInfoMap DIM;
679 DIM.reserve(JDDepMap.size());
680 for (
auto &KV : JDDepMap) {
681 auto HI = HeaderAddrs.
find(KV.first);
683 if (HI == HeaderAddrs.
end())
686 MachOJITDylibDepInfo DepInfo;
687 for (
auto &Dep : KV.second) {
688 auto HJ = HeaderAddrs.
find(Dep);
689 if (HJ != HeaderAddrs.
end())
690 DepInfo.DepHeaders.push_back(HJ->second);
692 DIM.push_back(std::make_pair(
H, std::move(DepInfo)));
699 lookupInitSymbolsAsync(
700 [
this, SendResult = std::move(SendResult), JD](
Error Err)
mutable {
702 SendResult(std::move(Err));
704 pushInitializersLoop(std::move(SendResult), JD);
706 ES, std::move(NewInitSymbols));
709void MachOPlatform::rt_pushInitializers(PushInitializersSendResultFn SendResult,
713 std::lock_guard<std::mutex> Lock(PlatformMutex);
714 auto I = HeaderAddrToJITDylib.find(JDHeaderAddr);
715 if (
I != HeaderAddrToJITDylib.end())
720 dbgs() <<
"MachOPlatform::rt_pushInitializers(" << JDHeaderAddr <<
") ";
722 dbgs() <<
"pushing initializers for " << JD->
getName() <<
"\n";
724 dbgs() <<
"No JITDylib for header address.\n";
728 SendResult(make_error<StringError>(
"No JITDylib with header addr " +
729 formatv(
"{0:x}", JDHeaderAddr),
734 pushInitializersLoop(std::move(SendResult), JD);
737void MachOPlatform::rt_pushSymbols(
738 PushSymbolsInSendResultFn SendResult,
ExecutorAddr Handle,
739 const std::vector<std::pair<StringRef, bool>> &SymbolNames) {
744 std::lock_guard<std::mutex> Lock(PlatformMutex);
745 auto I = HeaderAddrToJITDylib.find(Handle);
746 if (
I != HeaderAddrToJITDylib.end())
750 dbgs() <<
"MachOPlatform::rt_pushSymbols(";
754 dbgs() <<
"<invalid handle " << Handle <<
">, [ ";
755 for (
auto &
Name : SymbolNames)
756 dbgs() <<
"\"" <<
Name.first <<
"\" ";
761 SendResult(make_error<StringError>(
"No JITDylib associated with handle " +
770 ? SymbolLookupFlags::RequiredSymbol
771 : SymbolLookupFlags::WeaklyReferencedSymbol);
774 LookupKind::DLSym, {{JD, JITDylibLookupFlags::MatchExportedSymbolsOnly}},
775 std::move(LS), SymbolState::Ready,
777 SendResult(
Result.takeError());
783 if (!CreatePThreadKey.Addr)
784 return make_error<StringError>(
785 "Attempting to create pthread key in target, but runtime support has "
786 "not been loaded yet",
791 CreatePThreadKey.Addr,
Result))
792 return std::move(Err);
796void MachOPlatform::MachOPlatformPlugin::modifyPassConfig(
800 using namespace jitlink;
802 bool InBootstrapPhase =
806 if (InBootstrapPhase) {
807 Config.PrePrunePasses.push_back(
808 [
this](LinkGraph &
G) {
return bootstrapPipelineStart(
G); });
809 Config.PostAllocationPasses.push_back([
this](LinkGraph &
G) {
810 return bootstrapPipelineRecordRuntimeFunctions(
G);
820 if (InitSymbol == MP.MachOHeaderStartSymbol && !InBootstrapPhase) {
821 Config.PostAllocationPasses.push_back([
this, &MR](LinkGraph &
G) {
822 return associateJITDylibHeaderSymbol(
G, MR);
830 Config.PrePrunePasses.push_back([
this, &MR](LinkGraph &
G) {
831 if (
auto Err = preserveImportantSections(
G, MR))
833 return processObjCImageInfo(
G, MR);
835 Config.PostPrunePasses.push_back(
836 [
this](LinkGraph &
G) {
return createObjCRuntimeObject(
G); });
837 Config.PostAllocationPasses.push_back(
838 [
this, &MR](LinkGraph &
G) {
return populateObjCRuntimeObject(
G, MR); });
843 Config.PostPrunePasses.insert(
844 Config.PostPrunePasses.begin(),
846 return fixTLVSectionsAndEdges(
G, JD);
852 auto JITSymTabInfo = std::make_shared<JITSymTabVector>();
853 Config.PostPrunePasses.push_back([
this, JITSymTabInfo](LinkGraph &
G) {
854 return prepareSymbolTableRegistration(
G, *JITSymTabInfo);
856 Config.PostFixupPasses.push_back([
this, &MR, JITSymTabInfo,
857 InBootstrapPhase](LinkGraph &
G) {
858 return addSymbolTableRegistration(
G, MR, *JITSymTabInfo, InBootstrapPhase);
863 Config.PostAllocationPasses.push_back(
865 return registerObjectPlatformSections(
G, JD, InBootstrapPhase);
870 if (InBootstrapPhase)
871 Config.PostFixupPasses.push_back(
872 [
this](LinkGraph &
G) {
return bootstrapPipelineEnd(
G); });
875Error MachOPlatform::MachOPlatformPlugin::bootstrapPipelineStart(
878 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
879 ++MP.Bootstrap.load()->ActiveGraphs;
883Error MachOPlatform::MachOPlatformPlugin::
886 std::pair<StringRef, ExecutorAddr *> RuntimeSymbols[] = {
887 {*MP.MachOHeaderStartSymbol, &MP.Bootstrap.load()->MachOHeaderAddr},
888 {*MP.PlatformBootstrap.Name, &MP.PlatformBootstrap.Addr},
889 {*MP.PlatformShutdown.Name, &MP.PlatformShutdown.Addr},
890 {*MP.RegisterJITDylib.Name, &MP.RegisterJITDylib.Addr},
891 {*MP.DeregisterJITDylib.Name, &MP.DeregisterJITDylib.Addr},
892 {*MP.RegisterObjectSymbolTable.Name, &MP.RegisterObjectSymbolTable.Addr},
893 {*MP.DeregisterObjectSymbolTable.Name,
894 &MP.DeregisterObjectSymbolTable.Addr},
895 {*MP.RegisterObjectPlatformSections.Name,
896 &MP.RegisterObjectPlatformSections.Addr},
897 {*MP.DeregisterObjectPlatformSections.Name,
898 &MP.DeregisterObjectPlatformSections.Addr},
899 {*MP.CreatePThreadKey.Name, &MP.CreatePThreadKey.Addr},
900 {*MP.RegisterObjCRuntimeObject.Name, &MP.RegisterObjCRuntimeObject.Addr},
901 {*MP.DeregisterObjCRuntimeObject.Name,
902 &MP.DeregisterObjCRuntimeObject.Addr}};
904 bool RegisterMachOHeader =
false;
906 for (
auto *
Sym :
G.defined_symbols()) {
907 for (
auto &RTSym : RuntimeSymbols) {
908 if (
Sym->hasName() && *
Sym->getName() == RTSym.first) {
910 return make_error<StringError>(
911 "Duplicate " + RTSym.first +
912 " detected during MachOPlatform bootstrap",
915 if (
Sym->getName() == MP.MachOHeaderStartSymbol)
916 RegisterMachOHeader =
true;
918 *RTSym.second =
Sym->getAddress();
923 if (RegisterMachOHeader) {
926 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
927 MP.JITDylibToHeaderAddr[&MP.PlatformJD] =
928 MP.Bootstrap.load()->MachOHeaderAddr;
929 MP.HeaderAddrToJITDylib[MP.Bootstrap.load()->MachOHeaderAddr] =
936Error MachOPlatform::MachOPlatformPlugin::bootstrapPipelineEnd(
938 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
939 assert(MP.Bootstrap &&
"DeferredAAs reset before bootstrap completed");
940 --MP.Bootstrap.load()->ActiveGraphs;
943 if (MP.Bootstrap.load()->ActiveGraphs == 0)
944 MP.Bootstrap.load()->CV.notify_all();
948Error MachOPlatform::MachOPlatformPlugin::associateJITDylibHeaderSymbol(
951 return Sym->getName() == MP.MachOHeaderStartSymbol;
953 assert(
I !=
G.defined_symbols().end() &&
"Missing MachO header start symbol");
956 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
957 auto HeaderAddr = (*I)->getAddress();
958 MP.JITDylibToHeaderAddr[&JD] = HeaderAddr;
959 MP.HeaderAddrToJITDylib[HeaderAddr] = &JD;
962 G.allocActions().push_back(
965 MP.RegisterJITDylib.Addr, JD.
getName(), HeaderAddr)),
967 MP.DeregisterJITDylib.Addr, HeaderAddr))});
971Error MachOPlatform::MachOPlatformPlugin::preserveImportantSections(
977 if (
auto *ObjCImageInfoSec =
979 if (ObjCImageInfoSec->blocks_size() != 1)
980 return make_error<StringError>(
981 "In " +
G.getName() +
982 "__DATA,__objc_imageinfo contains multiple blocks",
984 G.addAnonymousSymbol(**ObjCImageInfoSec->blocks().begin(), 0, 0,
false,
987 for (
auto *
B : ObjCImageInfoSec->blocks())
988 if (!
B->edges_empty())
989 return make_error<StringError>(
"In " +
G.getName() +
", " +
991 " contains references to symbols",
1008 auto *InitSection =
G.findSectionByName(InitSectionName);
1009 if (!InitSection || InitSection->empty())
1015 auto &
B = **InitSection->blocks().begin();
1016 InitSym = &
G.addDefinedSymbol(
1022 for (
auto *
B : InitSection->blocks()) {
1026 auto &S =
G.addAnonymousSymbol(*
B, 0,
B->getSize(),
false,
true);
1035Error MachOPlatform::MachOPlatformPlugin::processObjCImageInfo(
1048 auto ObjCImageInfoBlocks = ObjCImageInfo->blocks();
1051 if (ObjCImageInfoBlocks.empty())
1053 " section in " +
G.getName(),
1057 if (std::next(ObjCImageInfoBlocks.begin()) != ObjCImageInfoBlocks.end())
1058 return make_error<StringError>(
"Multiple blocks in " +
1060 " section in " +
G.getName(),
1065 for (
auto &Sec :
G.sections()) {
1066 if (&Sec != ObjCImageInfo)
1067 for (
auto *
B : Sec.blocks())
1068 for (
auto &E :
B->edges())
1069 if (E.getTarget().isDefined() &&
1070 &E.getTarget().getBlock().getSection() == ObjCImageInfo)
1072 " is referenced within file " +
1077 auto &ObjCImageInfoBlock = **ObjCImageInfoBlocks.begin();
1078 auto *ObjCImageInfoData = ObjCImageInfoBlock.getContent().data();
1084 std::lock_guard<std::mutex> Lock(PluginMutex);
1087 if (ObjCImageInfoItr != ObjCImageInfos.end()) {
1090 if (ObjCImageInfoItr->second.Version !=
Version)
1091 return make_error<StringError>(
1092 "ObjC version in " +
G.getName() +
1093 " does not match first registered version",
1095 if (ObjCImageInfoItr->second.Flags != Flags)
1096 if (
Error E = mergeImageInfoFlags(
G, MR, ObjCImageInfoItr->second, Flags))
1100 for (
auto *S : ObjCImageInfo->symbols())
1101 G.removeDefinedSymbol(*S);
1102 G.removeBlock(ObjCImageInfoBlock);
1105 dbgs() <<
"MachOPlatform: Registered __objc_imageinfo for "
1107 <<
"; flags = " <<
formatv(
"{0:x4}", Flags) <<
"\n";
1111 G.addDefinedSymbol(ObjCImageInfoBlock, 0, ObjCImageInfoSymbolName,
1115 {{MR.getExecutionSession().intern(ObjCImageInfoSymbolName),
1116 JITSymbolFlags()}}))
1124Error MachOPlatform::MachOPlatformPlugin::mergeImageInfoFlags(
1126 ObjCImageInfo &Info,
uint32_t NewFlags) {
1127 if (
Info.Flags == NewFlags)
1130 ObjCImageInfoFlags Old(
Info.Flags);
1131 ObjCImageInfoFlags
New(NewFlags);
1134 if (Old.SwiftABIVersion &&
New.SwiftABIVersion &&
1135 Old.SwiftABIVersion !=
New.SwiftABIVersion)
1136 return make_error<StringError>(
"Swift ABI version in " +
G.getName() +
1137 " does not match first registered flags",
1143 if (
Info.Finalized && Old.HasCategoryClassProperties &&
1144 !
New.HasCategoryClassProperties)
1145 return make_error<StringError>(
"ObjC category class property support in " +
1147 " does not match first registered flags",
1149 if (
Info.Finalized && Old.HasSignedObjCClassROs && !
New.HasSignedObjCClassROs)
1150 return make_error<StringError>(
"ObjC class_ro_t pointer signing in " +
1152 " does not match first registered flags",
1161 if (Old.SwiftVersion &&
New.SwiftVersion)
1162 New.SwiftVersion = std::min(Old.SwiftVersion,
New.SwiftVersion);
1163 else if (Old.SwiftVersion)
1164 New.SwiftVersion = Old.SwiftVersion;
1166 if (!
New.SwiftABIVersion)
1167 New.SwiftABIVersion = Old.SwiftABIVersion;
1169 if (Old.HasCategoryClassProperties !=
New.HasCategoryClassProperties)
1170 New.HasCategoryClassProperties =
false;
1172 if (Old.HasSignedObjCClassROs !=
New.HasSignedObjCClassROs)
1173 New.HasSignedObjCClassROs =
false;
1176 dbgs() <<
"MachOPlatform: Merging __objc_imageinfo flags for "
1178 <<
formatv(
"{0:x4}", Old.rawFlags()) <<
")"
1179 <<
" with " <<
G.getName() <<
" (" <<
formatv(
"{0:x4}", NewFlags)
1181 <<
" -> " <<
formatv(
"{0:x4}",
New.rawFlags()) <<
"\n";
1188Error MachOPlatform::MachOPlatformPlugin::fixTLVSectionsAndEdges(
1190 auto TLVBootStrapSymbolName =
G.intern(
"__tlv_bootstrap");
1192 for (
auto *
Sym :
G.external_symbols())
1193 if (
Sym->getName() == TLVBootStrapSymbolName) {
1195 MP.getExecutionSession().intern(
"___orc_rt_macho_tlv_get_addr");
1196 Sym->setName(std::move(TLSGetADDR));
1202 std::optional<uint64_t>
Key;
1204 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1205 auto I = MP.JITDylibToPThreadKey.find(&JD);
1206 if (
I != MP.JITDylibToPThreadKey.end())
1211 if (
auto KeyOrErr = MP.createPThreadKey())
1214 return KeyOrErr.takeError();
1220 for (
auto *
B : ThreadDataSec->blocks()) {
1221 if (
B->getSize() != 3 *
G.getPointerSize())
1222 return make_error<StringError>(
"__thread_vars block at " +
1223 formatv(
"{0:x}",
B->getAddress()) +
1224 " has unexpected size",
1227 auto NewBlockContent =
G.allocateBuffer(
B->getSize());
1228 llvm::copy(
B->getContent(), NewBlockContent.data());
1229 memcpy(NewBlockContent.data() +
G.getPointerSize(), &PlatformKeyBits,
1230 G.getPointerSize());
1231 B->setContent(NewBlockContent);
1236 for (
auto *
B :
G.blocks())
1237 for (
auto &E :
B->edges())
1240 E.setKind(jitlink::x86_64::
1241 RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable);
1246std::optional<MachOPlatform::MachOPlatformPlugin::UnwindSections>
1247MachOPlatform::MachOPlatformPlugin::findUnwindSectionInfo(
1249 using namespace jitlink;
1257 if (Sec.blocks().empty())
1259 SecRange = (*Sec.blocks().begin())->
getRange();
1260 for (
auto *
B : Sec.blocks()) {
1261 auto R =
B->getRange();
1262 SecRange.Start = std::min(SecRange.Start,
R.Start);
1263 SecRange.End = std::max(SecRange.End,
R.End);
1264 for (
auto &E :
B->edges()) {
1265 if (!E.getTarget().isDefined())
1267 auto &TargetBlock = E.getTarget().getBlock();
1268 auto &TargetSection = TargetBlock.getSection();
1269 if ((TargetSection.getMemProt() & MemProt::Exec) == MemProt::Exec)
1276 ScanUnwindInfoSection(*EHFrameSec, US.DwarfSection);
1278 if (Section *CUInfoSec =
1280 ScanUnwindInfoSection(*CUInfoSec, US.CompactUnwindSection);
1284 if (CodeBlocks.
empty())
1285 return std::nullopt;
1290 return LHS->getAddress() <
RHS->getAddress();
1292 for (
auto *
B : CodeBlocks) {
1293 if (US.CodeRanges.empty() || US.CodeRanges.back().End !=
B->getAddress())
1294 US.CodeRanges.push_back(
B->getRange());
1296 US.CodeRanges.back().End =
B->getRange().End;
1300 dbgs() <<
"MachOPlatform identified unwind info in " <<
G.getName() <<
":\n"
1302 if (US.DwarfSection.Start)
1303 dbgs() << US.DwarfSection <<
"\n";
1306 dbgs() <<
" Compact-unwind: ";
1307 if (US.CompactUnwindSection.Start)
1308 dbgs() << US.CompactUnwindSection <<
"\n";
1311 <<
"for code ranges:\n";
1312 for (
auto &CR : US.CodeRanges)
1313 dbgs() <<
" " << CR <<
"\n";
1314 if (US.CodeRanges.size() >=
G.sections_size())
1315 dbgs() <<
"WARNING: High number of discontiguous code ranges! "
1316 "Padding may be interfering with coalescing.\n";
1322Error MachOPlatform::MachOPlatformPlugin::registerObjectPlatformSections(
1335 if (ThreadDataSection)
1336 G.mergeSections(*ThreadDataSection, *ThreadBSSSection);
1338 ThreadDataSection = ThreadBSSSection;
1347 for (
auto &SecName : DataSections) {
1348 if (
auto *Sec =
G.findSectionByName(SecName)) {
1351 MachOPlatformSecs.
push_back({SecName,
R.getRange()});
1357 if (ThreadDataSection) {
1366 ObjCRuntimeObjectSectionName};
1368 for (
auto &SecName : PlatformSections) {
1369 auto *Sec =
G.findSectionByName(SecName);
1376 MachOPlatformSecs.
push_back({SecName,
R.getRange()});
1382 if (
auto UI = findUnwindSectionInfo(
G))
1383 UnwindInfo = std::make_tuple(std::move(UI->CodeRanges), UI->DwarfSection,
1384 UI->CompactUnwindSection);
1386 if (!MachOPlatformSecs.
empty() || UnwindInfo) {
1389 dbgs() <<
"MachOPlatform: Scraped " <<
G.getName() <<
" init sections:\n";
1390 for (
auto &KV : MachOPlatformSecs)
1391 dbgs() <<
" " << KV.first <<
": " << KV.second <<
"\n";
1394 using SPSRegisterObjectPlatformSectionsArgs =
SPSArgList<
1402 : MP.Bootstrap.load()->DeferredAAs;
1406 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1407 auto I = MP.JITDylibToHeaderAddr.find(&JD);
1408 assert(
I != MP.JITDylibToHeaderAddr.end() &&
1409 "No header registered for JD");
1410 assert(
I->second &&
"Null header registered for JD");
1411 HeaderAddr =
I->second;
1413 allocActions.push_back(
1415 WrapperFunctionCall::Create<SPSRegisterObjectPlatformSectionsArgs>(
1416 MP.RegisterObjectPlatformSections.Addr, HeaderAddr, UnwindInfo,
1417 MachOPlatformSecs)),
1419 WrapperFunctionCall::Create<SPSRegisterObjectPlatformSectionsArgs>(
1420 MP.DeregisterObjectPlatformSections.Addr, HeaderAddr,
1421 UnwindInfo, MachOPlatformSecs))});
1427Error MachOPlatform::MachOPlatformPlugin::createObjCRuntimeObject(
1430 bool NeedTextSegment =
false;
1431 size_t NumRuntimeSections = 0;
1433 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsData)
1434 if (
G.findSectionByName(ObjCRuntimeSectionName))
1435 ++NumRuntimeSections;
1437 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsText) {
1438 if (
G.findSectionByName(ObjCRuntimeSectionName)) {
1439 ++NumRuntimeSections;
1440 NeedTextSegment =
true;
1445 if (NumRuntimeSections == 0)
1450 ++NumRuntimeSections;
1456 auto &Sec =
G.createSection(ObjCRuntimeObjectSectionName,
1457 MemProt::Read | MemProt::Write);
1458 G.createMutableContentBlock(Sec, MachOSize,
ExecutorAddr(), 16, 0,
true);
1463Error MachOPlatform::MachOPlatformPlugin::populateObjCRuntimeObject(
1466 auto *ObjCRuntimeObjectSec =
1467 G.findSectionByName(ObjCRuntimeObjectSectionName);
1469 if (!ObjCRuntimeObjectSec)
1472 switch (
G.getTargetTriple().getArch()) {
1478 return make_error<StringError>(
"Unrecognized MachO arch in triple " +
1479 G.getTargetTriple().str(),
1483 auto &SecBlock = **ObjCRuntimeObjectSec->blocks().begin();
1490 std::vector<SecDesc> TextSections, DataSections;
1496 memcpy(SD.Sec.segname, FQName.
data(), 6);
1497 SD.Sec.addr = SR.getStart() - SecBlock.getAddress();
1498 SD.Sec.size = SR.getSize();
1504 DataSections.push_back({});
1505 auto &SD = DataSections.back();
1506 memset(&SD.Sec, 0,
sizeof(SD.Sec));
1507 memcpy(SD.Sec.sectname,
"__objc_imageinfo", 16);
1508 strcpy(SD.Sec.segname,
"__DATA");
1510 SD.AddFixups = [&](
size_t RecordOffset) {
1511 auto PointerEdge = getPointerEdgeKind(
G);
1515 for (
auto *
Sym :
G.external_symbols())
1516 if (
Sym->hasName() && *
Sym->getName() == ObjCImageInfoSymbolName) {
1517 ObjCImageInfoSym =
Sym;
1520 if (!ObjCImageInfoSym)
1521 for (
auto *
Sym :
G.absolute_symbols())
1522 if (
Sym->hasName() && *
Sym->getName() == ObjCImageInfoSymbolName) {
1523 ObjCImageInfoSym =
Sym;
1526 if (!ObjCImageInfoSym)
1527 for (
auto *
Sym :
G.defined_symbols())
1528 if (
Sym->hasName() && *
Sym->getName() == ObjCImageInfoSymbolName) {
1529 ObjCImageInfoSym =
Sym;
1530 std::optional<uint32_t>
Flags;
1532 std::lock_guard<std::mutex> Lock(PluginMutex);
1534 if (It != ObjCImageInfos.end()) {
1535 It->second.Finalized =
true;
1536 Flags = It->second.Flags;
1543 auto Content =
Sym->getBlock().getMutableContent(
G);
1545 "__objc_image_info size should have been verified already");
1550 if (!ObjCImageInfoSym)
1552 &
G.addExternalSymbol(ObjCImageInfoSymbolName, 8,
false);
1554 SecBlock.addEdge(PointerEdge,
1555 RecordOffset + ((
char *)&SD.Sec.addr - (
char *)&SD.Sec),
1556 *ObjCImageInfoSym, -SecBlock.getAddress().getValue());
1560 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsData) {
1561 if (
auto *GraphSec =
G.findSectionByName(ObjCRuntimeSectionName)) {
1562 DataSections.push_back({});
1563 AddSection(DataSections.back(), *GraphSec);
1567 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsText) {
1568 if (
auto *GraphSec =
G.findSectionByName(ObjCRuntimeSectionName)) {
1569 TextSections.push_back({});
1570 AddSection(TextSections.back(), *GraphSec);
1574 assert(ObjCRuntimeObjectSec->blocks_size() == 1 &&
1575 "Unexpected number of blocks in runtime sections object");
1581 switch (
G.getTargetTriple().getArch()) {
1595 Hdr.
ncmds = 1 + !TextSections.empty();
1602 auto SecContent = SecBlock.getAlreadyMutableContent();
1603 char *
P = SecContent.data();
1604 auto WriteMachOStruct = [&](
auto S) {
1607 memcpy(
P, &S,
sizeof(S));
1611 auto WriteSegment = [&](
StringRef Name, std::vector<SecDesc> &Secs) {
1613 memset(&SegLC, 0,
sizeof(SegLC));
1615 SegLC.
cmd = MachO::LC_SEGMENT_64;
1618 SegLC.
nsects = Secs.size();
1619 WriteMachOStruct(SegLC);
1620 for (
auto &SD : Secs) {
1622 SD.AddFixups(
P - SecContent.data());
1623 WriteMachOStruct(SD.Sec);
1627 WriteMachOStruct(Hdr);
1628 if (!TextSections.empty())
1629 WriteSegment(
"__TEXT", TextSections);
1630 if (!DataSections.empty())
1631 WriteSegment(
"__DATA", DataSections);
1633 assert(
P == SecContent.end() &&
"Underflow writing ObjC runtime object");
1637Error MachOPlatform::MachOPlatformPlugin::prepareSymbolTableRegistration(
1643 MemProt::Read | MemProt::Exec);
1647 for (
auto *
Sym : CStringSec->symbols()) {
1660 for (
auto *
Sym :
G.defined_symbols())
1662 for (
auto *
Sym :
G.absolute_symbols())
1665 for (
auto *
Sym : SymsToProcess) {
1666 if (!
Sym->hasName())
1669 auto I = ExistingStrings.
find(*
Sym->getName());
1670 if (
I == ExistingStrings.
end()) {
1671 auto &NameBlock =
G.createMutableContentBlock(
1672 *CStringSec,
G.allocateCString(*
Sym->getName()),
1674 auto &SymbolNameSym =
G.addAnonymousSymbol(
1675 NameBlock, 0, NameBlock.getSize(),
false,
true);
1676 JITSymTabInfo.push_back({
Sym, &SymbolNameSym});
1678 JITSymTabInfo.push_back({
Sym,
I->second});
1685Error MachOPlatform::MachOPlatformPlugin::addSymbolTableRegistration(
1687 JITSymTabVector &JITSymTabInfo,
bool InBootstrapPhase) {
1691 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1693 assert(
I != MP.JITDylibToHeaderAddr.end() &&
"No header registered for JD");
1694 assert(
I->second &&
"Null header registered for JD");
1695 HeaderAddr =
I->second;
1702 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
1703 auto &SymTab = MP.Bootstrap.load()->SymTab;
1704 for (
auto &[OriginalSymbol, NameSym] : JITSymTabInfo)
1705 SymTab.push_back({NameSym->getAddress(), OriginalSymbol->getAddress(),
1706 flagsForSymbol(*OriginalSymbol)});
1710 SymbolTableVector SymTab;
1711 for (
auto &[OriginalSymbol, NameSym] : JITSymTabInfo)
1712 SymTab.push_back({NameSym->getAddress(), OriginalSymbol->getAddress(),
1713 flagsForSymbol(*OriginalSymbol)});
1715 G.allocActions().push_back(
1716 {
cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
1717 MP.RegisterObjectSymbolTable.Addr, HeaderAddr, SymTab)),
1718 cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
1719 MP.DeregisterObjectSymbolTable.Addr, HeaderAddr, SymTab))});
1724template <
typename MachOTraits>
1734 B.Header.cputype = HdrInfo.CPUType;
1735 B.Header.cpusubtype = HdrInfo.CPUSubType;
1738 B.template addLoadCommand<MachO::LC_ID_DYLIB>(
1740 Opts.
IDDylib->CurrentVersion, Opts.
IDDylib->CompatibilityVersion);
1742 B.template addLoadCommand<MachO::LC_ID_DYLIB>(JD.
getName(), 0, 0, 0);
1745 B.template addLoadCommand<MachO::LC_BUILD_VERSION>(
1746 BV.Platform, BV.MinOS, BV.SDK,
static_cast<uint32_t>(0));
1748 B.template addLoadCommand<MachO::LC_LOAD_DYLIB>(
1749 D.Name,
D.Timestamp,
D.CurrentVersion,
D.CompatibilityVersion);
1751 B.template addLoadCommand<MachO::LC_RPATH>(
P);
1753 auto HeaderContent =
G.allocateBuffer(
B.layout());
1754 B.write(HeaderContent);
1756 return G.createContentBlock(HeaderSection, HeaderContent,
ExecutorAddr(), 8,
1764 createHeaderInterface(MOP,
std::
move(HeaderStartSymbol))),
1765 MOP(MOP), Opts(
std::
move(Opts)) {}
1768 std::unique_ptr<MaterializationResponsibility> R) {
1769 auto G = createPlatformGraph(
MOP,
"<MachOHeaderMU>");
1770 addMachOHeader(R->getTargetJITDylib(), *
G, R->getInitializerSymbol());
1777void SimpleMachOHeaderMU::addMachOHeader(
1780 auto &HeaderSection =
G.createSection(
"__header",
MemProt::Read);
1784 G.addDefinedSymbol(HeaderBlock, 0, *InitializerSymbol, HeaderBlock.getSize(),
1787 for (
auto &HS : AdditionalHeaderSymbols)
1788 G.addDefinedSymbol(HeaderBlock, HS.Offset, HS.Name, HeaderBlock.getSize(),
1799 return ::createHeaderBlock<MachO64LE>(
MOP,
Opts, JD,
G, HeaderSection);
1810 for (
auto &HS : AdditionalHeaderSymbols)
1819 switch (TT.getArch()) {
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Analysis containing CSE Info
#define LLVM_UNLIKELY(EXPR)
#define LLVM_LIKELY(EXPR)
static std::optional< ConstantRange > getRange(Value *V, const InstrInfoQuery &IIQ)
Helper method to get range from metadata or attribute.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
iterator find(const_arg_type_t< KeyT > Val)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again.
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.
void push_back(const T &Elt)
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.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Triple - Helper class for working with autoconf configuration names.
ArchType getArch() const
Get the parsed architecture type of this triple.
An Addressable with content and edges.
void addEdge(Edge::Kind K, Edge::OffsetT Offset, Symbol &Target, Edge::AddendT Addend)
Add an edge to this block.
const std::string & getName() const
Get the name for this JITLinkDylib.
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.
Block & getBlock()
Return the Block for this Symbol (Symbol must be defined).
An ExecutionSession represents a running JIT program.
const Triple & getTargetTriple() const
Return the triple for the executor.
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
static JITDispatchHandlerFunction wrapAsyncWithSPS(HandlerT &&H)
Wrap a handler that takes concrete argument types (and a sender for a concrete return type) to produc...
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Get the SymbolStringPool for this instance.
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.
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.
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
ExecutionSession & getExecutionSession()
LinkGraphLinkingLayer & addPlugin(std::shared_ptr< Plugin > P)
Add a plugin.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Error defineMaterializing(SymbolFlagsMap SymbolFlags)
Attempt to claim responsibility for new definitions.
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.
void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O) override
Emit an object file.
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, VisitMembersFunction VisitMembers=VisitMembersFunction(), 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.
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 optionals.
Output char buffer with overflow check.
SPS tag type for sequences.
static size_t size(const MachOPlatform::MachOExecutorSymbolFlags &SF)
static bool deserialize(SPSInputBuffer &IB, MachOPlatform::MachOExecutorSymbolFlags &SF)
static bool serialize(SPSOutputBuffer &OB, const MachOPlatform::MachOExecutorSymbolFlags &SF)
static bool serialize(SPSOutputBuffer &OB, const MachOPlatform::MachOJITDylibDepInfo &DDI)
static size_t size(const MachOPlatform::MachOJITDylibDepInfo &DDI)
static bool deserialize(SPSInputBuffer &IB, MachOPlatform::MachOJITDylibDepInfo &DDI)
Specialize to describe how to serialize/deserialize to/from the given concrete type.
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.
@ S_REGULAR
S_REGULAR - Regular section.
void swapStruct(fat_header &mh)
constexpr uint64_t PointerSize
aarch64 pointer size.
@ Pointer64
A plain 64-bit pointer value relocation.
@ RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable
A TLVP entry getter/constructor, transformed to Delta32ToTLVPLoadREXRelaxable.
@ 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 llvm::endianness Endianness
The endianness of all multi-byte encoded values in MessagePack.
SPSTuple< SPSExecutorAddr, SPSExecutorAddr > SPSExecutorAddrRange
std::vector< AllocActionCallPair > AllocActions
A vector of allocation actions to be run for this allocation.
StringRef MachOSwift5EntrySectionName
StringRef MachOThreadBSSSectionName
StringRef MachOThreadVarsSectionName
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...
StringRef MachOCompactUnwindInfoSectionName
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.
StringRef MachOObjCProtoListSectionName
StringRef MachOSwift5ProtosSectionName
StringRef MachOEHFrameSectionName
StringRef MachOModInitFuncSectionName
StringRef MachOObjCConstSectionName
StringRef MachODataDataSectionName
StringRef MachOSwift5ProtoSectionName
static void addAliases(ExecutionSession &ES, SymbolAliasMap &Aliases, ArrayRef< std::pair< const char *, const char * > > AL)
StringRef MachOObjCCatListSectionName
StringRef MachOObjCClassRefsSectionName
StringRef MachOObjCDataSectionName
StringRef MachOObjCClassNameSectionName
StringRef MachOObjCMethNameSectionName
StringRef MachOInitSectionNames[22]
StringRef MachOObjCClassListSectionName
StringRef MachOObjCSelRefsSectionName
StringRef MachOSwift5FieldMetadataSectionName
StringRef MachOCStringSectionName
StringRef MachOObjCMethTypeSectionName
StringRef MachOSwift5TypesSectionName
StringRef MachOObjCNLCatListSectionName
jitlink::Block & createHeaderBlock(MachOPlatform &MOP, const MachOPlatform::HeaderOptions &Opts, JITDylib &JD, jitlink::LinkGraph &G, jitlink::Section &HeaderSection)
StringRef MachOObjCNLClassListSectionName
StringRef MachOObjCImageInfoSectionName
MachOHeaderInfo getMachOHeaderInfoFromTriple(const Triple &TT)
RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
StringRef MachOThreadDataSectionName
StringRef MachODataCommonSectionName
StringRef MachOObjCProtoRefsSectionName
StringRef MachOSwift5TypeRefSectionName
StringRef MachOObjCCatList2SectionName
value_type byte_swap(value_type value, endianness endian)
uint32_t read32(const void *P, endianness E)
void write32(void *P, uint32_t V, endianness E)
This is an optimization pass for GlobalISel generic memory operations.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
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 copy(R &&Range, OutputIt Out)
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.
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...
Represents an address range in the exceutor process.