blob: 85b1b803c5d9a9b1522b159b7cbcdf9f09d46f6d [file] [log] [blame]
Lang Hames11c8dfa52019-04-20 17:10:34 +00001//===----- JITLink_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_LIB_EXECUTIONENGINE_JITLINK_JITLINK_EHFRAMESUPPORTIMPL_H
14#define LLVM_LIB_EXECUTIONENGINE_JITLINK_JITLINK_EHFRAMESUPPORTIMPL_H
15
16#include "llvm/ExecutionEngine/JITLink/JITLink_EHFrameSupport.h"
17
18#include "llvm/ExecutionEngine/JITLink/JITLink.h"
19#include "llvm/Support/BinaryStreamReader.h"
20
21namespace llvm {
22namespace 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.
28class EHFrameParser {
29public:
30 EHFrameParser(AtomGraph &G, Section &EHFrameSection, StringRef EHFrameContent,
31 JITTargetAddress EHFrameAddress, Edge::Kind FDEToCIERelocKind,
32 Edge::Kind FDEToTargetRelocKind);
33 Error atomize();
34
35private:
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 AtomGraph &G;
48 Section &EHFrameSection;
49 StringRef EHFrameContent;
50 JITTargetAddress EHFrameAddress;
51 BinaryStreamReader EHFrameReader;
52 DefinedAtom *CurRecordAtom = nullptr;
53 DefinedAtom *MostRecentCIE = nullptr;
54 bool LSDAFieldPresent = false;
55 Edge::Kind FDEToCIERelocKind;
56 Edge::Kind FDEToTargetRelocKind;
57};
58
59Error addEHFrame(AtomGraph &G, Section &EHFrameSection,
60 StringRef EHFrameContent, JITTargetAddress EHFrameAddress,
61 Edge::Kind FDEToCIERelocKind, Edge::Kind FDEToTargetRelocKind);
62
63} // end namespace jitlink
64} // end namespace llvm
65
66#endif // LLVM_LIB_EXECUTIONENGINE_JITLINK_JITLINK_EHFRAMESUPPORTIMPL_H