EHFrameSupport.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--------- EHFrameSupport.h - JITLink eh-frame utils --------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // EHFrame registration support for JITLink.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORT_H
  18. #define LLVM_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORT_H
  19. #include "llvm/ADT/Triple.h"
  20. #include "llvm/ExecutionEngine/JITLink/JITLink.h"
  21. #include "llvm/ExecutionEngine/JITSymbol.h"
  22. #include "llvm/Support/Error.h"
  23. namespace llvm {
  24. namespace jitlink {
  25. /// Supports registration/deregistration of EH-frames in a target process.
  26. class EHFrameRegistrar {
  27. public:
  28. virtual ~EHFrameRegistrar();
  29. virtual Error registerEHFrames(orc::ExecutorAddrRange EHFrameSection) = 0;
  30. virtual Error deregisterEHFrames(orc::ExecutorAddrRange EHFrameSection) = 0;
  31. };
  32. /// Registers / Deregisters EH-frames in the current process.
  33. class InProcessEHFrameRegistrar final : public EHFrameRegistrar {
  34. public:
  35. Error registerEHFrames(orc::ExecutorAddrRange EHFrameSection) override;
  36. Error deregisterEHFrames(orc::ExecutorAddrRange EHFrameSection) override;
  37. };
  38. using StoreFrameRangeFunction = std::function<void(
  39. orc::ExecutorAddr EHFrameSectionAddr, size_t EHFrameSectionSize)>;
  40. /// Creates a pass that records the address and size of the EH frame section.
  41. /// If no eh-frame section is found then the address and size will both be given
  42. /// as zero.
  43. ///
  44. /// Authors of JITLinkContexts can use this function to register a post-fixup
  45. /// pass that records the range of the eh-frame section. This range can
  46. /// be used after finalization to register and deregister the frame.
  47. LinkGraphPassFunction
  48. createEHFrameRecorderPass(const Triple &TT,
  49. StoreFrameRangeFunction StoreFrameRange);
  50. } // end namespace jitlink
  51. } // end namespace llvm
  52. #endif // LLVM_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORT_H
  53. #ifdef __GNUC__
  54. #pragma GCC diagnostic pop
  55. #endif