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 binary parser for eh-frame sections.
25 ///
26 /// Adds blocks and symbols representing CIE and FDE entries to a JITLink graph.
27 ///
28 /// This parser assumes that the user has already verified that the EH-frame's
29 /// address range does not overlap any other section/symbol, so that generated
30 /// CIE/FDE records do not overlap other sections/symbols.
32 public:
33  EHFrameBinaryParser(JITTargetAddress EHFrameAddress, StringRef EHFrameContent,
34  unsigned PointerSize, support::endianness Endianness);
35  virtual ~EHFrameBinaryParser() {}
36 
37  Error addToGraph();
38 
39 private:
40  virtual void anchor();
41  virtual Symbol *getSymbolAtAddress(JITTargetAddress Addr) = 0;
42  virtual Symbol &createCIERecord(JITTargetAddress RecordAddr,
43  StringRef RecordContent) = 0;
44  virtual Expected<Symbol &>
45  createFDERecord(JITTargetAddress RecordAddr, StringRef RecordContent,
46  Symbol &CIE, size_t CIEOffset, Symbol &Func,
47  size_t FuncOffset, Symbol *LSDA, size_t LSDAOffset) = 0;
48 
49  struct AugmentationInfo {
50  bool AugmentationDataPresent = false;
51  bool EHDataFieldPresent = false;
52  uint8_t Fields[4] = {0x0, 0x0, 0x0, 0x0};
53  };
54 
55  Expected<AugmentationInfo> parseAugmentationString();
56  Expected<JITTargetAddress> readAbsolutePointer();
57  Error processCIE(size_t RecordOffset, size_t RecordLength);
58  Error processFDE(size_t RecordOffset, size_t RecordLength,
59  JITTargetAddress CIEPointerOffset, uint32_t CIEPointer);
60 
61  struct CIEInformation {
62  CIEInformation() = default;
63  CIEInformation(Symbol &CIESymbol) : CIESymbol(&CIESymbol) {}
64  Symbol *CIESymbol = nullptr;
65  bool FDEsHaveLSDAField = false;
66  };
67 
68  JITTargetAddress EHFrameAddress;
69  StringRef EHFrameContent;
70  unsigned PointerSize;
71  BinaryStreamReader EHFrameReader;
73 };
74 
75 } // end namespace jitlink
76 } // end namespace llvm
77 
78 #endif // LLVM_LIB_EXECUTIONENGINE_JITLINK_EHFRAMESUPPORTIMPL_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
constexpr support::endianness Endianness
The endianness of all multi-byte encoded values in MessagePack.
Definition: MsgPack.h:24
Tagged union holding either a T or a Error.
Definition: yaml2obj.h:21
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