#include "llvm/ExecutionEngine/Orc/MachOPlatform.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/ExecutionEngine/JITLink/MachO.h"
#include "llvm/ExecutionEngine/JITLink/aarch64.h"
#include "llvm/ExecutionEngine/JITLink/x86_64.h"
#include "llvm/ExecutionEngine/Orc/DebugUtils.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
#include "llvm/ExecutionEngine/Orc/LookupAndRecordAddrs.h"
#include "llvm/ExecutionEngine/Orc/MachOBuilder.h"
#include "llvm/ExecutionEngine/Orc/Shared/ObjectFormats.h"
#include "llvm/Support/BinaryByteStream.h"
#include "llvm/Support/Debug.h"
#include <optional>
#define DEBUG_TYPE …
usingnamespacellvm;
usingnamespacellvm::orc;
usingnamespacellvm::orc::shared;
namespace llvm {
namespace orc {
namespace shared {
SPSMachOJITDylibDepInfo;
SPSMachOJITDylibDepInfoMap;
class SPSMachOExecutorSymbolFlags;
template <>
class SPSSerializationTraits<SPSMachOJITDylibDepInfo,
MachOPlatform::MachOJITDylibDepInfo> { … };
template <>
class SPSSerializationTraits<SPSMachOExecutorSymbolFlags,
MachOPlatform::MachOExecutorSymbolFlags> { … };
}
}
}
namespace {
SPSRegisterSymbolsArgs;
std::unique_ptr<jitlink::LinkGraph> createPlatformGraph(MachOPlatform &MOP,
std::string Name) { … }
class MachOPlatformCompleteBootstrapMaterializationUnit
: public MaterializationUnit { … };
static StringRef ObjCRuntimeObjectSectionsData[] = …;
static StringRef ObjCRuntimeObjectSectionsText[] = …;
static StringRef ObjCRuntimeObjectSectionName = …;
static StringRef ObjCImageInfoSymbolName = …;
struct ObjCImageInfoFlags { … };
}
namespace llvm {
namespace orc {
std::optional<MachOPlatform::HeaderOptions::BuildVersionOpts>
MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple(const Triple &TT,
uint32_t MinOS,
uint32_t SDK) { … }
Expected<std::unique_ptr<MachOPlatform>>
MachOPlatform::Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
std::unique_ptr<DefinitionGenerator> OrcRuntime,
HeaderOptions PlatformJDOpts,
MachOHeaderMUBuilder BuildMachOHeaderMU,
std::optional<SymbolAliasMap> RuntimeAliases) { … }
Expected<std::unique_ptr<MachOPlatform>>
MachOPlatform::Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
const char *OrcRuntimePath, HeaderOptions PlatformJDOpts,
MachOHeaderMUBuilder BuildMachOHeaderMU,
std::optional<SymbolAliasMap> RuntimeAliases) { … }
Error MachOPlatform::setupJITDylib(JITDylib &JD) { … }
Error MachOPlatform::setupJITDylib(JITDylib &JD, HeaderOptions Opts) { … }
Error MachOPlatform::teardownJITDylib(JITDylib &JD) { … }
Error MachOPlatform::notifyAdding(ResourceTracker &RT,
const MaterializationUnit &MU) { … }
Error MachOPlatform::notifyRemoving(ResourceTracker &RT) { … }
static void addAliases(ExecutionSession &ES, SymbolAliasMap &Aliases,
ArrayRef<std::pair<const char *, const char *>> AL) { … }
SymbolAliasMap MachOPlatform::standardPlatformAliases(ExecutionSession &ES) { … }
ArrayRef<std::pair<const char *, const char *>>
MachOPlatform::requiredCXXAliases() { … }
ArrayRef<std::pair<const char *, const char *>>
MachOPlatform::standardRuntimeUtilityAliases() { … }
bool MachOPlatform::supportedTarget(const Triple &TT) { … }
jitlink::Edge::Kind MachOPlatform::getPointerEdgeKind(jitlink::LinkGraph &G) { … }
MachOPlatform::MachOExecutorSymbolFlags
MachOPlatform::flagsForSymbol(jitlink::Symbol &Sym) { … }
MachOPlatform::MachOPlatform(
ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator,
HeaderOptions PlatformJDOpts, MachOHeaderMUBuilder BuildMachOHeaderMU,
Error &Err)
: … { … }
Error MachOPlatform::associateRuntimeSupportFunctions() { … }
void MachOPlatform::pushInitializersLoop(
PushInitializersSendResultFn SendResult, JITDylibSP JD) { … }
void MachOPlatform::rt_pushInitializers(PushInitializersSendResultFn SendResult,
ExecutorAddr JDHeaderAddr) { … }
void MachOPlatform::rt_pushSymbols(
PushSymbolsInSendResultFn SendResult, ExecutorAddr Handle,
const std::vector<std::pair<StringRef, bool>> &SymbolNames) { … }
Expected<uint64_t> MachOPlatform::createPThreadKey() { … }
void MachOPlatform::MachOPlatformPlugin::modifyPassConfig(
MaterializationResponsibility &MR, jitlink::LinkGraph &LG,
jitlink::PassConfiguration &Config) { … }
Error MachOPlatform::MachOPlatformPlugin::bootstrapPipelineStart(
jitlink::LinkGraph &G) { … }
Error MachOPlatform::MachOPlatformPlugin::
bootstrapPipelineRecordRuntimeFunctions(jitlink::LinkGraph &G) { … }
Error MachOPlatform::MachOPlatformPlugin::bootstrapPipelineEnd(
jitlink::LinkGraph &G) { … }
Error MachOPlatform::MachOPlatformPlugin::associateJITDylibHeaderSymbol(
jitlink::LinkGraph &G, MaterializationResponsibility &MR) { … }
Error MachOPlatform::MachOPlatformPlugin::preserveImportantSections(
jitlink::LinkGraph &G, MaterializationResponsibility &MR) { … }
Error MachOPlatform::MachOPlatformPlugin::processObjCImageInfo(
jitlink::LinkGraph &G, MaterializationResponsibility &MR) { … }
Error MachOPlatform::MachOPlatformPlugin::mergeImageInfoFlags(
jitlink::LinkGraph &G, MaterializationResponsibility &MR,
ObjCImageInfo &Info, uint32_t NewFlags) { … }
Error MachOPlatform::MachOPlatformPlugin::fixTLVSectionsAndEdges(
jitlink::LinkGraph &G, JITDylib &JD) { … }
std::optional<MachOPlatform::MachOPlatformPlugin::UnwindSections>
MachOPlatform::MachOPlatformPlugin::findUnwindSectionInfo(
jitlink::LinkGraph &G) { … }
Error MachOPlatform::MachOPlatformPlugin::registerObjectPlatformSections(
jitlink::LinkGraph &G, JITDylib &JD, bool InBootstrapPhase) { … }
Error MachOPlatform::MachOPlatformPlugin::createObjCRuntimeObject(
jitlink::LinkGraph &G) { … }
Error MachOPlatform::MachOPlatformPlugin::populateObjCRuntimeObject(
jitlink::LinkGraph &G, MaterializationResponsibility &MR) { … }
Error MachOPlatform::MachOPlatformPlugin::prepareSymbolTableRegistration(
jitlink::LinkGraph &G, JITSymTabVector &JITSymTabInfo) { … }
Error MachOPlatform::MachOPlatformPlugin::addSymbolTableRegistration(
jitlink::LinkGraph &G, MaterializationResponsibility &MR,
JITSymTabVector &JITSymTabInfo, bool InBootstrapPhase) { … }
template <typename MachOTraits>
jitlink::Block &createHeaderBlock(MachOPlatform &MOP,
const MachOPlatform::HeaderOptions &Opts,
JITDylib &JD, jitlink::LinkGraph &G,
jitlink::Section &HeaderSection) { … }
SimpleMachOHeaderMU::SimpleMachOHeaderMU(MachOPlatform &MOP,
SymbolStringPtr HeaderStartSymbol,
MachOPlatform::HeaderOptions Opts)
: … { … }
void SimpleMachOHeaderMU::materialize(
std::unique_ptr<MaterializationResponsibility> R) { … }
void SimpleMachOHeaderMU::discard(const JITDylib &JD,
const SymbolStringPtr &Sym) { … }
void SimpleMachOHeaderMU::addMachOHeader(
JITDylib &JD, jitlink::LinkGraph &G,
const SymbolStringPtr &InitializerSymbol) { … }
jitlink::Block &
SimpleMachOHeaderMU::createHeaderBlock(JITDylib &JD, jitlink::LinkGraph &G,
jitlink::Section &HeaderSection) { … }
MaterializationUnit::Interface SimpleMachOHeaderMU::createHeaderInterface(
MachOPlatform &MOP, const SymbolStringPtr &HeaderStartSymbol) { … }
MachOHeaderInfo getMachOHeaderInfoFromTriple(const Triple &TT) { … }
}
}