OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_X86_H_ | 5 #ifndef COURGETTE_DISASSEMBLER_ELF_32_X86_H_ |
6 #define COURGETTE_DISASSEMBLER_ELF_32_X86_H_ | 6 #define COURGETTE_DISASSEMBLER_ELF_32_X86_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "courgette/disassembler_elf_32.h" | 14 #include "courgette/disassembler_elf_32.h" |
15 #include "courgette/types_elf.h" | 15 #include "courgette/types_elf.h" |
16 | 16 |
17 namespace courgette { | 17 namespace courgette { |
18 | 18 |
19 class AssemblyProgram; | 19 class AssemblyProgram; |
20 | 20 |
21 class DisassemblerElf32X86 : public DisassemblerElf32 { | 21 class DisassemblerElf32X86 : public DisassemblerElf32 { |
22 public: | 22 public: |
23 // 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
| |
24 static bool QuickDetect(const uint8_t* start, size_t length) { | |
25 return DisassemblerElf32::QuickDetect(start, length, EM_386); | |
26 } | |
27 | |
23 class TypedRVAX86 : public TypedRVA { | 28 class TypedRVAX86 : public TypedRVA { |
24 public: | 29 public: |
25 explicit TypedRVAX86(RVA rva) : TypedRVA(rva) { } | 30 explicit TypedRVAX86(RVA rva) : TypedRVA(rva) { } |
26 ~TypedRVAX86() override { } | 31 ~TypedRVAX86() override { } |
27 | 32 |
28 // TypedRVA interfaces. | 33 // TypedRVA interfaces. |
29 CheckBool ComputeRelativeTarget(const uint8_t* op_pointer) override; | 34 CheckBool ComputeRelativeTarget(const uint8_t* op_pointer) override; |
30 CheckBool EmitInstruction(AssemblyProgram* program, | 35 CheckBool EmitInstruction(AssemblyProgram* program, |
31 Label* label) override; | 36 Label* label) override; |
32 uint16_t op_size() const override; | 37 uint16_t op_size() const override; |
33 }; | 38 }; |
34 | 39 |
35 DisassemblerElf32X86(const void* start, size_t length); | 40 DisassemblerElf32X86(const uint8_t* start, size_t length); |
36 | 41 |
37 ~DisassemblerElf32X86() override { } | 42 ~DisassemblerElf32X86() override { } |
38 | 43 |
39 // DisassemblerElf32 interfaces. | 44 // DisassemblerElf32 interfaces. |
40 ExecutableType kind() const override { return EXE_ELF_32_X86; } | 45 ExecutableType kind() const override { return EXE_ELF_32_X86; } |
41 e_machine_values ElfEM() const override { return EM_386; } | 46 e_machine_values ElfEM() const override { return EM_386; } |
42 | 47 |
43 protected: | 48 protected: |
44 // DisassemblerElf32 interfaces. | 49 // DisassemblerElf32 interfaces. |
45 CheckBool RelToRVA(Elf32_Rel rel, | 50 CheckBool RelToRVA(Elf32_Rel rel, |
46 RVA* result) const override WARN_UNUSED_RESULT; | 51 RVA* result) const override WARN_UNUSED_RESULT; |
47 CheckBool ParseRelocationSection(const Elf32_Shdr* section_header, | 52 CheckBool ParseRelocationSection(const Elf32_Shdr* section_header, |
48 AssemblyProgram* program) | 53 AssemblyProgram* program) |
49 override WARN_UNUSED_RESULT; | 54 override WARN_UNUSED_RESULT; |
50 CheckBool ParseRel32RelocsFromSection(const Elf32_Shdr* section) | 55 CheckBool ParseRel32RelocsFromSection(const Elf32_Shdr* section) |
51 override WARN_UNUSED_RESULT; | 56 override WARN_UNUSED_RESULT; |
52 | 57 |
53 #if COURGETTE_HISTOGRAM_TARGETS | 58 #if COURGETTE_HISTOGRAM_TARGETS |
54 std::map<RVA, int> rel32_target_rvas_; | 59 std::map<RVA, int> rel32_target_rvas_; |
55 #endif | 60 #endif |
56 | 61 |
57 DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32X86); | 62 DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32X86); |
58 }; | 63 }; |
59 | 64 |
60 } // namespace courgette | 65 } // namespace courgette |
61 | 66 |
62 #endif // COURGETTE_DISASSEMBLER_ELF_32_X86_H_ | 67 #endif // COURGETTE_DISASSEMBLER_ELF_32_X86_H_ |
OLD | NEW |