| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" | 
| 9 #include "courgette/disassembler_elf_32.h" | 9 #include "courgette/disassembler_elf_32.h" | 
| 10 #include "courgette/memory_allocator.h" | 10 #include "courgette/memory_allocator.h" | 
| 11 #include "courgette/types_elf.h" | 11 #include "courgette/types_elf.h" | 
| 12 | 12 | 
| 13 namespace courgette { | 13 namespace courgette { | 
| 14 | 14 | 
| 15 class AssemblyProgram; | 15 class AssemblyProgram; | 
| 16 | 16 | 
| 17 class DisassemblerElf32X86 : public DisassemblerElf32 { | 17 class DisassemblerElf32X86 : public DisassemblerElf32 { | 
| 18  public: | 18  public: | 
| 19   class TypedRVAX86 : public TypedRVA { | 19   class TypedRVAX86 : public TypedRVA { | 
| 20    public: | 20    public: | 
| 21     explicit TypedRVAX86(RVA rva) : TypedRVA(rva) { | 21     explicit TypedRVAX86(RVA rva) : TypedRVA(rva) { | 
| 22     } | 22     } | 
| 23 | 23 | 
| 24     virtual CheckBool ComputeRelativeTarget(const uint8* op_pointer) override { | 24     CheckBool ComputeRelativeTarget(const uint8* op_pointer) override { | 
| 25       set_relative_target(Read32LittleEndian(op_pointer) + 4); | 25       set_relative_target(Read32LittleEndian(op_pointer) + 4); | 
| 26       return true; | 26       return true; | 
| 27     } | 27     } | 
| 28 | 28 | 
| 29     virtual CheckBool EmitInstruction(AssemblyProgram* program, | 29     CheckBool EmitInstruction(AssemblyProgram* program, | 
| 30                                        RVA target_rva) override { | 30                               RVA target_rva) override { | 
| 31       return program->EmitRel32(program->FindOrMakeRel32Label(target_rva)); | 31       return program->EmitRel32(program->FindOrMakeRel32Label(target_rva)); | 
| 32     } | 32     } | 
| 33 | 33 | 
| 34     virtual uint16 op_size() const override { return 4; } | 34     uint16 op_size() const override { return 4; } | 
| 35   }; | 35   }; | 
| 36 | 36 | 
| 37   explicit DisassemblerElf32X86(const void* start, size_t length); | 37   explicit DisassemblerElf32X86(const void* start, size_t length); | 
| 38 | 38 | 
| 39   virtual ExecutableType kind() { return EXE_ELF_32_X86; } | 39   virtual ExecutableType kind() { return EXE_ELF_32_X86; } | 
| 40 | 40 | 
| 41   virtual e_machine_values ElfEM() { return EM_386; } | 41   virtual e_machine_values ElfEM() { return EM_386; } | 
| 42 | 42 | 
| 43  protected: | 43  protected: | 
| 44   virtual CheckBool RelToRVA(Elf32_Rel rel, RVA* result) | 44   virtual CheckBool RelToRVA(Elf32_Rel rel, RVA* result) | 
| 45       const WARN_UNUSED_RESULT; | 45       const WARN_UNUSED_RESULT; | 
| 46 | 46 | 
| 47   virtual CheckBool ParseRelocationSection( | 47   virtual CheckBool ParseRelocationSection( | 
| 48       const Elf32_Shdr *section_header, | 48       const Elf32_Shdr *section_header, | 
| 49       AssemblyProgram* program) WARN_UNUSED_RESULT; | 49       AssemblyProgram* program) WARN_UNUSED_RESULT; | 
| 50 | 50 | 
| 51   virtual CheckBool ParseRel32RelocsFromSection( | 51   virtual CheckBool ParseRel32RelocsFromSection( | 
| 52       const Elf32_Shdr* section) WARN_UNUSED_RESULT; | 52       const Elf32_Shdr* section) WARN_UNUSED_RESULT; | 
| 53 | 53 | 
| 54 #if COURGETTE_HISTOGRAM_TARGETS | 54 #if COURGETTE_HISTOGRAM_TARGETS | 
| 55   std::map<RVA, int> rel32_target_rvas_; | 55   std::map<RVA, int> rel32_target_rvas_; | 
| 56 #endif | 56 #endif | 
| 57 | 57 | 
| 58   DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32X86); | 58   DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32X86); | 
| 59 }; | 59 }; | 
| 60 | 60 | 
| 61 }  // namespace courgette | 61 }  // namespace courgette | 
| 62 | 62 | 
| 63 #endif  // COURGETTE_DISASSEMBLER_ELF_32_X86_H_ | 63 #endif  // COURGETTE_DISASSEMBLER_ELF_32_X86_H_ | 
| OLD | NEW | 
|---|