blob: 95f521702268a89e56d3ef49d13219a4c4e0e5ee [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
Saleem Abdulrasool8c491702014-06-04 16:03:18 +000013#include "llvm/Object/COFF.h"
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000014#include "llvm/Support/ErrorOr.h"
Zachary Turner88bb1632016-05-03 00:28:04 +000015#include "llvm/Support/ScopedPrinter.h"
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000016
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
Zachary Turner88bb1632016-05-03 00:28:04 +000025 ScopedPrinter &SW;
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000026 raw_ostream &OS;
27
28 struct RingEntry {
29 uint8_t Mask;
30 uint8_t Value;
Rui Ueyama062c4062014-09-11 21:46:33 +000031 bool (Decoder::*Routine)(const uint8_t *, unsigned &, unsigned, bool);
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000032 };
33 static const RingEntry Ring[];
34
Rui Ueyama062c4062014-09-11 21:46:33 +000035 bool opcode_0xxxxxxx(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000036 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000037 bool opcode_10Lxxxxx(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000038 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000039 bool opcode_1100xxxx(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000040 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000041 bool opcode_11010Lxx(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000042 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000043 bool opcode_11011Lxx(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000044 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000045 bool opcode_11100xxx(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000046 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000047 bool opcode_111010xx(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000048 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000049 bool opcode_1110110L(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000050 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000051 bool opcode_11101110(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000052 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000053 bool opcode_11101111(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000054 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000055 bool opcode_11110101(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000056 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000057 bool opcode_11110110(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000058 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000059 bool opcode_11110111(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000060 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000061 bool opcode_11111000(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000062 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000063 bool opcode_11111001(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000064 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000065 bool opcode_11111010(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000066 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000067 bool opcode_11111011(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000068 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000069 bool opcode_11111100(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000070 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000071 bool opcode_11111101(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000072 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000073 bool opcode_11111110(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000074 unsigned Length, bool Prologue);
Rui Ueyama062c4062014-09-11 21:46:33 +000075 bool opcode_11111111(const uint8_t *Opcodes, unsigned &Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000076 unsigned Length, bool Prologue);
77
Rui Ueyama062c4062014-09-11 21:46:33 +000078 void decodeOpcodes(ArrayRef<uint8_t> Opcodes, unsigned Offset,
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +000079 bool Prologue);
80
81 void printRegisters(const std::pair<uint16_t, uint32_t> &RegisterMask);
82
83 ErrorOr<object::SectionRef>
84 getSectionContaining(const object::COFFObjectFile &COFF, uint64_t Address);
85
86 ErrorOr<object::SymbolRef>
87 getSymbol(const object::COFFObjectFile &COFF, uint64_t Address,
88 bool FunctionOnly = false);
89
90 ErrorOr<object::SymbolRef>
91 getRelocatedSymbol(const object::COFFObjectFile &COFF,
92 const object::SectionRef &Section, uint64_t Offset);
93
94 bool dumpXDataRecord(const object::COFFObjectFile &COFF,
95 const object::SectionRef &Section,
96 uint64_t FunctionAddress, uint64_t VA);
97 bool dumpUnpackedEntry(const object::COFFObjectFile &COFF,
98 const object::SectionRef Section, uint64_t Offset,
99 unsigned Index, const RuntimeFunction &Entry);
100 bool dumpPackedEntry(const object::COFFObjectFile &COFF,
101 const object::SectionRef Section, uint64_t Offset,
102 unsigned Index, const RuntimeFunction &Entry);
103 bool dumpProcedureDataEntry(const object::COFFObjectFile &COFF,
104 const object::SectionRef Section, unsigned Entry,
105 ArrayRef<uint8_t> Contents);
106 void dumpProcedureData(const object::COFFObjectFile &COFF,
107 const object::SectionRef Section);
108
109public:
Zachary Turner88bb1632016-05-03 00:28:04 +0000110 Decoder(ScopedPrinter &SW) : SW(SW), OS(SW.getOStream()) {}
Rafael Espindolabff5d0d2014-06-13 01:25:41 +0000111 std::error_code dumpProcedureData(const object::COFFObjectFile &COFF);
Saleem Abdulrasoole6971ca2014-06-04 15:47:15 +0000112};
113}
114}
115}
116
117#endif