LLVM  10.0.0svn
EHFrameSupportImpl.h
Go to the documentation of this file.
1 //===------- EHFrameSupportImpl.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_LIB_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORTIMPL_H
14 #define LLVM_LIB_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORTIMPL_H
15 
17 
20 
21 namespace llvm {
22 namespace jitlink {
23 
24 /// A generic parser for eh-frame sections.
25 ///
26 /// Adds atoms representing CIE and FDE entries, using the given FDE-to-CIE and
27 /// FDEToTarget relocation kinds.
29 public:
30  EHFrameParser(AtomGraph &G, Section &EHFrameSection, StringRef EHFrameContent,
31  JITTargetAddress EHFrameAddress, Edge::Kind FDEToCIERelocKind,
32  Edge::Kind FDEToTargetRelocKind);
33  Error atomize();
34 
35 private:
36  struct AugmentationInfo {
37  bool AugmentationDataPresent = false;
38  bool EHDataFieldPresent = false;
39  uint8_t Fields[4] = {0x0, 0x0, 0x0, 0x0};
40  };
41 
42  Expected<AugmentationInfo> parseAugmentationString();
43  Expected<JITTargetAddress> readAbsolutePointer();
44  Error processCIE();
45  Error processFDE(JITTargetAddress CIEPointerAddress, uint32_t CIEPointer);
46 
47  struct CIEInformation {
48  CIEInformation() = default;
49  CIEInformation(DefinedAtom &CIEAtom) : CIEAtom(&CIEAtom) {}
50  DefinedAtom *CIEAtom = nullptr;
51  bool FDEsHaveLSDAField = false;
52  };
53 
54  AtomGraph &G;
55  Section &EHFrameSection;
56  StringRef EHFrameContent;
57  JITTargetAddress EHFrameAddress;
58  BinaryStreamReader EHFrameReader;
59  DefinedAtom *CurRecordAtom = nullptr;
61  Edge::Kind FDEToCIERelocKind;
62  Edge::Kind FDEToTargetRelocKind;
63 };
64 
65 Error addEHFrame(AtomGraph &G, Section &EHFrameSection,
66  StringRef EHFrameContent, JITTargetAddress EHFrameAddress,
67  Edge::Kind FDEToCIERelocKind, Edge::Kind FDEToTargetRelocKind);
68 
69 } // end namespace jitlink
70 } // end namespace llvm
71 
72 #endif // LLVM_LIB_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORTIMPL_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Tagged union holding either a T or a Error.
Definition: yaml2obj.h:21
#define G(x, y, z)
Definition: MD5.cpp:56
uint64_t JITTargetAddress
Represents an address in the target process&#39;s address space.
Definition: JITSymbol.h:41
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48