15#define DEBUG_TYPE "orc"
21Expected<std::shared_ptr<UnwindInfoRegistrationPlugin>>
26 auto &EPC = ES.getExecutorProcessControl();
27 if (
auto Err = EPC.getBootstrapSymbols(
28 {{Register, rt_alt::UnwindInfoManagerRegisterActionName},
29 {Deregister, rt_alt::UnwindInfoManagerDeregisterActionName}}))
30 return std::move(Err);
32 return std::make_shared<UnwindInfoRegistrationPlugin>(ES,
Register,
41 [
this](
LinkGraph &
G) {
return addUnwindInfoRegistrationActions(
G); });
44Error UnwindInfoRegistrationPlugin::addUnwindInfoRegistrationActions(
48 std::vector<Block *> CodeBlocks;
54 SecRange.Start = (*Sec.
blocks().begin())->getAddress();
56 auto R =
B->getRange();
57 SecRange.Start = std::min(SecRange.Start, R.Start);
58 SecRange.End = std::max(SecRange.End, R.End);
59 for (
auto &E :
B->edges()) {
60 if (E.getKind() != Edge::KeepAlive || !E.getTarget().isDefined())
62 auto &TargetBlock = E.getTarget().getBlock();
63 auto &TargetSection = TargetBlock.getSection();
65 CodeBlocks.push_back(&TargetBlock);
70 if (
auto *EHFrame =
G.findSectionByName(MachOEHFrameSectionName))
71 ScanUnwindInfoSection(*EHFrame, EHFrameRange);
73 if (
auto *UnwindInfo =
G.findSectionByName(MachOUnwindInfoSectionName))
74 ScanUnwindInfoSection(*UnwindInfo, UnwindInfoRange);
76 if (CodeBlocks.empty())
79 if ((EHFrameRange == ExecutorAddrRange() &&
80 UnwindInfoRange == ExecutorAddrRange()))
84 return LHS->getAddress() <
RHS->getAddress();
88 for (
auto *
B : CodeBlocks) {
89 if (CodeRanges.empty() || CodeRanges.back().End !=
B->getAddress())
90 CodeRanges.push_back(
B->getRange());
92 CodeRanges.back().End =
B->getRange().End;
96 if (
auto *DSOBaseSym =
G.findAbsoluteSymbolByName(DSOBaseName))
97 DSOBase = DSOBaseSym->getAddress();
98 else if (
auto *DSOBaseSym =
G.findExternalSymbolByName(DSOBaseName))
99 DSOBase = DSOBaseSym->getAddress();
100 else if (
auto *DSOBaseSym =
G.findDefinedSymbolByName(DSOBaseName))
101 DSOBase = DSOBaseSym->getAddress();
104 " could not find dso base symbol",
107 using namespace shared;
108 using SPSRegisterArgs =
109 SPSArgList<SPSSequence<SPSExecutorAddrRange>, SPSExecutorAddr,
111 using SPSDeregisterArgs = SPSArgList<SPSSequence<SPSExecutorAddrRange>>;
113 G.allocActions().push_back(
114 {
cantFail(WrapperFunctionCall::Create<SPSRegisterArgs>(
115 Register, CodeRanges, DSOBase, EHFrameRange, UnwindInfoRange)),
116 cantFail(WrapperFunctionCall::Create<SPSDeregisterArgs>(Deregister,
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Module.h This file contains the declarations for the Module class.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Wrapper class representing virtual and physical registers.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represents an object file section.
iterator_range< block_iterator > blocks()
Returns an iterator over the blocks defined in this section.
bool empty() const
Returns true if this section is empty (contains no blocks or symbols).
An ExecutionSession represents a running JIT program.
Represents an address in the executor process.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::PassConfiguration &PassConfig) override
static Expected< std::shared_ptr< UnwindInfoRegistrationPlugin > > Create(ExecutionSession &ES, ExecutorAddr Register, ExecutorAddr Deregister)
SPSTuple< SPSExecutorAddr, SPSExecutorAddr > SPSExecutorAddrRange
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
void sort(IteratorTy Start, IteratorTy End)
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...
LinkGraphPassList PostFixupPasses
Post-fixup passes.
Represents an address range in the exceutor process.