1 //===-- EPCEHFrameRegistrar.h - EPC based eh-frame registration -*- C++ -*-===//
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 // ExecutorProcessControl based eh-frame registration.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H
14 #define LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H
15 
16 #include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h"
17 
18 namespace llvm {
19 namespace orc {
20 
21 class ExecutionSession;
22 
23 /// Register/Deregisters EH frames in a remote process via a
24 /// ExecutorProcessControl instance.
25 class EPCEHFrameRegistrar : public jitlink::EHFrameRegistrar {
26 public:
27   /// Create from a ExecutorProcessControl instance alone. This will use
28   /// the EPC's lookupSymbols method to find the registration/deregistration
29   /// funciton addresses by name.
30   static Expected<std::unique_ptr<EPCEHFrameRegistrar>>
31   Create(ExecutionSession &ES);
32 
33   /// Create a EPCEHFrameRegistrar with the given ExecutorProcessControl
34   /// object and registration/deregistration function addresses.
EPCEHFrameRegistrar(ExecutionSession & ES,JITTargetAddress RegisterEHFrameWrapperFnAddr,JITTargetAddress DeregisterEHFRameWrapperFnAddr)35   EPCEHFrameRegistrar(ExecutionSession &ES,
36                       JITTargetAddress RegisterEHFrameWrapperFnAddr,
37                       JITTargetAddress DeregisterEHFRameWrapperFnAddr)
38       : ES(ES), RegisterEHFrameWrapperFnAddr(RegisterEHFrameWrapperFnAddr),
39         DeregisterEHFrameWrapperFnAddr(DeregisterEHFRameWrapperFnAddr) {}
40 
41   Error registerEHFrames(JITTargetAddress EHFrameSectionAddr,
42                          size_t EHFrameSectionSize) override;
43   Error deregisterEHFrames(JITTargetAddress EHFrameSectionAddr,
44                            size_t EHFrameSectionSize) override;
45 
46 private:
47   ExecutionSession &ES;
48   JITTargetAddress RegisterEHFrameWrapperFnAddr;
49   JITTargetAddress DeregisterEHFrameWrapperFnAddr;
50 };
51 
52 } // end namespace orc
53 } // end namespace llvm
54 
55 #endif // LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H
56