OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COURGETTE_DISASSEMBLER_ELF_32_ARM_H_ | 5 #ifndef COURGETTE_DISASSEMBLER_ELF_32_ARM_H_ |
6 #define COURGETTE_DISASSEMBLER_ELF_32_ARM_H_ | 6 #define COURGETTE_DISASSEMBLER_ELF_32_ARM_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 enum ARM_RVA { | 21 enum ARM_RVA { |
22 ARM_OFF8, | 22 ARM_OFF8, |
23 ARM_OFF11, | 23 ARM_OFF11, |
24 ARM_OFF24, | 24 ARM_OFF24, |
25 ARM_OFF25, | 25 ARM_OFF25, |
26 ARM_OFF21, | 26 ARM_OFF21, |
27 }; | 27 }; |
28 | 28 |
29 class DisassemblerElf32ARM : public DisassemblerElf32 { | 29 class DisassemblerElf32ARM : public DisassemblerElf32 { |
30 public: | 30 public: |
| 31 static bool QuickDetect(const uint8_t* start, size_t length) { |
| 32 return DisassemblerElf32::QuickDetect(start, length, EM_ARM); |
| 33 } |
| 34 |
31 class TypedRVAARM : public TypedRVA { | 35 class TypedRVAARM : public TypedRVA { |
32 public: | 36 public: |
33 TypedRVAARM(ARM_RVA type, RVA rva) : TypedRVA(rva), type_(type) { } | 37 TypedRVAARM(ARM_RVA type, RVA rva) : TypedRVA(rva), type_(type) { } |
34 ~TypedRVAARM() override { } | 38 ~TypedRVAARM() override { } |
35 | 39 |
36 // TypedRVA interfaces. | 40 // TypedRVA interfaces. |
37 CheckBool ComputeRelativeTarget(const uint8_t* op_pointer) override; | 41 CheckBool ComputeRelativeTarget(const uint8_t* op_pointer) override; |
38 CheckBool EmitInstruction(AssemblyProgram* program, | 42 CheckBool EmitInstruction(AssemblyProgram* program, |
39 Label* label) override; | 43 Label* label) override; |
40 uint16_t op_size() const override; | 44 uint16_t op_size() const override; |
41 | 45 |
42 uint16_t c_op() const { return c_op_; } | 46 uint16_t c_op() const { return c_op_; } |
43 | 47 |
44 private: | 48 private: |
45 ARM_RVA type_; | 49 ARM_RVA type_; |
46 uint16_t c_op_; // Set by ComputeRelativeTarget(). | 50 uint16_t c_op_; // Set by ComputeRelativeTarget(). |
47 const uint8_t* arm_op_; | 51 const uint8_t* arm_op_; |
48 }; | 52 }; |
49 | 53 |
50 DisassemblerElf32ARM(const void* start, size_t length); | 54 DisassemblerElf32ARM(const uint8_t* start, size_t length); |
51 | 55 |
52 ~DisassemblerElf32ARM() override { } | 56 ~DisassemblerElf32ARM() override { } |
53 | 57 |
54 // DisassemblerElf32 interfaces. | 58 // DisassemblerElf32 interfaces. |
55 ExecutableType kind() const override { return EXE_ELF_32_ARM; } | 59 ExecutableType kind() const override { return EXE_ELF_32_ARM; } |
56 e_machine_values ElfEM() const override { return EM_ARM; } | 60 e_machine_values ElfEM() const override { return EM_ARM; } |
57 | 61 |
58 // Takes an ARM or thumb opcode |arm_op| of specified |type| and located at | 62 // Takes an ARM or thumb opcode |arm_op| of specified |type| and located at |
59 // |rva|, extracts the instruction-relative target RVA into |*addr| and | 63 // |rva|, extracts the instruction-relative target RVA into |*addr| and |
60 // encodes the corresponding Courgette opcode as |*c_op|. | 64 // encodes the corresponding Courgette opcode as |*c_op|. |
(...skipping 28 matching lines...) Expand all Loading... |
89 #if COURGETTE_HISTOGRAM_TARGETS | 93 #if COURGETTE_HISTOGRAM_TARGETS |
90 std::map<RVA, int> rel32_target_rvas_; | 94 std::map<RVA, int> rel32_target_rvas_; |
91 #endif | 95 #endif |
92 | 96 |
93 DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32ARM); | 97 DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32ARM); |
94 }; | 98 }; |
95 | 99 |
96 } // namespace courgette | 100 } // namespace courgette |
97 | 101 |
98 #endif // COURGETTE_DISASSEMBLER_ELF_32_ARM_H_ | 102 #endif // COURGETTE_DISASSEMBLER_ELF_32_ARM_H_ |
OLD | NEW |