22#define DEBUG_TYPE "orc"
36class SPSMachOExecutorSymbolFlags;
48 return SPSMachOJITDylibDepInfo::AsArgList::serialize(OB, DDI.
Sealed,
54 return SPSMachOJITDylibDepInfo::AsArgList::deserialize(IB, DDI.
Sealed,
63 using UT = std::underlying_type_t<MachOPlatform::MachOExecutorSymbolFlags>;
91using SPSRegisterSymbolsArgs =
94 SPSMachOExecutorSymbolFlags>>>;
96std::unique_ptr<jitlink::LinkGraph> createPlatformGraph(
MachOPlatform &MOP,
99 return std::make_unique<jitlink::LinkGraph>(
100 std::move(
Name), ES.getSymbolStringPool(), ES.getTargetTriple(),
105class MachOPlatformCompleteBootstrapMaterializationUnit
108 using SymbolTableVector =
112 MachOPlatformCompleteBootstrapMaterializationUnit(
122 MOP(MOP), PlatformJDName(PlatformJDName),
123 CompleteBootstrapSymbol(std::move(CompleteBootstrapSymbol)),
124 SymTab(std::move(SymTab)), DeferredAAs(std::move(DeferredAAs)),
125 MachOHeaderAddr(MachOHeaderAddr), PlatformBootstrap(PlatformBootstrap),
126 PlatformShutdown(PlatformShutdown), RegisterJITDylib(RegisterJITDylib),
127 DeregisterJITDylib(DeregisterJITDylib),
128 RegisterObjectSymbolTable(RegisterObjectSymbolTable),
129 DeregisterObjectSymbolTable(DeregisterObjectSymbolTable) {}
132 return "MachOPlatformCompleteBootstrap";
135 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override {
136 using namespace jitlink;
137 auto G = createPlatformGraph(MOP,
"<OrcRTCompleteBootstrap>");
138 auto &PlaceholderSection =
139 G->createSection(
"__orc_rt_cplt_bs", MemProt::Read);
140 auto &PlaceholderBlock =
141 G->createZeroFillBlock(PlaceholderSection, 1,
ExecutorAddr(), 1, 0);
142 G->addDefinedSymbol(PlaceholderBlock, 0, *CompleteBootstrapSymbol, 1,
143 Linkage::Strong, Scope::Hidden,
false,
true);
146 G->allocActions().reserve(DeferredAAs.size() + 3);
149 G->allocActions().push_back(
155 G->allocActions().push_back(
158 RegisterJITDylib, PlatformJDName, MachOHeaderAddr)),
160 DeregisterJITDylib, MachOHeaderAddr))});
163 G->allocActions().push_back(
164 {
cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
165 RegisterObjectSymbolTable, MachOHeaderAddr, SymTab)),
166 cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
167 DeregisterObjectSymbolTable, MachOHeaderAddr, SymTab))});
170 std::move(DeferredAAs.begin(), DeferredAAs.end(),
171 std::back_inserter(
G->allocActions()));
182 SymbolTableVector SymTab;
193static StringRef ObjCRuntimeObjectSectionsData[] = {
201static StringRef ObjCRuntimeObjectSectionsText[] = {
208static StringRef ObjCRuntimeObjectSectionName =
209 "__llvm_jitlink_ObjCRuntimeRegistrationObject";
211static StringRef ObjCImageInfoSymbolName =
212 "__llvm_jitlink_macho_objc_imageinfo";
214struct ObjCImageInfoFlags {
217 bool HasCategoryClassProperties;
218 bool HasSignedObjCClassROs;
220 static constexpr uint32_t SIGNED_CLASS_RO = (1 << 4);
221 static constexpr uint32_t HAS_CATEGORY_CLASS_PROPERTIES = (1 << 6);
223 explicit ObjCImageInfoFlags(
uint32_t RawFlags) {
224 HasSignedObjCClassROs = RawFlags & SIGNED_CLASS_RO;
225 HasCategoryClassProperties = RawFlags & HAS_CATEGORY_CLASS_PROPERTIES;
226 SwiftABIVersion = (RawFlags >> 8) & 0xFF;
227 SwiftVersion = (RawFlags >> 16) & 0xFFFF;
232 if (HasCategoryClassProperties)
233 Result |= HAS_CATEGORY_CLASS_PROPERTIES;
234 if (HasSignedObjCClassROs)
235 Result |= SIGNED_CLASS_RO;
236 Result |= (SwiftABIVersion << 8);
237 Result |= (SwiftVersion << 16);
246std::optional<MachOPlatform::HeaderOptions::BuildVersionOpts>
252 switch (TT.getOS()) {
254 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_IOSSIMULATOR
255 : MachO::PLATFORM_IOS;
261 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_TVOSSIMULATOR
262 : MachO::PLATFORM_TVOS;
265 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_WATCHOSSIMULATOR
266 : MachO::PLATFORM_WATCHOS;
269 Platform = TT.isSimulatorEnvironment() ? MachO::PLATFORM_XROS_SIMULATOR
270 : MachO::PLATFORM_XROS;
281 std::unique_ptr<DefinitionGenerator> OrcRuntime,
284 std::optional<SymbolAliasMap> RuntimeAliases) {
289 if (!supportedTarget(ES.getTargetTriple()))
290 return make_error<StringError>(
"Unsupported MachOPlatform triple: " +
291 ES.getTargetTriple().str(),
294 auto &EPC = ES.getExecutorProcessControl();
302 return std::move(Err);
305 if (
auto Err = PlatformJD.
define(
307 {EPC.getJITDispatchInfo().JITDispatchFunction,
309 {ES.intern(
"___orc_rt_jit_dispatch_ctx"),
310 {EPC.getJITDispatchInfo().JITDispatchContext,
312 return std::move(Err);
317 ObjLinkingLayer, PlatformJD, std::move(OrcRuntime),
318 std::move(PlatformJDOpts), std::move(BuildMachOHeaderMU), Err));
320 return std::move(Err);
328 std::optional<SymbolAliasMap> RuntimeAliases) {
331 auto OrcRuntimeArchiveGenerator =
333 if (!OrcRuntimeArchiveGenerator)
334 return OrcRuntimeArchiveGenerator.takeError();
336 return Create(ObjLinkingLayer, PlatformJD,
337 std::move(*OrcRuntimeArchiveGenerator),
338 std::move(PlatformJDOpts), std::move(BuildMachOHeaderMU),
339 std::move(RuntimeAliases));
347 if (
auto Err = JD.
define(BuildMachOHeaderMU(*
this, std::move(Opts))))
350 return ES.lookup({&JD}, MachOHeaderStartSymbol).takeError();
354 std::lock_guard<std::mutex> Lock(PlatformMutex);
355 auto I = JITDylibToHeaderAddr.find(&JD);
356 if (
I != JITDylibToHeaderAddr.end()) {
357 assert(HeaderAddrToJITDylib.count(
I->second) &&
358 "HeaderAddrToJITDylib missing entry");
359 HeaderAddrToJITDylib.erase(
I->second);
360 JITDylibToHeaderAddr.erase(
I);
362 JITDylibToPThreadKey.erase(&JD);
373 RegisteredInitSymbols[&JD].add(InitSym,
376 dbgs() <<
"MachOPlatform: Registered init symbol " << *InitSym <<
" for MU "
387 ArrayRef<std::pair<const char *, const char *>> AL) {
388 for (
auto &KV : AL) {
389 auto AliasName = ES.
intern(KV.first);
390 assert(!Aliases.
count(AliasName) &&
"Duplicate symbol name in alias map");
391 Aliases[std::move(AliasName)] = {ES.
intern(KV.second),
406 static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
407 {
"___cxa_atexit",
"___orc_rt_macho_cxa_atexit"}};
414 static const std::pair<const char *, const char *>
415 StandardRuntimeUtilityAliases[] = {
416 {
"___orc_rt_run_program",
"___orc_rt_macho_run_program"},
417 {
"___orc_rt_jit_dlerror",
"___orc_rt_macho_jit_dlerror"},
418 {
"___orc_rt_jit_dlopen",
"___orc_rt_macho_jit_dlopen"},
419 {
"___orc_rt_jit_dlupdate",
"___orc_rt_macho_jit_dlupdate"},
420 {
"___orc_rt_jit_dlclose",
"___orc_rt_macho_jit_dlclose"},
421 {
"___orc_rt_jit_dlsym",
"___orc_rt_macho_jit_dlsym"},
422 {
"___orc_rt_log_error",
"___orc_rt_log_error_to_stderr"}};
425 StandardRuntimeUtilityAliases);
430 static const std::pair<const char *, const char *>
431 StandardLazyCompilationAliases[] = {
432 {
"__orc_rt_reenter",
"__orc_rt_sysv_reenter"},
433 {
"__orc_rt_resolve_tag",
"___orc_rt_resolve_tag"}};
436 StandardLazyCompilationAliases);
439bool MachOPlatform::supportedTarget(
const Triple &TT) {
440 switch (TT.getArch()) {
450 switch (
G.getTargetTriple().getArch()) {
466 if (
Sym.isCallable())
472MachOPlatform::MachOPlatform(
474 std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator,
478 ObjLinkingLayer(ObjLinkingLayer),
479 BuildMachOHeaderMU(
std::
move(BuildMachOHeaderMU)) {
481 ObjLinkingLayer.
addPlugin(std::make_unique<MachOPlatformPlugin>(*
this));
482 PlatformJD.
addGenerator(std::move(OrcRuntimeGenerator));
486 std::optional<bool> ForceEHFrames;
490 this->ForceEHFrames = ForceEHFrames.has_value() ? *ForceEHFrames :
false;
551 if ((Err = PlatformJD.
define(
552 this->BuildMachOHeaderMU(*
this, std::move(PlatformJDOpts)))))
554 if ((Err = ES.
lookup(&PlatformJD, MachOHeaderStartSymbol).takeError()))
561 {PlatformBootstrap.Name, PlatformShutdown.Name,
562 RegisterJITDylib.Name, DeregisterJITDylib.Name,
563 RegisterObjectSymbolTable.Name,
564 DeregisterObjectSymbolTable.Name,
565 RegisterObjectPlatformSections.Name,
566 DeregisterObjectPlatformSections.Name,
567 CreatePThreadKey.Name}))
573 std::unique_lock<std::mutex> Lock(BI.Mutex);
574 BI.CV.wait(Lock, [&]() {
return BI.ActiveGraphs == 0; });
579 auto BootstrapCompleteSymbol = ES.
intern(
"__orc_rt_macho_complete_bootstrap");
580 if ((Err = PlatformJD.
define(
581 std::make_unique<MachOPlatformCompleteBootstrapMaterializationUnit>(
582 *
this, PlatformJD.
getName(), BootstrapCompleteSymbol,
583 std::move(BI.SymTab), std::move(BI.DeferredAAs),
584 BI.MachOHeaderAddr, PlatformBootstrap.Addr,
585 PlatformShutdown.Addr, RegisterJITDylib.Addr,
586 DeregisterJITDylib.Addr, RegisterObjectSymbolTable.Addr,
587 DeregisterObjectSymbolTable.Addr))))
591 std::move(BootstrapCompleteSymbol))
602 if ((Err = associateRuntimeSupportFunctions()))
606Error MachOPlatform::associateRuntimeSupportFunctions() {
609 using PushInitializersSPSSig =
611 WFs[ES.
intern(
"___orc_rt_macho_push_initializers_tag")] =
613 this, &MachOPlatform::rt_pushInitializers);
615 using PushSymbolsSPSSig =
617 WFs[ES.
intern(
"___orc_rt_macho_push_symbols_tag")] =
619 &MachOPlatform::rt_pushSymbols);
624void MachOPlatform::pushInitializersLoop(
625 PushInitializersSendResultFn SendResult,
JITDylibSP JD) {
631 while (!Worklist.empty()) {
634 auto DepJD = Worklist.back();
638 if (JDDepMap.count(DepJD))
642 auto &DM = JDDepMap[DepJD];
643 DepJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
645 if (KV.first == DepJD)
647 DM.push_back(KV.first);
648 Worklist.push_back(KV.first);
653 auto RISItr = RegisteredInitSymbols.find(DepJD);
654 if (RISItr != RegisteredInitSymbols.end()) {
655 NewInitSymbols[DepJD] = std::move(RISItr->second);
656 RegisteredInitSymbols.erase(RISItr);
663 if (NewInitSymbols.
empty()) {
672 std::lock_guard<std::mutex> Lock(PlatformMutex);
673 for (
auto &KV : JDDepMap) {
674 auto I = JITDylibToHeaderAddr.find(KV.first);
675 if (
I != JITDylibToHeaderAddr.end())
676 HeaderAddrs[KV.first] =
I->second;
681 MachOJITDylibDepInfoMap DIM;
682 DIM.reserve(JDDepMap.size());
683 for (
auto &KV : JDDepMap) {
684 auto HI = HeaderAddrs.
find(KV.first);
686 if (HI == HeaderAddrs.
end())
689 MachOJITDylibDepInfo DepInfo;
690 for (
auto &Dep : KV.second) {
691 auto HJ = HeaderAddrs.
find(Dep);
692 if (HJ != HeaderAddrs.
end())
693 DepInfo.DepHeaders.push_back(HJ->second);
695 DIM.push_back(std::make_pair(
H, std::move(DepInfo)));
702 lookupInitSymbolsAsync(
703 [
this, SendResult = std::move(SendResult), JD](
Error Err)
mutable {
705 SendResult(std::move(Err));
707 pushInitializersLoop(std::move(SendResult), JD);
709 ES, std::move(NewInitSymbols));
712void MachOPlatform::rt_pushInitializers(PushInitializersSendResultFn SendResult,
716 std::lock_guard<std::mutex> Lock(PlatformMutex);
717 auto I = HeaderAddrToJITDylib.find(JDHeaderAddr);
718 if (
I != HeaderAddrToJITDylib.end())
723 dbgs() <<
"MachOPlatform::rt_pushInitializers(" << JDHeaderAddr <<
") ";
725 dbgs() <<
"pushing initializers for " << JD->
getName() <<
"\n";
727 dbgs() <<
"No JITDylib for header address.\n";
731 SendResult(make_error<StringError>(
"No JITDylib with header addr " +
732 formatv(
"{0:x}", JDHeaderAddr),
737 pushInitializersLoop(std::move(SendResult), JD);
740void MachOPlatform::rt_pushSymbols(
741 PushSymbolsInSendResultFn SendResult,
ExecutorAddr Handle,
742 const std::vector<std::pair<StringRef, bool>> &SymbolNames) {
747 std::lock_guard<std::mutex> Lock(PlatformMutex);
748 auto I = HeaderAddrToJITDylib.find(Handle);
749 if (
I != HeaderAddrToJITDylib.end())
753 dbgs() <<
"MachOPlatform::rt_pushSymbols(";
757 dbgs() <<
"<invalid handle " << Handle <<
">, [ ";
758 for (
auto &
Name : SymbolNames)
759 dbgs() <<
"\"" <<
Name.first <<
"\" ";
764 SendResult(make_error<StringError>(
"No JITDylib associated with handle " +
773 ? SymbolLookupFlags::RequiredSymbol
774 : SymbolLookupFlags::WeaklyReferencedSymbol);
777 LookupKind::DLSym, {{JD, JITDylibLookupFlags::MatchExportedSymbolsOnly}},
778 std::move(LS), SymbolState::Ready,
780 SendResult(
Result.takeError());
786 if (!CreatePThreadKey.Addr)
787 return make_error<StringError>(
788 "Attempting to create pthread key in target, but runtime support has "
789 "not been loaded yet",
794 CreatePThreadKey.Addr,
Result))
795 return std::move(Err);
799void MachOPlatform::MachOPlatformPlugin::modifyPassConfig(
803 using namespace jitlink;
805 bool InBootstrapPhase =
false;
809 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
812 InBootstrapPhase =
true;
813 ++MP.Bootstrap->ActiveGraphs;
819 if (
I != MP.JITDylibToHeaderAddr.end())
820 HeaderAddr =
I->second;
825 if (MP.ForceEHFrames)
834 Linkage::Strong, Scope::Local,
true);
838 Config.PostAllocationPasses.push_back([
this](LinkGraph &
G) {
839 return bootstrapPipelineRecordRuntimeFunctions(
G);
848 if (InitSymbol == MP.MachOHeaderStartSymbol && !InBootstrapPhase) {
849 Config.PostAllocationPasses.push_back([
this, &MR](LinkGraph &
G) {
850 return associateJITDylibHeaderSymbol(
G, MR);
858 Config.PrePrunePasses.push_back([
this, &MR](LinkGraph &
G) {
859 if (
auto Err = preserveImportantSections(
G, MR))
861 return processObjCImageInfo(
G, MR);
863 Config.PostPrunePasses.push_back(
864 [
this](LinkGraph &
G) {
return createObjCRuntimeObject(
G); });
865 Config.PostAllocationPasses.push_back(
866 [
this, &MR](LinkGraph &
G) {
return populateObjCRuntimeObject(
G, MR); });
871 Config.PostPrunePasses.insert(
872 Config.PostPrunePasses.begin(),
874 return fixTLVSectionsAndEdges(
G, JD);
880 auto JITSymTabInfo = std::make_shared<JITSymTabVector>();
881 Config.PostPrunePasses.push_back([
this, JITSymTabInfo](LinkGraph &
G) {
882 return prepareSymbolTableRegistration(
G, *JITSymTabInfo);
884 Config.PostFixupPasses.push_back([
this, &MR, JITSymTabInfo,
885 InBootstrapPhase](LinkGraph &
G) {
886 return addSymbolTableRegistration(
G, MR, *JITSymTabInfo, InBootstrapPhase);
893 InBootstrapPhase](LinkGraph &
G) {
894 return registerObjectPlatformSections(
G, JD, HeaderAddr, InBootstrapPhase);
899 if (InBootstrapPhase)
900 Config.PostFixupPasses.push_back(
901 [
this](LinkGraph &
G) {
return bootstrapPipelineEnd(
G); });
904Error MachOPlatform::MachOPlatformPlugin::
907 std::pair<StringRef, ExecutorAddr *> RuntimeSymbols[] = {
908 {*MP.MachOHeaderStartSymbol, &MP.Bootstrap->MachOHeaderAddr},
909 {*MP.PlatformBootstrap.Name, &MP.PlatformBootstrap.Addr},
910 {*MP.PlatformShutdown.Name, &MP.PlatformShutdown.Addr},
911 {*MP.RegisterJITDylib.Name, &MP.RegisterJITDylib.Addr},
912 {*MP.DeregisterJITDylib.Name, &MP.DeregisterJITDylib.Addr},
913 {*MP.RegisterObjectSymbolTable.Name, &MP.RegisterObjectSymbolTable.Addr},
914 {*MP.DeregisterObjectSymbolTable.Name,
915 &MP.DeregisterObjectSymbolTable.Addr},
916 {*MP.RegisterObjectPlatformSections.Name,
917 &MP.RegisterObjectPlatformSections.Addr},
918 {*MP.DeregisterObjectPlatformSections.Name,
919 &MP.DeregisterObjectPlatformSections.Addr},
920 {*MP.CreatePThreadKey.Name, &MP.CreatePThreadKey.Addr},
921 {*MP.RegisterObjCRuntimeObject.Name, &MP.RegisterObjCRuntimeObject.Addr},
922 {*MP.DeregisterObjCRuntimeObject.Name,
923 &MP.DeregisterObjCRuntimeObject.Addr}};
925 bool RegisterMachOHeader =
false;
927 for (
auto *
Sym :
G.defined_symbols()) {
928 for (
auto &RTSym : RuntimeSymbols) {
929 if (
Sym->hasName() && *
Sym->getName() == RTSym.first) {
931 return make_error<StringError>(
932 "Duplicate " + RTSym.first +
933 " detected during MachOPlatform bootstrap",
936 if (
Sym->getName() == MP.MachOHeaderStartSymbol)
937 RegisterMachOHeader =
true;
939 *RTSym.second =
Sym->getAddress();
944 if (RegisterMachOHeader) {
947 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
948 MP.JITDylibToHeaderAddr[&MP.PlatformJD] = MP.Bootstrap->MachOHeaderAddr;
949 MP.HeaderAddrToJITDylib[MP.Bootstrap->MachOHeaderAddr] = &MP.PlatformJD;
955Error MachOPlatform::MachOPlatformPlugin::bootstrapPipelineEnd(
957 std::lock_guard<std::mutex> Lock(MP.Bootstrap->Mutex);
959 --MP.Bootstrap->ActiveGraphs;
962 if (MP.Bootstrap->ActiveGraphs == 0)
963 MP.Bootstrap->CV.notify_all();
967Error MachOPlatform::MachOPlatformPlugin::associateJITDylibHeaderSymbol(
970 return Sym->getName() == MP.MachOHeaderStartSymbol;
972 assert(
I !=
G.defined_symbols().end() &&
"Missing MachO header start symbol");
975 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
976 auto HeaderAddr = (*I)->getAddress();
977 MP.JITDylibToHeaderAddr[&JD] = HeaderAddr;
978 MP.HeaderAddrToJITDylib[HeaderAddr] = &JD;
981 G.allocActions().push_back(
984 MP.RegisterJITDylib.Addr, JD.
getName(), HeaderAddr)),
986 MP.DeregisterJITDylib.Addr, HeaderAddr))});
990Error MachOPlatform::MachOPlatformPlugin::preserveImportantSections(
996 if (
auto *ObjCImageInfoSec =
998 if (ObjCImageInfoSec->blocks_size() != 1)
999 return make_error<StringError>(
1000 "In " +
G.getName() +
1001 "__DATA,__objc_imageinfo contains multiple blocks",
1003 G.addAnonymousSymbol(**ObjCImageInfoSec->blocks().begin(), 0, 0,
false,
1006 for (
auto *
B : ObjCImageInfoSec->blocks())
1007 if (!
B->edges_empty())
1008 return make_error<StringError>(
"In " +
G.getName() +
", " +
1010 " contains references to symbols",
1027 auto *InitSection =
G.findSectionByName(InitSectionName);
1028 if (!InitSection || InitSection->empty())
1034 auto &
B = **InitSection->blocks().begin();
1035 InitSym = &
G.addDefinedSymbol(
1041 for (
auto *
B : InitSection->blocks()) {
1045 auto &S =
G.addAnonymousSymbol(*
B, 0,
B->getSize(),
false,
true);
1054Error MachOPlatform::MachOPlatformPlugin::processObjCImageInfo(
1067 auto ObjCImageInfoBlocks = ObjCImageInfo->blocks();
1070 if (ObjCImageInfoBlocks.empty())
1072 " section in " +
G.getName(),
1076 if (std::next(ObjCImageInfoBlocks.begin()) != ObjCImageInfoBlocks.end())
1077 return make_error<StringError>(
"Multiple blocks in " +
1079 " section in " +
G.getName(),
1084 for (
auto &Sec :
G.sections()) {
1085 if (&Sec != ObjCImageInfo)
1086 for (
auto *
B : Sec.blocks())
1087 for (
auto &E :
B->edges())
1088 if (E.getTarget().isDefined() &&
1089 &E.getTarget().getSection() == ObjCImageInfo)
1091 " is referenced within file " +
1096 auto &ObjCImageInfoBlock = **ObjCImageInfoBlocks.begin();
1097 auto *ObjCImageInfoData = ObjCImageInfoBlock.getContent().data();
1103 std::lock_guard<std::mutex> Lock(PluginMutex);
1106 if (ObjCImageInfoItr != ObjCImageInfos.end()) {
1109 if (ObjCImageInfoItr->second.Version !=
Version)
1110 return make_error<StringError>(
1111 "ObjC version in " +
G.getName() +
1112 " does not match first registered version",
1114 if (ObjCImageInfoItr->second.Flags != Flags)
1115 if (
Error E = mergeImageInfoFlags(
G, MR, ObjCImageInfoItr->second, Flags))
1119 for (
auto *S : ObjCImageInfo->symbols())
1120 G.removeDefinedSymbol(*S);
1121 G.removeBlock(ObjCImageInfoBlock);
1124 dbgs() <<
"MachOPlatform: Registered __objc_imageinfo for "
1126 <<
"; flags = " <<
formatv(
"{0:x4}", Flags) <<
"\n";
1130 G.addDefinedSymbol(ObjCImageInfoBlock, 0, ObjCImageInfoSymbolName,
1134 {{MR.getExecutionSession().intern(ObjCImageInfoSymbolName),
1135 JITSymbolFlags()}}))
1143Error MachOPlatform::MachOPlatformPlugin::mergeImageInfoFlags(
1145 ObjCImageInfo &Info,
uint32_t NewFlags) {
1146 if (
Info.Flags == NewFlags)
1149 ObjCImageInfoFlags Old(
Info.Flags);
1150 ObjCImageInfoFlags
New(NewFlags);
1153 if (Old.SwiftABIVersion &&
New.SwiftABIVersion &&
1154 Old.SwiftABIVersion !=
New.SwiftABIVersion)
1155 return make_error<StringError>(
"Swift ABI version in " +
G.getName() +
1156 " does not match first registered flags",
1162 if (
Info.Finalized && Old.HasCategoryClassProperties &&
1163 !
New.HasCategoryClassProperties)
1164 return make_error<StringError>(
"ObjC category class property support in " +
1166 " does not match first registered flags",
1168 if (
Info.Finalized && Old.HasSignedObjCClassROs && !
New.HasSignedObjCClassROs)
1169 return make_error<StringError>(
"ObjC class_ro_t pointer signing in " +
1171 " does not match first registered flags",
1180 if (Old.SwiftVersion &&
New.SwiftVersion)
1181 New.SwiftVersion = std::min(Old.SwiftVersion,
New.SwiftVersion);
1182 else if (Old.SwiftVersion)
1183 New.SwiftVersion = Old.SwiftVersion;
1185 if (!
New.SwiftABIVersion)
1186 New.SwiftABIVersion = Old.SwiftABIVersion;
1188 if (Old.HasCategoryClassProperties !=
New.HasCategoryClassProperties)
1189 New.HasCategoryClassProperties =
false;
1191 if (Old.HasSignedObjCClassROs !=
New.HasSignedObjCClassROs)
1192 New.HasSignedObjCClassROs =
false;
1195 dbgs() <<
"MachOPlatform: Merging __objc_imageinfo flags for "
1197 <<
formatv(
"{0:x4}", Old.rawFlags()) <<
")"
1198 <<
" with " <<
G.getName() <<
" (" <<
formatv(
"{0:x4}", NewFlags)
1200 <<
" -> " <<
formatv(
"{0:x4}",
New.rawFlags()) <<
"\n";
1207Error MachOPlatform::MachOPlatformPlugin::fixTLVSectionsAndEdges(
1209 auto TLVBootStrapSymbolName =
G.intern(
"__tlv_bootstrap");
1211 for (
auto *
Sym :
G.external_symbols())
1212 if (
Sym->getName() == TLVBootStrapSymbolName) {
1214 MP.getExecutionSession().intern(
"___orc_rt_macho_tlv_get_addr");
1215 Sym->setName(std::move(TLSGetADDR));
1221 std::optional<uint64_t>
Key;
1223 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1224 auto I = MP.JITDylibToPThreadKey.find(&JD);
1225 if (
I != MP.JITDylibToPThreadKey.end())
1230 if (
auto KeyOrErr = MP.createPThreadKey())
1233 return KeyOrErr.takeError();
1239 for (
auto *
B : ThreadDataSec->blocks()) {
1240 if (
B->getSize() != 3 *
G.getPointerSize())
1241 return make_error<StringError>(
"__thread_vars block at " +
1242 formatv(
"{0:x}",
B->getAddress()) +
1243 " has unexpected size",
1246 auto NewBlockContent =
G.allocateBuffer(
B->getSize());
1247 llvm::copy(
B->getContent(), NewBlockContent.data());
1248 memcpy(NewBlockContent.data() +
G.getPointerSize(), &PlatformKeyBits,
1249 G.getPointerSize());
1250 B->setContent(NewBlockContent);
1255 for (
auto *
B :
G.blocks())
1256 for (
auto &E :
B->edges())
1259 E.setKind(jitlink::x86_64::
1260 RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable);
1265std::optional<MachOPlatform::MachOPlatformPlugin::UnwindSections>
1266MachOPlatform::MachOPlatformPlugin::findUnwindSectionInfo(
1268 using namespace jitlink;
1276 auto AddCodeBlocks) {
1277 if (Sec.blocks().empty())
1279 SecRange = (*Sec.blocks().begin())->
getRange();
1280 for (
auto *
B : Sec.blocks()) {
1281 auto R =
B->getRange();
1282 SecRange.Start = std::min(SecRange.Start,
R.Start);
1283 SecRange.End = std::max(SecRange.End,
R.End);
1289 ScanUnwindInfoSection(*EHFrameSec, US.DwarfSection, [&](
Block &
B) {
1290 if (auto *Fn = jitlink::EHFrameCFIBlockInspector::FromEdgeScan(B)
1292 if (Fn->getTarget().isDefined())
1293 CodeBlocks.push_back(&Fn->getTarget().getBlock());
1298 ScanUnwindInfoSection(
1299 *CUInfoSec, US.CompactUnwindSection, [&](
Block &
B) {
1300 for (auto &E : B.edges()) {
1301 assert(E.getTarget().isDefined() &&
1302 "unwind-info record edge has external target");
1303 assert(E.getKind() == Edge::KeepAlive &&
1304 "unwind-info record has unexpected edge kind");
1305 CodeBlocks.push_back(&E.getTarget().getBlock());
1312 if (CodeBlocks.
empty())
1313 return std::nullopt;
1318 return LHS->getAddress() <
RHS->getAddress();
1320 for (
auto *
B : CodeBlocks) {
1321 if (US.CodeRanges.empty() || US.CodeRanges.back().End !=
B->getAddress())
1322 US.CodeRanges.push_back(
B->getRange());
1324 US.CodeRanges.back().End =
B->getRange().End;
1328 dbgs() <<
"MachOPlatform identified unwind info in " <<
G.getName() <<
":\n"
1330 if (US.DwarfSection.Start)
1331 dbgs() << US.DwarfSection <<
"\n";
1334 dbgs() <<
" Compact-unwind: ";
1335 if (US.CompactUnwindSection.Start)
1336 dbgs() << US.CompactUnwindSection <<
"\n";
1339 <<
"for code ranges:\n";
1340 for (
auto &CR : US.CodeRanges)
1341 dbgs() <<
" " << CR <<
"\n";
1342 if (US.CodeRanges.size() >=
G.sections_size())
1343 dbgs() <<
"WARNING: High number of discontiguous code ranges! "
1344 "Padding may be interfering with coalescing.\n";
1350Error MachOPlatform::MachOPlatformPlugin::registerObjectPlatformSections(
1352 bool InBootstrapPhase) {
1364 if (ThreadDataSection)
1365 G.mergeSections(*ThreadDataSection, *ThreadBSSSection);
1367 ThreadDataSection = ThreadBSSSection;
1376 for (
auto &SecName : DataSections) {
1377 if (
auto *Sec =
G.findSectionByName(SecName)) {
1380 MachOPlatformSecs.
push_back({SecName,
R.getRange()});
1386 if (ThreadDataSection) {
1395 ObjCRuntimeObjectSectionName};
1397 for (
auto &SecName : PlatformSections) {
1398 auto *Sec =
G.findSectionByName(SecName);
1405 MachOPlatformSecs.
push_back({SecName,
R.getRange()});
1411 if (
auto UI = findUnwindSectionInfo(
G))
1412 UnwindInfo = std::make_tuple(std::move(UI->CodeRanges), UI->DwarfSection,
1413 UI->CompactUnwindSection);
1415 if (!MachOPlatformSecs.
empty() || UnwindInfo) {
1418 dbgs() <<
"MachOPlatform: Scraped " <<
G.getName() <<
" init sections:\n";
1419 for (
auto &KV : MachOPlatformSecs)
1420 dbgs() <<
" " << KV.first <<
": " << KV.second <<
"\n";
1423 assert(HeaderAddr &&
"Null header registered for JD");
1424 using SPSRegisterObjectPlatformSectionsArgs =
SPSArgList<
1432 WrapperFunctionCall::Create<SPSRegisterObjectPlatformSectionsArgs>(
1433 MP.RegisterObjectPlatformSections.Addr, HeaderAddr, UnwindInfo,
1434 MachOPlatformSecs)),
1436 WrapperFunctionCall::Create<SPSRegisterObjectPlatformSectionsArgs>(
1437 MP.DeregisterObjectPlatformSections.Addr, HeaderAddr,
1438 UnwindInfo, MachOPlatformSecs))};
1443 std::lock_guard<std::mutex> Lock(MP.Bootstrap->Mutex);
1444 MP.Bootstrap->DeferredAAs.push_back(std::move(
AllocActions));
1451Error MachOPlatform::MachOPlatformPlugin::createObjCRuntimeObject(
1454 bool NeedTextSegment =
false;
1455 size_t NumRuntimeSections = 0;
1457 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsData)
1458 if (
G.findSectionByName(ObjCRuntimeSectionName))
1459 ++NumRuntimeSections;
1461 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsText) {
1462 if (
G.findSectionByName(ObjCRuntimeSectionName)) {
1463 ++NumRuntimeSections;
1464 NeedTextSegment =
true;
1469 if (NumRuntimeSections == 0)
1474 ++NumRuntimeSections;
1480 auto &Sec =
G.createSection(ObjCRuntimeObjectSectionName,
1481 MemProt::Read | MemProt::Write);
1482 G.createMutableContentBlock(Sec, MachOSize,
ExecutorAddr(), 16, 0,
true);
1487Error MachOPlatform::MachOPlatformPlugin::populateObjCRuntimeObject(
1490 auto *ObjCRuntimeObjectSec =
1491 G.findSectionByName(ObjCRuntimeObjectSectionName);
1493 if (!ObjCRuntimeObjectSec)
1496 switch (
G.getTargetTriple().getArch()) {
1502 return make_error<StringError>(
"Unrecognized MachO arch in triple " +
1503 G.getTargetTriple().str(),
1507 auto &SecBlock = **ObjCRuntimeObjectSec->blocks().begin();
1514 std::vector<SecDesc> TextSections, DataSections;
1520 memcpy(SD.Sec.segname, FQName.
data(), 6);
1521 SD.Sec.addr = SR.getStart() - SecBlock.getAddress();
1522 SD.Sec.size = SR.getSize();
1528 DataSections.push_back({});
1529 auto &SD = DataSections.back();
1530 memset(&SD.Sec, 0,
sizeof(SD.Sec));
1531 memcpy(SD.Sec.sectname,
"__objc_imageinfo", 16);
1532 strcpy(SD.Sec.segname,
"__DATA");
1535 SD.AddFixups = [&, ObjCImageInfoSym](
size_t RecordOffset)
mutable {
1536 auto PointerEdge = getPointerEdgeKind(
G);
1539 if (!ObjCImageInfoSym) {
1540 auto Name =
G.intern(ObjCImageInfoSymbolName);
1541 ObjCImageInfoSym =
G.findExternalSymbolByName(
Name);
1542 if (!ObjCImageInfoSym)
1543 ObjCImageInfoSym =
G.findAbsoluteSymbolByName(
Name);
1544 if (!ObjCImageInfoSym) {
1545 ObjCImageInfoSym =
G.findDefinedSymbolByName(
Name);
1546 if (ObjCImageInfoSym) {
1547 std::optional<uint32_t>
Flags;
1549 std::lock_guard<std::mutex> Lock(PluginMutex);
1551 if (It != ObjCImageInfos.end()) {
1552 It->second.Finalized =
true;
1553 Flags = It->second.Flags;
1563 "__objc_image_info size should have been verified already");
1568 if (!ObjCImageInfoSym)
1569 ObjCImageInfoSym = &
G.addExternalSymbol(std::move(
Name), 8,
false);
1572 SecBlock.addEdge(PointerEdge,
1573 RecordOffset + ((
char *)&SD.Sec.addr - (
char *)&SD.Sec),
1574 *ObjCImageInfoSym, -SecBlock.getAddress().getValue());
1578 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsData) {
1579 if (
auto *GraphSec =
G.findSectionByName(ObjCRuntimeSectionName)) {
1580 DataSections.push_back({});
1581 AddSection(DataSections.back(), *GraphSec);
1585 for (
auto ObjCRuntimeSectionName : ObjCRuntimeObjectSectionsText) {
1586 if (
auto *GraphSec =
G.findSectionByName(ObjCRuntimeSectionName)) {
1587 TextSections.push_back({});
1588 AddSection(TextSections.back(), *GraphSec);
1592 assert(ObjCRuntimeObjectSec->blocks_size() == 1 &&
1593 "Unexpected number of blocks in runtime sections object");
1599 switch (
G.getTargetTriple().getArch()) {
1613 Hdr.
ncmds = 1 + !TextSections.empty();
1620 auto SecContent = SecBlock.getAlreadyMutableContent();
1621 char *
P = SecContent.data();
1622 auto WriteMachOStruct = [&](
auto S) {
1625 memcpy(
P, &S,
sizeof(S));
1629 auto WriteSegment = [&](
StringRef Name, std::vector<SecDesc> &Secs) {
1631 memset(&SegLC, 0,
sizeof(SegLC));
1633 SegLC.
cmd = MachO::LC_SEGMENT_64;
1636 SegLC.
nsects = Secs.size();
1637 WriteMachOStruct(SegLC);
1638 for (
auto &SD : Secs) {
1640 SD.AddFixups(
P - SecContent.data());
1641 WriteMachOStruct(SD.Sec);
1645 WriteMachOStruct(Hdr);
1646 if (!TextSections.empty())
1647 WriteSegment(
"__TEXT", TextSections);
1648 if (!DataSections.empty())
1649 WriteSegment(
"__DATA", DataSections);
1651 assert(
P == SecContent.end() &&
"Underflow writing ObjC runtime object");
1655Error MachOPlatform::MachOPlatformPlugin::prepareSymbolTableRegistration(
1661 MemProt::Read | MemProt::Exec);
1665 for (
auto *
Sym : CStringSec->symbols()) {
1678 for (
auto *
Sym :
G.defined_symbols())
1680 for (
auto *
Sym :
G.absolute_symbols())
1683 for (
auto *
Sym : SymsToProcess) {
1684 if (!
Sym->hasName())
1687 auto I = ExistingStrings.
find(*
Sym->getName());
1688 if (
I == ExistingStrings.
end()) {
1689 auto &NameBlock =
G.createMutableContentBlock(
1690 *CStringSec,
G.allocateCString(*
Sym->getName()),
1692 auto &SymbolNameSym =
G.addAnonymousSymbol(
1693 NameBlock, 0, NameBlock.getSize(),
false,
true);
1694 JITSymTabInfo.push_back({
Sym, &SymbolNameSym});
1696 JITSymTabInfo.push_back({
Sym,
I->second});
1703Error MachOPlatform::MachOPlatformPlugin::addSymbolTableRegistration(
1705 JITSymTabVector &JITSymTabInfo,
bool InBootstrapPhase) {
1709 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1711 assert(
I != MP.JITDylibToHeaderAddr.end() &&
"No header registered for JD");
1712 assert(
I->second &&
"Null header registered for JD");
1713 HeaderAddr =
I->second;
1720 std::lock_guard<std::mutex> Lock(MP.Bootstrap->Mutex);
1721 auto &SymTab = MP.Bootstrap->SymTab;
1722 for (
auto &[OriginalSymbol, NameSym] : JITSymTabInfo)
1723 SymTab.push_back({NameSym->getAddress(), OriginalSymbol->getAddress(),
1724 flagsForSymbol(*OriginalSymbol)});
1728 SymbolTableVector SymTab;
1729 for (
auto &[OriginalSymbol, NameSym] : JITSymTabInfo)
1730 SymTab.push_back({NameSym->getAddress(), OriginalSymbol->getAddress(),
1731 flagsForSymbol(*OriginalSymbol)});
1733 G.allocActions().push_back(
1734 {
cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
1735 MP.RegisterObjectSymbolTable.Addr, HeaderAddr, SymTab)),
1736 cantFail(WrapperFunctionCall::Create<SPSRegisterSymbolsArgs>(
1737 MP.DeregisterObjectSymbolTable.Addr, HeaderAddr, SymTab))});
1742template <
typename MachOTraits>
1752 B.Header.cputype = HdrInfo.CPUType;
1753 B.Header.cpusubtype = HdrInfo.CPUSubType;
1756 B.template addLoadCommand<MachO::LC_ID_DYLIB>(
1758 Opts.
IDDylib->CurrentVersion, Opts.
IDDylib->CompatibilityVersion);
1760 B.template addLoadCommand<MachO::LC_ID_DYLIB>(JD.
getName(), 0, 0, 0);
1763 B.template addLoadCommand<MachO::LC_BUILD_VERSION>(
1764 BV.Platform, BV.MinOS, BV.SDK,
static_cast<uint32_t>(0));
1766 B.template addLoadCommand<MachO::LC_LOAD_DYLIB>(
1767 D.Name,
D.Timestamp,
D.CurrentVersion,
D.CompatibilityVersion);
1769 B.template addLoadCommand<MachO::LC_RPATH>(
P);
1771 auto HeaderContent =
G.allocateBuffer(
B.layout());
1772 B.write(HeaderContent);
1774 return G.createContentBlock(HeaderSection, HeaderContent,
ExecutorAddr(), 8,
1782 createHeaderInterface(MOP,
std::
move(HeaderStartSymbol))),
1783 MOP(MOP), Opts(
std::
move(Opts)) {}
1786 std::unique_ptr<MaterializationResponsibility> R) {
1787 auto G = createPlatformGraph(
MOP,
"<MachOHeaderMU>");
1788 addMachOHeader(R->getTargetJITDylib(), *
G, R->getInitializerSymbol());
1795void SimpleMachOHeaderMU::addMachOHeader(
1798 auto &HeaderSection =
G.createSection(
"__header",
MemProt::Read);
1802 G.addDefinedSymbol(HeaderBlock, 0, *InitializerSymbol, HeaderBlock.getSize(),
1805 for (
auto &HS : AdditionalHeaderSymbols)
1806 G.addDefinedSymbol(HeaderBlock, HS.Offset, HS.Name, HeaderBlock.getSize(),
1817 return ::createHeaderBlock<MachO64LE>(
MOP,
Opts, JD,
G, HeaderSection);
1828 for (
auto &HS : AdditionalHeaderSymbols)
1837 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).
Manages the enabling and disabling of subtarget specific features.
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.
MutableArrayRef< char > getMutableContent(LinkGraph &G)
Get mutable content for this block.
const std::string & getName() const
Get the name for this JITLinkDylib.
void removeSection(Section &Sec)
Remove a section.
Section * findSectionByName(StringRef Name)
Returns the section with the given name if it exists, otherwise returns null.
Symbol & addAbsoluteSymbol(orc::SymbolStringPtr Name, orc::ExecutorAddr Address, orc::ExecutorAddrDiff Size, Linkage L, Scope S, bool IsLive)
Add an absolute symbol.
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...
Error getBootstrapMapValue(StringRef Key, std::optional< T > &Val) const
Look up and SPS-deserialize a bootstrap map value.
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)
@ 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.
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...
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 MachOCompactUnwindSectionName
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 MachOUnwindInfoSectionName
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.
A pair of WrapperFunctionCalls, one to be run at finalization time, one to be run at deallocation tim...