LLVM 22.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
14
15#define DEBUG_TYPE "orc"
16
17using namespace llvm::jitlink;
18
19namespace llvm::orc {
20
23 // Lookup addresseses of the registration/deregistration functions in the
24 // bootstrap map.
25 ExecutorAddr RegisterEHFrameSectionAllocAction;
26 ExecutorAddr DeregisterEHFrameSectionAllocAction;
28 {{RegisterEHFrameSectionAllocAction,
29 rt::RegisterEHFrameSectionAllocActionName},
30 {DeregisterEHFrameSectionAllocAction,
31 rt::DeregisterEHFrameSectionAllocActionName}}))
32 return std::move(Err);
33
34 return std::make_unique<EHFrameRegistrationPlugin>(
35 RegisterEHFrameSectionAllocAction, DeregisterEHFrameSectionAllocAction);
36}
37
38void EHFrameRegistrationPlugin::modifyPassConfig(
40 PassConfiguration &PassConfig) {
42 PassConfig.PrePrunePasses.insert(
43 PassConfig.PrePrunePasses.begin(), [](LinkGraph &G) {
44 if (auto *CUSec = G.findSectionByName(MachOCompactUnwindSectionName))
45 G.removeSection(*CUSec);
46 return Error::success();
47 });
48
49 PassConfig.PostFixupPasses.push_back([this](LinkGraph &G) -> Error {
50 if (auto *EHFrame = getEHFrameSection(G)) {
51 using namespace shared;
52 auto R = SectionRange(*EHFrame).getRange();
53 G.allocActions().push_back(
54 {cantFail(
55 WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddrRange>>(
56 RegisterEHFrame, R)),
58 WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddrRange>>(
59 DeregisterEHFrame, R))});
60 }
61 return Error::success();
62 });
63}
64
65} // namespace llvm::orc
#define G(x, y, z)
Definition: MD5.cpp:56
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
static ErrorSuccess success()
Create a success value.
Definition: Error.h:336
Tagged union holding either a T or a Error.
Definition: Error.h:485
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:779
static Expected< std::unique_ptr< EHFrameRegistrationPlugin > > Create(ExecutionSession &ES)
An ExecutionSession represents a running JIT program.
Definition: Core.h:1355
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition: Core.h:1395
Represents an address in the executor process.
Error getBootstrapSymbols(ArrayRef< std::pair< ExecutorAddr &, StringRef > > Pairs) const
For each (ExecutorAddr&, StringRef) pair, looks up the string in the bootstrap symbols map and writes...
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition: Core.h:576
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:769