1//===------ EPCEHFrameRegistrar.cpp - EPC-based eh-frame registration -----===//
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
9#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h"
10
11#include "llvm/ExecutionEngine/Orc/Core.h"
12#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
13
14using namespace llvm::orc::shared;
15
16namespace llvm {
17namespace orc {
18
19Expected<std::unique_ptr<EPCEHFrameRegistrar>>
20EPCEHFrameRegistrar::Create(ExecutionSession &ES) {
21
22 // Lookup addresseses of the registration/deregistration functions in the
23 // bootstrap map.
24 ExecutorAddr RegisterEHFrameSectionWrapper;
25 ExecutorAddr DeregisterEHFrameSectionWrapper;
26 if (auto Err = ES.getExecutorProcessControl().getBootstrapSymbols(
27 Pairs: {{RegisterEHFrameSectionWrapper,
28 rt::RegisterEHFrameSectionWrapperName},
29 {DeregisterEHFrameSectionWrapper,
30 rt::DeregisterEHFrameSectionWrapperName}}))
31 return std::move(Err);
32
33 return std::make_unique<EPCEHFrameRegistrar>(
34 args&: ES, args&: RegisterEHFrameSectionWrapper, args&: DeregisterEHFrameSectionWrapper);
35}
36
37Error EPCEHFrameRegistrar::registerEHFrames(ExecutorAddrRange EHFrameSection) {
38 return ES.callSPSWrapper<void(SPSExecutorAddrRange)>(
39 WrapperFnAddr: RegisterEHFrameSectionWrapper, WrapperCallArgs&: EHFrameSection);
40}
41
42Error EPCEHFrameRegistrar::deregisterEHFrames(
43 ExecutorAddrRange EHFrameSection) {
44 return ES.callSPSWrapper<void(SPSExecutorAddrRange)>(
45 WrapperFnAddr: DeregisterEHFrameSectionWrapper, WrapperCallArgs&: EHFrameSection);
46}
47
48} // end namespace orc
49} // end namespace llvm
50