Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 1 | //===--- 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 Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_TOOLS_LLVM_READOBJ_ARMWINEHPRINTER_H |
| 11 | #define LLVM_TOOLS_LLVM_READOBJ_ARMWINEHPRINTER_H |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 12 | |
Saleem Abdulrasool | 8c49170 | 2014-06-04 16:03:18 +0000 | [diff] [blame] | 13 | #include "llvm/Object/COFF.h" |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 14 | #include "llvm/Support/ErrorOr.h" |
Zachary Turner | 88bb163 | 2016-05-03 00:28:04 +0000 | [diff] [blame^] | 15 | #include "llvm/Support/ScopedPrinter.h" |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 16 | |
| 17 | namespace llvm { |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 18 | namespace ARM { |
| 19 | namespace WinEH { |
| 20 | class RuntimeFunction; |
| 21 | |
| 22 | class Decoder { |
| 23 | static const size_t PDataEntrySize; |
| 24 | |
Zachary Turner | 88bb163 | 2016-05-03 00:28:04 +0000 | [diff] [blame^] | 25 | ScopedPrinter &SW; |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 26 | raw_ostream &OS; |
| 27 | |
| 28 | struct RingEntry { |
| 29 | uint8_t Mask; |
| 30 | uint8_t Value; |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 31 | bool (Decoder::*Routine)(const uint8_t *, unsigned &, unsigned, bool); |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 32 | }; |
| 33 | static const RingEntry Ring[]; |
| 34 | |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 35 | bool opcode_0xxxxxxx(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 36 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 37 | bool opcode_10Lxxxxx(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 38 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 39 | bool opcode_1100xxxx(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 40 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 41 | bool opcode_11010Lxx(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 42 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 43 | bool opcode_11011Lxx(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 44 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 45 | bool opcode_11100xxx(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 46 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 47 | bool opcode_111010xx(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 48 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 49 | bool opcode_1110110L(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 50 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 51 | bool opcode_11101110(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 52 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 53 | bool opcode_11101111(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 54 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 55 | bool opcode_11110101(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 56 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 57 | bool opcode_11110110(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 58 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 59 | bool opcode_11110111(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 60 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 61 | bool opcode_11111000(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 62 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 63 | bool opcode_11111001(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 64 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 65 | bool opcode_11111010(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 66 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 67 | bool opcode_11111011(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 68 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 69 | bool opcode_11111100(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 70 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 71 | bool opcode_11111101(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 72 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 73 | bool opcode_11111110(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 74 | unsigned Length, bool Prologue); |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 75 | bool opcode_11111111(const uint8_t *Opcodes, unsigned &Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 76 | unsigned Length, bool Prologue); |
| 77 | |
Rui Ueyama | 062c406 | 2014-09-11 21:46:33 +0000 | [diff] [blame] | 78 | void decodeOpcodes(ArrayRef<uint8_t> Opcodes, unsigned Offset, |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 79 | 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 | |
| 109 | public: |
Zachary Turner | 88bb163 | 2016-05-03 00:28:04 +0000 | [diff] [blame^] | 110 | Decoder(ScopedPrinter &SW) : SW(SW), OS(SW.getOStream()) {} |
Rafael Espindola | bff5d0d | 2014-06-13 01:25:41 +0000 | [diff] [blame] | 111 | std::error_code dumpProcedureData(const object::COFFObjectFile &COFF); |
Saleem Abdulrasool | e6971ca | 2014-06-04 15:47:15 +0000 | [diff] [blame] | 112 | }; |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | #endif |