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 // Returns 'true' if an valid executable is detected using only quick checks. | |
huangs
2016/06/17 15:21:57
NIT: true does not need ''
NIT: *a* valid executab
| |
32 static bool QuickDetect(const uint8_t* start, size_t length) { | |
33 return DisassemblerElf32::QuickDetect(start, length, EM_ARM); | |
34 } | |
35 | |
31 class TypedRVAARM : public TypedRVA { | 36 class TypedRVAARM : public TypedRVA { |
32 public: | 37 public: |
33 TypedRVAARM(ARM_RVA type, RVA rva) : TypedRVA(rva), type_(type) { } | 38 TypedRVAARM(ARM_RVA type, RVA rva) : TypedRVA(rva), type_(type) { } |
34 ~TypedRVAARM() override { } | 39 ~TypedRVAARM() override { } |
35 | 40 |
36 // TypedRVA interfaces. | 41 // TypedRVA interfaces. |
37 CheckBool ComputeRelativeTarget(const uint8_t* op_pointer) override; | 42 CheckBool ComputeRelativeTarget(const uint8_t* op_pointer) override; |
38 CheckBool EmitInstruction(AssemblyProgram* program, | 43 CheckBool EmitInstruction(AssemblyProgram* program, |
39 Label* label) override; | 44 Label* label) override; |
40 uint16_t op_size() const override; | 45 uint16_t op_size() const override; |
41 | 46 |
42 uint16_t c_op() const { return c_op_; } | 47 uint16_t c_op() const { return c_op_; } |
43 | 48 |
44 private: | 49 private: |
45 ARM_RVA type_; | 50 ARM_RVA type_; |
46 uint16_t c_op_; // Set by ComputeRelativeTarget(). | 51 uint16_t c_op_; // Set by ComputeRelativeTarget(). |
47 const uint8_t* arm_op_; | 52 const uint8_t* arm_op_; |
48 }; | 53 }; |
49 | 54 |
50 DisassemblerElf32ARM(const void* start, size_t length); | 55 DisassemblerElf32ARM(const uint8_t* start, size_t length); |
51 | 56 |
52 ~DisassemblerElf32ARM() override { } | 57 ~DisassemblerElf32ARM() override { } |
53 | 58 |
54 // DisassemblerElf32 interfaces. | 59 // DisassemblerElf32 interfaces. |
55 ExecutableType kind() const override { return EXE_ELF_32_ARM; } | 60 ExecutableType kind() const override { return EXE_ELF_32_ARM; } |
56 e_machine_values ElfEM() const override { return EM_ARM; } | 61 e_machine_values ElfEM() const override { return EM_ARM; } |
57 | 62 |
58 // Takes an ARM or thumb opcode |arm_op| of specified |type| and located at | 63 // 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 | 64 // |rva|, extracts the instruction-relative target RVA into |*addr| and |
60 // encodes the corresponding Courgette opcode as |*c_op|. | 65 // encodes the corresponding Courgette opcode as |*c_op|. |
(...skipping 28 matching lines...) Expand all Loading... | |
89 #if COURGETTE_HISTOGRAM_TARGETS | 94 #if COURGETTE_HISTOGRAM_TARGETS |
90 std::map<RVA, int> rel32_target_rvas_; | 95 std::map<RVA, int> rel32_target_rvas_; |
91 #endif | 96 #endif |
92 | 97 |
93 DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32ARM); | 98 DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32ARM); |
94 }; | 99 }; |
95 | 100 |
96 } // namespace courgette | 101 } // namespace courgette |
97 | 102 |
98 #endif // COURGETTE_DISASSEMBLER_ELF_32_ARM_H_ | 103 #endif // COURGETTE_DISASSEMBLER_ELF_32_ARM_H_ |
OLD | NEW |