15#define DEBUG_TYPE "orc"
21Expected<std::shared_ptr<UnwindInfoRegistrationPlugin>>
28 if (
auto Err = EPC.getBootstrapSymbols(
29 {{RegisterSections, SNs.RegisterSectionsName},
30 {DeregisterSections, SNs.DeregisterSectionsName}}))
31 return std::move(Err);
33 return std::make_shared<UnwindInfoRegistrationPlugin>(ES, RegisterSections,
42 [
this](
LinkGraph &
G) {
return addUnwindInfoRegistrationActions(
G); });
45Error UnwindInfoRegistrationPlugin::addUnwindInfoRegistrationActions(
49 std::vector<Block *> CodeBlocks;
55 SecRange.Start = (*Sec.
blocks().begin())->getAddress();
57 auto R =
B->getRange();
58 SecRange.Start = std::min(SecRange.Start, R.Start);
59 SecRange.End = std::max(SecRange.End, R.End);
60 for (
auto &E :
B->edges()) {
61 if (E.getKind() != Edge::KeepAlive || !E.getTarget().isDefined())
63 auto &TargetBlock = E.getTarget().getBlock();
64 auto &TargetSection = TargetBlock.getSection();
66 CodeBlocks.push_back(&TargetBlock);
71 if (
auto *EHFrame =
G.findSectionByName(MachOEHFrameSectionName))
72 ScanUnwindInfoSection(*EHFrame, EHFrameRange);
74 if (
auto *UnwindInfo =
G.findSectionByName(MachOUnwindInfoSectionName))
75 ScanUnwindInfoSection(*UnwindInfo, UnwindInfoRange);
77 if (CodeBlocks.empty())
80 if ((EHFrameRange == ExecutorAddrRange() &&
81 UnwindInfoRange == ExecutorAddrRange()))
85 return LHS->getAddress() <
RHS->getAddress();
89 for (
auto *
B : CodeBlocks) {
90 if (CodeRanges.empty() || CodeRanges.back().End !=
B->getAddress())
91 CodeRanges.push_back(
B->getRange());
93 CodeRanges.back().End =
B->getRange().End;
97 if (
auto *DSOBaseSym =
G.findAbsoluteSymbolByName(DSOBaseName))
98 DSOBase = DSOBaseSym->getAddress();
99 else if (
auto *DSOBaseSym =
G.findExternalSymbolByName(DSOBaseName))
100 DSOBase = DSOBaseSym->getAddress();
101 else if (
auto *DSOBaseSym =
G.findDefinedSymbolByName(DSOBaseName))
102 DSOBase = DSOBaseSym->getAddress();
105 " could not find dso base symbol",
108 using namespace shared;
109 using SPSRegisterSectionsArgs =
110 SPSArgList<SPSSequence<SPSExecutorAddrRange>, SPSExecutorAddr,
112 using SPSDeregisterSectionsArgs =
113 SPSArgList<SPSSequence<SPSExecutorAddrRange>>;
115 G.allocActions().push_back(
116 {
cantFail(WrapperFunctionCall::Create<SPSRegisterSectionsArgs>(
117 RegisterSections, CodeRanges, DSOBase, EHFrameRange,
119 cantFail(WrapperFunctionCall::Create<SPSDeregisterSectionsArgs>(
120 DeregisterSections, CodeRanges))});
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.
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.
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
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, rt::MachOUnwindInfoRegistrarSymbolNames SNs=rt::orc_rt_MachOUnwindInfoRegistrarSPSSymbols)
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.
Symbol names for the ORC runtime's StandaloneMachOUnwindInfoRegistrar SPS interface.