24#define DEBUG_TYPE "orc"
38class SPSMachOExecutorSymbolFlags;
50 return SPSMachOJITDylibDepInfo::AsArgList::serialize(OB, DDI.
Sealed,
56 return SPSMachOJITDylibDepInfo::AsArgList::deserialize(IB, DDI.
Sealed,
65 using UT = std::underlying_type_t<MachOPlatform::MachOExecutorSymbolFlags>;
93using SPSRegisterSymbolsArgs =
96 SPSMachOExecutorSymbolFlags>>>;
98std::unique_ptr<jitlink::LinkGraph> createPlatformGraph(
MachOPlatform &MOP,
104 switch (
TT.getArch()) {
114 return std::make_unique<jitlink::LinkGraph>(std::move(
Name), TT, PointerSize,
120class MachOPlatformCompleteBootstrapMaterializationUnit
123 using SymbolTableVector =
127 MachOPlatformCompleteBootstrapMaterializationUnit(
137 MOP(MOP), PlatformJDName(PlatformJDName),
138 CompleteBootstrapSymbol(std::move(CompleteBootstrapSymbol)),
139 SymTab(std::move(SymTab)), DeferredAAs(std::move(DeferredAAs)),
140 MachOHeaderAddr(MachOHeaderAddr), PlatformBootstrap(PlatformBootstrap),
141 PlatformShutdown(PlatformShutdown), RegisterJITDylib(RegisterJITDylib),
142 DeregisterJITDylib(DeregisterJITDylib),
143 RegisterObjectSymbolTable(RegisterObjectSymbolTable),
144 DeregisterObjectSymbolTable(DeregisterObjectSymbolTable) {}
147 return "MachOPlatformCompleteBootstrap";
150 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override {
151 using namespace jitlink;
152 auto G = createPlatformGraph(MOP,
"<OrcRTCompleteBootstrap>");
153 auto &PlaceholderSection =
154 G->createSection(
"__orc_rt_cplt_bs", MemProt::Read);
155 auto &PlaceholderBlock =
156 G->createZeroFillBlock(PlaceholderSection, 1,
ExecutorAddr(), 1, 0);
157 G->addDefinedSymbol(PlaceholderBlock, 0, *CompleteBootstrapSymbol, 1,
158 Linkage::Strong, Scope::Hidden,
false,
true);
161 G->allocActions().reserve(DeferredAAs.size() + 3);
164 G->allocActions().push_back(
170 G->allocActions().push_back(
173 RegisterJITDylib, PlatformJDName, MachOHeaderAddr)),
175 DeregisterJITDylib, MachOHeaderAddr))});
178 G->allocActions().push_back(
179 {
cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
180 RegisterObjectSymbolTable, MachOHeaderAddr, SymTab)),
181 cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
182 DeregisterObjectSymbolTable, MachOHeaderAddr, SymTab))});
185 std::move(DeferredAAs.begin(), DeferredAAs.end(),
186 std::back_inserter(
G->allocActions()));
197 SymbolTableVector SymTab;
208static StringRef ObjCRuntimeObjectSectionsData[] = {
216static StringRef ObjCRuntimeObjectSectionsText[] = {
223static StringRef ObjCRuntimeObjectSectionName =
224 "__llvm_jitlink_ObjCRuntimeRegistrationObject";
226static StringRef ObjCImageInfoSymbolName =
227 "__llvm_jitlink_macho_objc_imageinfo";
229struct ObjCImageInfoFlags {
232 bool HasCategoryClassProperties;
233 bool HasSignedObjCClassROs;
235 static constexpr uint32_t SIGNED_CLASS_RO = (1 << 4);
236 static constexpr uint32_t HAS_CATEGORY_CLASS_PROPERTIES = (1 << 6);
238 explicit ObjCImageInfoFlags(
uint32_t RawFlags) {
239 HasSignedObjCClassROs = RawFlags & SIGNED_CLASS_RO;
240 HasCategoryClassProperties = RawFlags & HAS_CATEGORY_CLASS_PROPERTIES;
241 SwiftABIVersion = (RawFlags >> 8) & 0xFF;
242 SwiftVersion = (RawFlags >> 16) & 0xFFFF;
247 if (HasCategoryClassProperties)
248 Result |= HAS_CATEGORY_CLASS_PROPERTIES;
249 if (HasSignedObjCClassROs)
250 Result |= SIGNED_CLASS_RO;
251 Result |= (SwiftABIVersion << 8);
252 Result |= (SwiftVersion << 16);
261std::optional<MachOPlatform::HeaderOptions::BuildVersionOpts>
267 switch (TT.getOS()) {
269 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_IOSSIMULATOR
270 : MachO::PLATFORM_IOS;
276 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_TVOSSIMULATOR
277 : MachO::PLATFORM_TVOS;
280 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_WATCHOSSIMULATOR
281 : MachO::PLATFORM_WATCHOS;
284 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_XROS_SIMULATOR
285 : MachO::PLATFORM_XROS;
296 JITDylib &PlatformJD, std::unique_ptr<DefinitionGenerator> OrcRuntime,
298 std::optional<SymbolAliasMap> RuntimeAliases) {
302 return make_error<StringError>(
"Unsupported MachOPlatform triple: " +
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 ES, ObjLinkingLayer, PlatformJD, std::move(OrcRuntime),
330 std::move(PlatformJDOpts), std::move(BuildMachOHeaderMU), Err));
332 return std::move(Err);
338 JITDylib &PlatformJD,
const char *OrcRuntimePath,
341 std::optional<SymbolAliasMap> RuntimeAliases) {
344 auto OrcRuntimeArchiveGenerator =
346 if (!OrcRuntimeArchiveGenerator)
347 return OrcRuntimeArchiveGenerator.takeError();
349 return Create(ES, ObjLinkingLayer, PlatformJD,
350 std::move(*OrcRuntimeArchiveGenerator),
351 std::move(PlatformJDOpts), std::move(BuildMachOHeaderMU),
352 std::move(RuntimeAliases));
360 if (
auto Err = JD.
define(BuildMachOHeaderMU(*
this, std::move(Opts))))
363 return ES.lookup({&JD}, MachOHeaderStartSymbol).takeError();
367 std::lock_guard<std::mutex> Lock(PlatformMutex);
368 auto I = JITDylibToHeaderAddr.find(&JD);
369 if (
I != JITDylibToHeaderAddr.end()) {
370 assert(HeaderAddrToJITDylib.count(
I->second) &&
371 "HeaderAddrToJITDylib missing entry");
372 HeaderAddrToJITDylib.erase(
I->second);
373 JITDylibToHeaderAddr.erase(
I);
375 JITDylibToPThreadKey.erase(&JD);
386 RegisteredInitSymbols[&JD].add(InitSym,
389 dbgs() <<
"MachOPlatform: Registered init symbol " << *InitSym <<
" for MU "
400 ArrayRef<std::pair<const char *, const char *>> AL) {
401 for (
auto &KV : AL) {
402 auto AliasName = ES.
intern(KV.first);
403 assert(!Aliases.
count(AliasName) &&
"Duplicate symbol name in alias map");
404 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_dlclose",
"___orc_rt_macho_jit_dlclose"},
432 {
"___orc_rt_jit_dlsym",
"___orc_rt_macho_jit_dlsym"},
433 {
"___orc_rt_log_error",
"___orc_rt_log_error_to_stderr"}};
436 StandardRuntimeUtilityAliases);
439bool MachOPlatform::supportedTarget(
const Triple &TT) {
440 switch (TT.getArch()) {
450 switch (
G.getTargetTriple().getArch()) {
466 if (
Sym.isCallable())
472MachOPlatform::MachOPlatform(
475 std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator,
478 : ES(ES), PlatformJD(PlatformJD), ObjLinkingLayer(ObjLinkingLayer),
479 BuildMachOHeaderMU(
std::
move(BuildMachOHeaderMU)) {
481 ObjLinkingLayer.
addPlugin(std::make_unique<MachOPlatformPlugin>(*
this));
482 PlatformJD.
addGenerator(std::move(OrcRuntimeGenerator));
542 if ((Err = PlatformJD.
define(
543 this->BuildMachOHeaderMU(*
this, std::move(PlatformJDOpts)))))
545 if ((Err = ES.
lookup(&PlatformJD, MachOHeaderStartSymbol).takeError()))
552 {PlatformBootstrap.Name, PlatformShutdown.Name,
553 RegisterJITDylib.Name, DeregisterJITDylib.Name,
554 RegisterObjectSymbolTable.Name,
555 DeregisterObjectSymbolTable.Name,
556 RegisterObjectPlatformSections.Name,
557 DeregisterObjectPlatformSections.Name,
558 CreatePThreadKey.Name}))
564 std::unique_lock<std::mutex> Lock(BI.Mutex);
565 BI.CV.wait(Lock, [&]() {
return BI.ActiveGraphs == 0; });
570 auto BootstrapCompleteSymbol = ES.
intern(
"__orc_rt_macho_complete_bootstrap");
571 if ((Err = PlatformJD.
define(
572 std::make_unique<MachOPlatformCompleteBootstrapMaterializationUnit>(
573 *
this, PlatformJD.
getName(), BootstrapCompleteSymbol,
574 std::move(BI.SymTab), std::move(BI.DeferredAAs),
575 BI.MachOHeaderAddr, PlatformBootstrap.Addr,
576 PlatformShutdown.Addr, RegisterJITDylib.Addr,
577 DeregisterJITDylib.Addr, RegisterObjectSymbolTable.Addr,
578 DeregisterObjectSymbolTable.Addr))))
582 std::move(BootstrapCompleteSymbol))
587 if ((Err = associateRuntimeSupportFunctions()))
591Error MachOPlatform::associateRuntimeSupportFunctions() {
594 using PushInitializersSPSSig =
596 WFs[ES.
intern(
"___orc_rt_macho_push_initializers_tag")] =
598 this, &MachOPlatform::rt_pushInitializers);
600 using PushSymbolsSPSSig =
602 WFs[ES.
intern(
"___orc_rt_macho_push_symbols_tag")] =
604 &MachOPlatform::rt_pushSymbols);
609void MachOPlatform::pushInitializersLoop(
610 PushInitializersSendResultFn SendResult,
JITDylibSP JD) {
616 while (!Worklist.empty()) {
619 auto DepJD = Worklist.back();
623 if (JDDepMap.count(DepJD))
627 auto &DM = JDDepMap[DepJD];
628 DepJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
630 if (KV.first == DepJD)
632 DM.push_back(KV.first);
633 Worklist.push_back(KV.first);
638 auto RISItr = RegisteredInitSymbols.find(DepJD);
639 if (RISItr != RegisteredInitSymbols.end()) {
640 NewInitSymbols[DepJD] = std::move(RISItr->second);
641 RegisteredInitSymbols.erase(RISItr);
648 if (NewInitSymbols.
empty()) {
657 std::lock_guard<std::mutex> Lock(PlatformMutex);
658 for (
auto &KV : JDDepMap) {
659 auto I = JITDylibToHeaderAddr.find(KV.first);
660 if (
I != JITDylibToHeaderAddr.end())
661 HeaderAddrs[KV.first] =
I->second;
666 MachOJITDylibDepInfoMap DIM;
667 DIM.reserve(JDDepMap.size());
668 for (
auto &KV : JDDepMap) {
669 auto HI = HeaderAddrs.
find(KV.first);
671 if (HI == HeaderAddrs.
end())
674 MachOJITDylibDepInfo DepInfo;
675 for (
auto &Dep : KV.second) {
676 auto HJ = HeaderAddrs.
find(Dep);
677 if (HJ != HeaderAddrs.
end())
678 DepInfo.DepHeaders.push_back(HJ->second);
680 DIM.push_back(std::make_pair(
H, std::move(DepInfo)));
687 lookupInitSymbolsAsync(
688 [
this, SendResult = std::move(SendResult), JD](
Error Err)
mutable {
690 SendResult(std::move(Err));
692 pushInitializersLoop(std::move(SendResult), JD);
694 ES, std::move(NewInitSymbols));
697void MachOPlatform::rt_pushInitializers(PushInitializersSendResultFn SendResult,
701 std::lock_guard<std::mutex> Lock(PlatformMutex);
702 auto I = HeaderAddrToJITDylib.find(JDHeaderAddr);
703 if (
I != HeaderAddrToJITDylib.end())
708 dbgs() <<
"MachOPlatform::rt_pushInitializers(" << JDHeaderAddr <<
") ";
710 dbgs() <<
"pushing initializers for " << JD->
getName() <<
"\n";
712 dbgs() <<
"No JITDylib for header address.\n";
716 SendResult(make_error<StringError>(
"No JITDylib with header addr " +
717 formatv(
"{0:x}", JDHeaderAddr),
722 pushInitializersLoop(std::move(SendResult), JD);
725void MachOPlatform::rt_pushSymbols(
726 PushSymbolsInSendResultFn SendResult,
ExecutorAddr Handle,
727 const std::vector<std::pair<StringRef, bool>> &SymbolNames) {
732 std::lock_guard<std::mutex> Lock(PlatformMutex);
733 auto I = HeaderAddrToJITDylib.find(Handle);
734 if (
I != HeaderAddrToJITDylib.end())
738 dbgs() <<
"MachOPlatform::rt_pushSymbols(";
742 dbgs() <<
"<invalid handle " << Handle <<
">, [ ";
743 for (
auto &
Name : SymbolNames)
744 dbgs() <<
"\"" <<
Name.first <<
"\" ";
749 SendResult(make_error<StringError>(
"No JITDylib associated with handle " +
756 for (
auto &[
Name, Required] : SymbolNames)
758 ? SymbolLookupFlags::RequiredSymbol
759 : SymbolLookupFlags::WeaklyReferencedSymbol);
762 LookupKind::DLSym, {{JD, JITDylibLookupFlags::MatchExportedSymbolsOnly}},
763 std::move(LS), SymbolState::Ready,
765 SendResult(
Result.takeError());
771 if (!CreatePThreadKey.Addr)
772 return make_error<StringError>(
773 "Attempting to create pthread key in target, but runtime support has "
774 "not been loaded yet",
779 CreatePThreadKey.Addr,
Result))
780 return std::move(Err);
784void MachOPlatform::MachOPlatformPlugin::modifyPassConfig(
788 using namespace jitlink;
790 bool InBootstrapPhase =
794 if (InBootstrapPhase) {
795 Config.PrePrunePasses.push_back(
796 [
this](LinkGraph &
G) {
return bootstrapPipelineStart(
G); });
797 Config.PostAllocationPasses.push_back([
this](LinkGraph &
G) {
798 return bootstrapPipelineRecordRuntimeFunctions(
G);
808 if (InitSymbol == MP.MachOHeaderStartSymbol && !InBootstrapPhase) {
809 Config.PostAllocationPasses.push_back([
this, &MR](LinkGraph &
G) {
810 return associateJITDylibHeaderSymbol(
G, MR);
818 Config.PrePrunePasses.push_back([
this, &MR](LinkGraph &
G) {
819 if (
auto Err = preserveImportantSections(
G, MR))
821 return processObjCImageInfo(
G, MR);
823 Config.PostPrunePasses.push_back(
824 [
this](LinkGraph &
G) {
return createObjCRuntimeObject(
G); });
825 Config.PostAllocationPasses.push_back(
826 [
this, &MR](LinkGraph &
G) {
return populateObjCRuntimeObject(
G, MR); });
831 Config.PostPrunePasses.insert(
832 Config.PostPrunePasses.begin(),
834 return fixTLVSectionsAndEdges(
G, JD);
840 auto JITSymTabInfo = std::make_shared<JITSymTabVector>();
841 Config.PostPrunePasses.push_back([
this, JITSymTabInfo](LinkGraph &
G) {
842 return prepareSymbolTableRegistration(
G, *JITSymTabInfo);
844 Config.PostFixupPasses.push_back([
this, &MR, JITSymTabInfo,
845 InBootstrapPhase](LinkGraph &
G) {
846 return addSymbolTableRegistration(
G, MR, *JITSymTabInfo, InBootstrapPhase);
851 Config.PostAllocationPasses.push_back(
853 return registerObjectPlatformSections(
G, JD, InBootstrapPhase);
858 if (InBootstrapPhase)
859 Config.PostFixupPasses.push_back(
860 [
this](LinkGraph &
G) {
return bootstrapPipelineEnd(
G); });
864MachOPlatform::MachOPlatformPlugin::getSyntheticSymbolDependencies(
866 std::lock_guard<std::mutex> Lock(PluginMutex);
867 auto I = InitSymbolDeps.find(&MR);
868 if (
I != InitSymbolDeps.end()) {
869 SyntheticSymbolDependenciesMap
Result;
871 InitSymbolDeps.erase(&MR);
874 return SyntheticSymbolDependenciesMap();
877Error MachOPlatform::MachOPlatformPlugin::bootstrapPipelineStart(
880 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
881 ++MP.Bootstrap.load()->ActiveGraphs;
885Error MachOPlatform::MachOPlatformPlugin::
888 std::pair<StringRef, ExecutorAddr *> RuntimeSymbols[] = {
889 {*MP.MachOHeaderStartSymbol, &MP.Bootstrap.load()->MachOHeaderAddr},
890 {*MP.PlatformBootstrap.Name, &MP.PlatformBootstrap.Addr},
891 {*MP.PlatformShutdown.Name, &MP.PlatformShutdown.Addr},
892 {*MP.RegisterJITDylib.Name, &MP.RegisterJITDylib.Addr},
893 {*MP.DeregisterJITDylib.Name, &MP.DeregisterJITDylib.Addr},
894 {*MP.RegisterObjectSymbolTable.Name, &MP.RegisterObjectSymbolTable.Addr},
895 {*MP.DeregisterObjectSymbolTable.Name,
896 &MP.DeregisterObjectSymbolTable.Addr},
897 {*MP.RegisterObjectPlatformSections.Name,
898 &MP.RegisterObjectPlatformSections.Addr},
899 {*MP.DeregisterObjectPlatformSections.Name,
900 &MP.DeregisterObjectPlatformSections.Addr},
901 {*MP.CreatePThreadKey.Name, &MP.CreatePThreadKey.Addr},
902 {*MP.RegisterObjCRuntimeObject.Name, &MP.RegisterObjCRuntimeObject.Addr},
903 {*MP.DeregisterObjCRuntimeObject.Name,
904 &MP.DeregisterObjCRuntimeObject.Addr}};
906 bool RegisterMachOHeader =
false;
908 for (
auto *
Sym :
G.defined_symbols()) {
909 for (
auto &RTSym : RuntimeSymbols) {
910 if (
Sym->hasName() &&
Sym->getName() == RTSym.first) {
912 return make_error<StringError>(
913 "Duplicate " + RTSym.first +
914 " detected during MachOPlatform bootstrap",
917 if (
Sym->getName() == *MP.MachOHeaderStartSymbol)
918 RegisterMachOHeader =
true;
920 *RTSym.second =
Sym->getAddress();
925 if (RegisterMachOHeader) {
928 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
929 MP.JITDylibToHeaderAddr[&MP.PlatformJD] =
930 MP.Bootstrap.load()->MachOHeaderAddr;
931 MP.HeaderAddrToJITDylib[MP.Bootstrap.load()->MachOHeaderAddr] =
938Error MachOPlatform::MachOPlatformPlugin::bootstrapPipelineEnd(
940 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
941 assert(MP.Bootstrap &&
"DeferredAAs reset before bootstrap completed");
942 --MP.Bootstrap.load()->ActiveGraphs;
945 if (MP.Bootstrap.load()->ActiveGraphs == 0)
946 MP.Bootstrap.load()->CV.notify_all();
950Error MachOPlatform::MachOPlatformPlugin::associateJITDylibHeaderSymbol(
953 return Sym->getName() == *MP.MachOHeaderStartSymbol;
955 assert(
I !=
G.defined_symbols().end() &&
"Missing MachO header start symbol");
958 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
959 auto HeaderAddr = (*I)->getAddress();
960 MP.JITDylibToHeaderAddr[&JD] = HeaderAddr;
961 MP.HeaderAddrToJITDylib[HeaderAddr] = &JD;
964 G.allocActions().push_back(
967 MP.RegisterJITDylib.Addr, JD.
getName(), HeaderAddr)),
969 MP.DeregisterJITDylib.Addr, HeaderAddr))});
973Error MachOPlatform::MachOPlatformPlugin::preserveImportantSections(
979 if (
auto *ObjCImageInfoSec =
981 if (ObjCImageInfoSec->blocks_size() != 1)
982 return make_error<StringError>(
983 "In " +
G.getName() +
984 "__DATA,__objc_imageinfo contains multiple blocks",
986 G.addAnonymousSymbol(**ObjCImageInfoSec->blocks().begin(), 0, 0,
false,
989 for (
auto *
B : ObjCImageInfoSec->blocks())
990 if (!
B->edges_empty())
991 return make_error<StringError>(
"In " +
G.getName() +
", " +
993 " contains references to symbols",
1000 JITLinkSymbolSet InitSectionSymbols;
1008 auto *InitSection =
G.findSectionByName(InitSectionName);
1015 for (
auto &
Sym : InitSection->symbols()) {
1016 auto &
B =
Sym->getBlock();
1017 if (
Sym->isLive() &&
Sym->getOffset() == 0 &&
1018 Sym->getSize() ==
B.getSize() && !AlreadyLiveBlocks.
count(&
B)) {
1019 InitSectionSymbols.insert(
Sym);
1025 for (
auto *
B : InitSection->blocks())
1026 if (!AlreadyLiveBlocks.
count(
B))
1027 InitSectionSymbols.insert(
1028 &
G.addAnonymousSymbol(*
B, 0,
B->getSize(),
false,
true));
1031 if (!InitSectionSymbols.empty()) {
1032 std::lock_guard<std::mutex> Lock(PluginMutex);
1033 InitSymbolDeps[&MR] = std::move(InitSectionSymbols);
1039Error MachOPlatform::MachOPlatformPlugin::processObjCImageInfo(
1052 auto ObjCImageInfoBlocks = ObjCImageInfo->blocks();
1055 if (ObjCImageInfoBlocks.empty())
1057 " section in " +
G.getName(),
1061 if (std::next(ObjCImageInfoBlocks.begin()) != ObjCImageInfoBlocks.end())
1062 return make_error<StringError>(
"Multiple blocks in " +
1064 " section in " +
G.getName(),
1069 for (
auto &Sec :
G.sections()) {
1070 if (&Sec != ObjCImageInfo)
1071 for (
auto *
B : Sec.blocks())
1072 for (
auto &E :
B->edges())
1073 if (E.getTarget().isDefined() &&
1074 &E.getTarget().getBlock().getSection() == ObjCImageInfo)
1076 " is referenced within file " +
1081 auto &ObjCImageInfoBlock = **ObjCImageInfoBlocks.begin();
1082 auto *ObjCImageInfoData = ObjCImageInfoBlock.getContent().data();
1088 std::lock_guard<std::mutex> Lock(PluginMutex);
1091 if (ObjCImageInfoItr != ObjCImageInfos.end()) {
1094 if (ObjCImageInfoItr->second.Version !=
Version)
1095 return make_error<StringError>(
1096 "ObjC version in " +
G.getName() +
1097 " does not match first registered version",
1099 if (ObjCImageInfoItr->second.Flags != Flags)
1100 if (
Error E = mergeImageInfoFlags(
G, MR, ObjCImageInfoItr->second, Flags))
1104 for (
auto *S : ObjCImageInfo->symbols())
1105 G.removeDefinedSymbol(*S);
1106 G.removeBlock(ObjCImageInfoBlock);
1109 dbgs() <<
"MachOPlatform: Registered __objc_imageinfo for "
1111 <<
"; flags = " <<
formatv(
"{0:x4}", Flags) <<
"\n";
1115 G.addDefinedSymbol(ObjCImageInfoBlock, 0, ObjCImageInfoSymbolName,
1119 {{MR.getExecutionSession().intern(ObjCImageInfoSymbolName),
1120 JITSymbolFlags()}}))
1128Error MachOPlatform::MachOPlatformPlugin::mergeImageInfoFlags(
1130 ObjCImageInfo &Info,
uint32_t NewFlags) {
1131 if (
Info.Flags == NewFlags)
1134 ObjCImageInfoFlags Old(
Info.Flags);
1135 ObjCImageInfoFlags
New(NewFlags);
1138 if (Old.SwiftABIVersion &&
New.SwiftABIVersion &&
1139 Old.SwiftABIVersion !=
New.SwiftABIVersion)
1140 return make_error<StringError>(
"Swift ABI version in " +
G.getName() +
1141 " does not match first registered flags",
1147 if (
Info.Finalized && Old.HasCategoryClassProperties &&
1148 !
New.HasCategoryClassProperties)
1149 return make_error<StringError>(
"ObjC category class property support in " +
1151 " does not match first registered flags",
1153 if (
Info.Finalized && Old.HasSignedObjCClassROs && !
New.HasSignedObjCClassROs)
1154 return make_error<StringError>(
"ObjC class_ro_t pointer signing in " +
1156 " does not match first registered flags",
1165 if (Old.SwiftVersion &&
New.SwiftVersion)
1166 New.SwiftVersion = std::min(Old.SwiftVersion,
New.SwiftVersion);
1167 else if (Old.SwiftVersion)
1168 New.SwiftVersion = Old.SwiftVersion;
1170 if (!
New.SwiftABIVersion)
1171 New.SwiftABIVersion = Old.SwiftABIVersion;
1173 if (Old.HasCategoryClassProperties !=
New.HasCategoryClassProperties)
1174 New.HasCategoryClassProperties =
false;
1176 if (Old.HasSignedObjCClassROs !=
New.HasSignedObjCClassROs)
1177 New.HasSignedObjCClassROs =
false;
1180 dbgs() <<
"MachOPlatform: Merging __objc_imageinfo flags for "
1182 <<
formatv(
"{0:x4}", Old.rawFlags()) <<
")"
1183 <<
" with " <<
G.getName() <<
" (" <<
formatv(
"{0:x4}", NewFlags)
1185 <<
" -> " <<
formatv(
"{0:x4}",
New.rawFlags()) <<
"\n";
1192Error MachOPlatform::MachOPlatformPlugin::fixTLVSectionsAndEdges(
1196 for (
auto *
Sym :
G.external_symbols())
1197 if (
Sym->getName() ==
"__tlv_bootstrap") {
1198 Sym->setName(
"___orc_rt_macho_tlv_get_addr");
1204 std::optional<uint64_t>
Key;
1206 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1207 auto I = MP.JITDylibToPThreadKey.find(&JD);
1208 if (
I != MP.JITDylibToPThreadKey.end())
1213 if (
auto KeyOrErr = MP.createPThreadKey())
1216 return KeyOrErr.takeError();
1222 for (
auto *
B : ThreadDataSec->blocks()) {
1223 if (
B->getSize() != 3 *
G.getPointerSize())
1224 return make_error<StringError>(
"__thread_vars block at " +
1225 formatv(
"{0:x}",
B->getAddress()) +
1226 " has unexpected size",
1229 auto NewBlockContent =
G.allocateBuffer(
B->getSize());
1230 llvm::copy(
B->getContent(), NewBlockContent.data());
1231 memcpy(NewBlockContent.data() +
G.getPointerSize(), &PlatformKeyBits,
1232 G.getPointerSize());
1233 B->setContent(NewBlockContent);
1238 for (
auto *
B :
G.blocks())
1239 for (
auto &E :
B->edges())
1242 E.setKind(jitlink::x86_64::
1243 RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable);
1248std::optional<MachOPlatform::MachOPlatformPlugin::UnwindSections>
1249MachOPlatform::MachOPlatformPlugin::findUnwindSectionInfo(
1251 using namespace jitlink;
1259 if (Sec.blocks().empty())
1261 SecRange = (*Sec.blocks().begin())->
getRange();
1262 for (
auto *
B : Sec.blocks()) {
1263 auto R =
B->getRange();
1264 SecRange.Start = std::min(SecRange.Start,
R.Start);
1265 SecRange.End = std::max(SecRange.End,
R.End);
1266 for (
auto &E :
B->edges()) {
1267 if (!E.getTarget().isDefined())
1269 auto &TargetBlock = E.getTarget().getBlock();
1270 auto &TargetSection = TargetBlock.getSection();
1271 if ((TargetSection.getMemProt() & MemProt::Exec) == MemProt::Exec)
1278 ScanUnwindInfoSection(*EHFrameSec, US.DwarfSection);
1280 if (Section *CUInfoSec =
1282 ScanUnwindInfoSection(*CUInfoSec, US.CompactUnwindSection);
1286 if (CodeBlocks.
empty())
1287 return std::nullopt;
1292 return LHS->getAddress() <
RHS->getAddress();
1294 for (
auto *
B : CodeBlocks) {
1295 if (US.CodeRanges.empty() || US.CodeRanges.back().End !=
B->getAddress())
1296 US.CodeRanges.push_back(
B->getRange());
1298 US.CodeRanges.back().End =
B->getRange().End;
1302 dbgs() <<
"MachOPlatform identified unwind info in " <<
G.getName() <<
":\n"
1304 if (US.DwarfSection.Start)
1305 dbgs() << US.DwarfSection <<
"\n";
1308 dbgs() <<
" Compact-unwind: ";
1309 if (US.CompactUnwindSection.Start)
1310 dbgs() << US.CompactUnwindSection <<
"\n";
1313 <<
"for code ranges:\n";
1314 for (
auto &CR : US.CodeRanges)
1315 dbgs() <<
" " << CR <<
"\n";
1316 if (US.CodeRanges.size() >=
G.sections_size())
1317 dbgs() <<
"WARNING: High number of discontiguous code ranges! "
1318 "Padding may be interfering with coalescing.\n";
1324Error MachOPlatform::MachOPlatformPlugin::registerObjectPlatformSections(
1337 if (ThreadDataSection)
1338 G.mergeSections(*ThreadDataSection, *ThreadBSSSection);
1340 ThreadDataSection = ThreadBSSSection;
1349 for (
auto &SecName : DataSections) {
1350 if (
auto *Sec =
G.findSectionByName(SecName)) {
1353 MachOPlatformSecs.
push_back({SecName,
R.getRange()});
1359 if (ThreadDataSection) {
1368 ObjCRuntimeObjectSectionName};
1370 for (
auto &SecName : PlatformSections) {
1371 auto *Sec =
G.findSectionByName(SecName);
1378 MachOPlatformSecs.
push_back({SecName,
R.getRange()});
1384 if (
auto UI = findUnwindSectionInfo(
G))
1385 UnwindInfo = std::make_tuple(std::move(UI->CodeRanges), UI->DwarfSection,
1386 UI->CompactUnwindSection);
1388 if (!MachOPlatformSecs.
empty() || UnwindInfo) {
1391 dbgs() <<
"MachOPlatform: Scraped " <<
G.getName() <<
" init sections:\n";
1392 for (
auto &KV : MachOPlatformSecs)
1393 dbgs() <<
" " << KV.first <<
": " << KV.second <<
"\n";
1396 using SPSRegisterObjectPlatformSectionsArgs =
SPSArgList<
1404 : MP.Bootstrap.load()->DeferredAAs;
1408 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1409 auto I = MP.JITDylibToHeaderAddr.find(&JD);
1410 assert(
I != MP.JITDylibToHeaderAddr.end() &&
1411 "No header registered for JD");
1412 assert(
I->second &&
"Null header registered for JD");
1413 HeaderAddr =
I->second;
1415 allocActions.push_back(
1417 WrapperFunctionCall::Create<SPSRegisterObjectPlatformSectionsArgs>(
1418 MP.RegisterObjectPlatformSections.Addr, HeaderAddr, UnwindInfo,
1419 MachOPlatformSecs)),
1421 WrapperFunctionCall::Create<SPSRegisterObjectPlatformSectionsArgs>(
1422 MP.DeregisterObjectPlatformSections.Addr, HeaderAddr,
1423 UnwindInfo, MachOPlatformSecs))});
1429Error MachOPlatform::MachOPlatformPlugin::createObjCRuntimeObject(
1432 bool NeedTextSegment =
false;
1433 size_t NumRuntimeSections = 0;
1435 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsData)
1436 if (
G.findSectionByName(ObjCRuntimeSectionName))
1437 ++NumRuntimeSections;
1439 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsText) {
1440 if (
G.findSectionByName(ObjCRuntimeSectionName)) {
1441 ++NumRuntimeSections;
1442 NeedTextSegment =
true;
1447 if (NumRuntimeSections == 0)
1452 ++NumRuntimeSections;
1458 auto &Sec =
G.createSection(ObjCRuntimeObjectSectionName,
1459 MemProt::Read | MemProt::Write);
1460 G.createMutableContentBlock(Sec, MachOSize,
ExecutorAddr(), 16, 0,
true);
1465Error MachOPlatform::MachOPlatformPlugin::populateObjCRuntimeObject(
1468 auto *ObjCRuntimeObjectSec =
1469 G.findSectionByName(ObjCRuntimeObjectSectionName);
1471 if (!ObjCRuntimeObjectSec)
1474 switch (
G.getTargetTriple().getArch()) {
1480 return make_error<StringError>(
"Unrecognized MachO arch in triple " +
1481 G.getTargetTriple().str(),
1485 auto &SecBlock = **ObjCRuntimeObjectSec->blocks().begin();
1492 std::vector<SecDesc> TextSections, DataSections;
1498 memcpy(SD.Sec.segname, FQName.
data(), 6);
1499 SD.Sec.addr = SR.getStart() - SecBlock.getAddress();
1500 SD.Sec.size = SR.getSize();
1506 DataSections.push_back({});
1507 auto &SD = DataSections.back();
1508 memset(&SD.Sec, 0,
sizeof(SD.Sec));
1509 memcpy(SD.Sec.sectname,
"__objc_imageinfo", 16);
1510 strcpy(SD.Sec.segname,
"__DATA");
1512 SD.AddFixups = [&](
size_t RecordOffset) {
1513 auto PointerEdge = getPointerEdgeKind(
G);
1517 for (
auto *
Sym :
G.external_symbols())
1518 if (
Sym->getName() == ObjCImageInfoSymbolName) {
1519 ObjCImageInfoSym =
Sym;
1522 if (!ObjCImageInfoSym)
1523 for (
auto *
Sym :
G.absolute_symbols())
1524 if (
Sym->getName() == ObjCImageInfoSymbolName) {
1525 ObjCImageInfoSym =
Sym;
1528 if (!ObjCImageInfoSym)
1529 for (
auto *
Sym :
G.defined_symbols())
1530 if (
Sym->hasName() &&
Sym->getName() == ObjCImageInfoSymbolName) {
1531 ObjCImageInfoSym =
Sym;
1532 std::optional<uint32_t>
Flags;
1534 std::lock_guard<std::mutex> Lock(PluginMutex);
1536 if (It != ObjCImageInfos.end()) {
1537 It->second.Finalized =
true;
1538 Flags = It->second.Flags;
1545 auto Content =
Sym->getBlock().getMutableContent(
G);
1547 "__objc_image_info size should have been verified already");
1552 if (!ObjCImageInfoSym)
1554 &
G.addExternalSymbol(ObjCImageInfoSymbolName, 8,
false);
1556 SecBlock.addEdge(PointerEdge,
1557 RecordOffset + ((
char *)&SD.Sec.addr - (
char *)&SD.Sec),
1558 *ObjCImageInfoSym, -SecBlock.getAddress().getValue());
1562 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsData) {
1563 if (
auto *GraphSec =
G.findSectionByName(ObjCRuntimeSectionName)) {
1564 DataSections.push_back({});
1565 AddSection(DataSections.back(), *GraphSec);
1569 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsText) {
1570 if (
auto *GraphSec =
G.findSectionByName(ObjCRuntimeSectionName)) {
1571 TextSections.push_back({});
1572 AddSection(TextSections.back(), *GraphSec);
1576 assert(ObjCRuntimeObjectSec->blocks_size() == 1 &&
1577 "Unexpected number of blocks in runtime sections object");
1583 switch (
G.getTargetTriple().getArch()) {
1597 Hdr.
ncmds = 1 + !TextSections.empty();
1604 auto SecContent = SecBlock.getAlreadyMutableContent();
1605 char *
P = SecContent.data();
1606 auto WriteMachOStruct = [&](
auto S) {
1609 memcpy(
P, &S,
sizeof(S));
1613 auto WriteSegment = [&](
StringRef Name, std::vector<SecDesc> &Secs) {
1615 memset(&SegLC, 0,
sizeof(SegLC));
1617 SegLC.
cmd = MachO::LC_SEGMENT_64;
1620 SegLC.
nsects = Secs.size();
1621 WriteMachOStruct(SegLC);
1622 for (
auto &SD : Secs) {
1624 SD.AddFixups(
P - SecContent.data());
1625 WriteMachOStruct(SD.Sec);
1629 WriteMachOStruct(Hdr);
1630 if (!TextSections.empty())
1631 WriteSegment(
"__TEXT", TextSections);
1632 if (!DataSections.empty())
1633 WriteSegment(
"__DATA", DataSections);
1635 assert(
P == SecContent.end() &&
"Underflow writing ObjC runtime object");
1639Error MachOPlatform::MachOPlatformPlugin::prepareSymbolTableRegistration(
1645 MemProt::Read | MemProt::Exec);
1649 for (
auto *
Sym : CStringSec->symbols()) {
1662 for (
auto *
Sym :
G.defined_symbols())
1664 for (
auto *
Sym :
G.absolute_symbols())
1667 for (
auto *
Sym : SymsToProcess) {
1668 if (!
Sym->hasName())
1671 auto I = ExistingStrings.
find(
Sym->getName());
1672 if (
I == ExistingStrings.
end()) {
1673 auto &NameBlock =
G.createMutableContentBlock(
1676 auto &SymbolNameSym =
G.addAnonymousSymbol(
1677 NameBlock, 0, NameBlock.getSize(),
false,
true);
1678 JITSymTabInfo.push_back({
Sym, &SymbolNameSym});
1680 JITSymTabInfo.push_back({
Sym,
I->second});
1687Error MachOPlatform::MachOPlatformPlugin::addSymbolTableRegistration(
1689 JITSymTabVector &JITSymTabInfo,
bool InBootstrapPhase) {
1693 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1695 assert(
I != MP.JITDylibToHeaderAddr.end() &&
"No header registered for JD");
1696 assert(
I->second &&
"Null header registered for JD");
1697 HeaderAddr =
I->second;
1704 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
1705 auto &SymTab = MP.Bootstrap.load()->SymTab;
1706 for (
auto &[OriginalSymbol, NameSym] : JITSymTabInfo)
1707 SymTab.push_back({NameSym->getAddress(), OriginalSymbol->getAddress(),
1708 flagsForSymbol(*OriginalSymbol)});
1712 SymbolTableVector SymTab;
1713 for (
auto &[OriginalSymbol, NameSym] : JITSymTabInfo)
1714 SymTab.push_back({NameSym->getAddress(), OriginalSymbol->getAddress(),
1715 flagsForSymbol(*OriginalSymbol)});
1717 G.allocActions().push_back(
1718 {
cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
1719 MP.RegisterObjectSymbolTable.Addr, HeaderAddr, SymTab)),
1720 cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
1721 MP.DeregisterObjectSymbolTable.Addr, HeaderAddr, SymTab))});
1726template <
typename MachOTraits>
1736 B.Header.cputype = HdrInfo.CPUType;
1737 B.Header.cpusubtype = HdrInfo.CPUSubType;
1740 B.template addLoadCommand<MachO::LC_ID_DYLIB>(
1742 Opts.
IDDylib->CurrentVersion, Opts.
IDDylib->CompatibilityVersion);
1744 B.template addLoadCommand<MachO::LC_ID_DYLIB>(JD.
getName(), 0, 0, 0);
1747 B.template addLoadCommand<MachO::LC_BUILD_VERSION>(
1748 BV.Platform, BV.MinOS, BV.SDK,
static_cast<uint32_t>(0));
1750 B.template addLoadCommand<MachO::LC_LOAD_DYLIB>(
1751 D.Name,
D.Timestamp,
D.CurrentVersion,
D.CompatibilityVersion);
1753 B.template addLoadCommand<MachO::LC_RPATH>(
P);
1755 auto HeaderContent =
G.allocateBuffer(
B.layout());
1756 B.write(HeaderContent);
1758 return G.createContentBlock(HeaderSection, HeaderContent,
ExecutorAddr(), 8,
1766 createHeaderInterface(MOP,
std::
move(HeaderStartSymbol))),
1767 MOP(MOP), Opts(
std::
move(Opts)) {}
1770 std::unique_ptr<MaterializationResponsibility> R) {
1771 auto G = createPlatformGraph(
MOP,
"<MachOHeaderMU>");
1772 addMachOHeader(R->getTargetJITDylib(), *
G, R->getInitializerSymbol());
1779void SimpleMachOHeaderMU::addMachOHeader(
1782 auto &HeaderSection =
G.createSection(
"__header",
MemProt::Read);
1786 G.addDefinedSymbol(HeaderBlock, 0, *InitializerSymbol, HeaderBlock.getSize(),
1789 for (
auto &HS : AdditionalHeaderSymbols)
1790 G.addDefinedSymbol(HeaderBlock, HS.Offset, HS.Name, HeaderBlock.getSize(),
1801 return ::createHeaderBlock<MachO64LE>(
MOP,
Opts, JD,
G, HeaderSection);
1812 for (
auto &HS : AdditionalHeaderSymbols)
1821 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.
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.
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.
const std::string & str() const
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
An Addressable with content and edges.
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.
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.
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.
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.
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.
ObjectLinkingLayer & addPlugin(std::shared_ptr< Plugin > P)
Add a plugin.
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, 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(const char *Fmt, Ts &&...Vals) -> formatv_object< decltype(std::make_tuple(support::detail::build_format_adapter(std::forward< 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.