blob: 31680e2401a775b3b5cadb70a45d574aa6e70f94 [file] [log] [blame]
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +00001//===--- ARMWinEHPrinter.h - Windows on ARM Unwind Information Printer ----===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_TOOLS_LLVM_READOBJ_ARMWINEHPRINTER_H
11#define LLVM_TOOLS_LLVM_READOBJ_ARMWINEHPRINTER_H
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000012
13#include "StreamWriter.h"
Saleem Abdulrasool8c491702014-06-04 16:03:18 +000014#include "llvm/Object/COFF.h"
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000015#include "llvm/Support/ErrorOr.h"
16
17namespace llvm {
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000018namespace ARM {
19namespace WinEH {
20class RuntimeFunction;
21
22class Decoder {
23 static const size_t PDataEntrySize;
24
25 StreamWriter &SW;
26 raw_ostream &OS;
27
28 struct RingEntry {
29 uint8_t Mask;
30 uint8_t Value;
31 bool (Decoder::*Routine)(const support::ulittle8_t *, unsigned &, unsigned,
32 bool);
33 };
34 static const RingEntry Ring[];
35
36 bool opcode_0xxxxxxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
37 unsigned Length, bool Prologue);
38 bool opcode_10Lxxxxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
39 unsigned Length, bool Prologue);
40 bool opcode_1100xxxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
41 unsigned Length, bool Prologue);
42 bool opcode_11010Lxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
43 unsigned Length, bool Prologue);
44 bool opcode_11011Lxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
45 unsigned Length, bool Prologue);
46 bool opcode_11100xxx(const support::ulittle8_t *Opcodes, unsigned &Offset,
47 unsigned Length, bool Prologue);
48 bool opcode_111010xx(const support::ulittle8_t *Opcodes, unsigned &Offset,
49 unsigned Length, bool Prologue);
50 bool opcode_1110110L(const support::ulittle8_t *Opcodes, unsigned &Offset,
51 unsigned Length, bool Prologue);
52 bool opcode_11101110(const support::ulittle8_t *Opcodes, unsigned &Offset,
53 unsigned Length, bool Prologue);
54 bool opcode_11101111(const support::ulittle8_t *Opcodes, unsigned &Offset,
55 unsigned Length, bool Prologue);
56 bool opcode_11110101(const support::ulittle8_t *Opcodes, unsigned &Offset,
57 unsigned Length, bool Prologue);
58 bool opcode_11110110(const support::ulittle8_t *Opcodes, unsigned &Offset,
59 unsigned Length, bool Prologue);
60 bool opcode_11110111(const support::ulittle8_t *Opcodes, unsigned &Offset,
61 unsigned Length, bool Prologue);
62 bool opcode_11111000(const support::ulittle8_t *Opcodes, unsigned &Offset,
63 unsigned Length, bool Prologue);
64 bool opcode_11111001(const support::ulittle8_t *Opcodes, unsigned &Offset,
65 unsigned Length, bool Prologue);
66 bool opcode_11111010(const support::ulittle8_t *Opcodes, unsigned &Offset,
67 unsigned Length, bool Prologue);
68 bool opcode_11111011(const support::ulittle8_t *Opcodes, unsigned &Offset,
69 unsigned Length, bool Prologue);
70 bool opcode_11111100(const support::ulittle8_t *Opcodes, unsigned &Offset,
71 unsigned Length, bool Prologue);
72 bool opcode_11111101(const support::ulittle8_t *Opcodes, unsigned &Offset,
73 unsigned Length, bool Prologue);
74 bool opcode_11111110(const support::ulittle8_t *Opcodes, unsigned &Offset,
75 unsigned Length, bool Prologue);
76 bool opcode_11111111(const support::ulittle8_t *Opcodes, unsigned &Offset,
77 unsigned Length, bool Prologue);
78
79 void decodeOpcodes(ArrayRef<support::ulittle8_t> Opcodes, unsigned Offset,
80 bool Prologue);
81
82 void printRegisters(const std::pair<uint16_t, uint32_t> &RegisterMask);
83
84 ErrorOr<object::SectionRef>
85 getSectionContaining(const object::COFFObjectFile &COFF, uint64_t Address);
86
87 ErrorOr<object::SymbolRef>
88 getSymbol(const object::COFFObjectFile &COFF, uint64_t Address,
89 bool FunctionOnly = false);
90
91 ErrorOr<object::SymbolRef>
92 getRelocatedSymbol(const object::COFFObjectFile &COFF,
93 const object::SectionRef &Section, uint64_t Offset);
94
95 bool dumpXDataRecord(const object::COFFObjectFile &COFF,
96 const object::SectionRef &Section,
97 uint64_t FunctionAddress, uint64_t VA);
98 bool dumpUnpackedEntry(const object::COFFObjectFile &COFF,
99 const object::SectionRef Section, uint64_t Offset,
100 unsigned Index, const RuntimeFunction &Entry);
101 bool dumpPackedEntry(const object::COFFObjectFile &COFF,
102 const object::SectionRef Section, uint64_t Offset,
103 unsigned Index, const RuntimeFunction &Entry);
104 bool dumpProcedureDataEntry(const object::COFFObjectFile &COFF,
105 const object::SectionRef Section, unsigned Entry,
106 ArrayRef<uint8_t> Contents);
107 void dumpProcedureData(const object::COFFObjectFile &COFF,
108 const object::SectionRef Section);
109
110public:
111 Decoder(StreamWriter &SW) : SW(SW), OS(SW.getOStream()) {}
Rafael Espindolabff5d0d2014-06-13 01:25:41 +0000112 std::error_code dumpProcedureData(const object::COFFObjectFile &COFF);
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +0000113};
114}
115}
116}
117
118#endif
119