LLVM 24.0.0git
EHFrameRegistrationPlugin.cpp
Go to the documentation of this file.
1//===--------- EHFrameRegistrationPlugin.cpp - Register eh-frames ---------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
15
16#define DEBUG_TYPE "orc"
17
18using namespace llvm::jitlink;
19
20namespace llvm::orc {
21
22Expected<std::unique_ptr<EHFrameRegistrationPlugin>>
24 // Lookup addresseses of the registration/deregistration functions in the
25 // bootstrap map.
26 ExecutorAddr RegisterEHFrameSectionAllocAction;
27 ExecutorAddr DeregisterEHFrameSectionAllocAction;
28 if (auto Err = lookupAndApply(
30 {recordAddr(rt::RegisterEHFrameSectionAllocActionName,
31 &RegisterEHFrameSectionAllocAction),
32 recordAddr(rt::DeregisterEHFrameSectionAllocActionName,
33 &DeregisterEHFrameSectionAllocAction)}))
34 return std::move(Err);
35
36 return std::make_unique<EHFrameRegistrationPlugin>(
37 RegisterEHFrameSectionAllocAction, DeregisterEHFrameSectionAllocAction);
38}
39
42 PassConfiguration &PassConfig) {
44 PassConfig.PrePrunePasses.insert(
45 PassConfig.PrePrunePasses.begin(), [](LinkGraph &G) {
46 if (auto *CUSec = G.findSectionByName(MachOCompactUnwindSectionName))
47 G.removeSection(*CUSec);
48 return Error::success();
49 });
50
51 PassConfig.PostFixupPasses.push_back([this](LinkGraph &G) -> Error {
52 if (auto *EHFrame = getEHFrameSection(G)) {
53 using namespace shared;
54 auto R = SectionRange(*EHFrame).getRange();
55 G.allocActions().push_back(
56 {cantFail(
57 WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddrRange>>(
58 RegisterEHFrame, R)),
60 WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddrRange>>(
61 DeregisterEHFrame, R))});
62 }
63 return Error::success();
64 });
65}
66
67} // namespace llvm::orc
#define G(x, y, z)
Definition MD5.cpp:55
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition Triple.h:875
static Expected< std::unique_ptr< EHFrameRegistrationPlugin > > Create(ExecutionSession &ES)
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::PassConfiguration &PassConfig) override
An ExecutionSession represents a running JIT program.
Definition Core.h:1111
JITDylib & getBootstrapJITDylib()
Returns a reference to the bootstrap JITDylib.
Definition Core.h:1177
Represents an address in the executor process.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition Core.h:349
LLVM_ABI void lookupAndApply(unique_function< void(Error)> OnApplied, LookupKind K, const JITDylibSearchOrder &SearchOrder, ArrayRef< LookupPrepareFn > PrepareFns)
Resolve the symbols contributed by every prepare function with a single lookup, then let each of thei...
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition Error.h:769