LLVM  10.0.0svn
EHFrameSupport.h
Go to the documentation of this file.
1 //===--------- EHFrameSupport.h - JITLink eh-frame utils --------*- 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 // EHFrame registration support for JITLink.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORT_H
14 #define LLVM_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORT_H
15 
16 #include "llvm/ADT/Triple.h"
19 #include "llvm/Support/Error.h"
20 
21 namespace llvm {
22 namespace jitlink {
23 
24 /// Registers all FDEs in the given eh-frame section with the current process.
25 Error registerEHFrameSection(const void *EHFrameSectionAddr);
26 
27 /// Deregisters all FDEs in the given eh-frame section with the current process.
28 Error deregisterEHFrameSection(const void *EHFrameSectionAddr);
29 
30 /// Supports registration/deregistration of EH-frames in a target process.
32 public:
33  virtual ~EHFrameRegistrar();
34  virtual Error registerEHFrames(JITTargetAddress EHFrameSectionAddr) = 0;
35  virtual Error deregisterEHFrames(JITTargetAddress EHFrameSectionAddr) = 0;
36 };
37 
38 /// Registers / Deregisters EH-frames in the current process.
40 public:
41  /// Get a reference to the InProcessEHFrameRegistrar singleton.
42  static InProcessEHFrameRegistrar &getInstance();
43 
46  operator=(const InProcessEHFrameRegistrar &) = delete;
47 
50 
51  Error registerEHFrames(JITTargetAddress EHFrameSectionAddr) override {
53  jitTargetAddressToPointer<void *>(EHFrameSectionAddr));
54  }
55 
56  Error deregisterEHFrames(JITTargetAddress EHFrameSectionAddr) override {
58  jitTargetAddressToPointer<void *>(EHFrameSectionAddr));
59  }
60 
61 private:
63 };
64 
65 using StoreFrameAddressFunction = std::function<void(JITTargetAddress)>;
66 
67 /// Creates a pass that records the address of the EH frame section. If no
68 /// eh-frame section is found, it will set EHFrameAddr to zero.
69 ///
70 /// Authors of JITLinkContexts can use this function to register a post-fixup
71 /// pass that records the address of the eh-frame section. This address can
72 /// be used after finalization to register and deregister the frame.
75  StoreFrameAddressFunction StoreFrameAddress);
76 
77 } // end namespace jitlink
78 } // end namespace llvm
79 
80 #endif // LLVM_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORT_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
uint64_t JITTargetAddress
Represents an address in the target process&#39;s address space.
Definition: JITSymbol.h:40
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157