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
3 // found in the LICENSE file.
5 #ifndef COURGETTE_DISASSEMBLER_ELF_32_X86_H_
6 #define COURGETTE_DISASSEMBLER_ELF_32_X86_H_
8 #include "base/basictypes.h"
9 #include "courgette/disassembler_elf_32.h"
10 #include "courgette/memory_allocator.h"
11 #include "courgette/types_elf.h"
15 class AssemblyProgram
;
17 class DisassemblerElf32X86
: public DisassemblerElf32
{
19 class TypedRVAX86
: public TypedRVA
{
21 explicit TypedRVAX86(RVA rva
) : TypedRVA(rva
) {
24 virtual CheckBool
ComputeRelativeTarget(const uint8
* op_pointer
) OVERRIDE
{
25 set_relative_target(Read32LittleEndian(op_pointer
) + 4);
29 virtual CheckBool
EmitInstruction(AssemblyProgram
* program
,
30 RVA target_rva
) OVERRIDE
{
31 return program
->EmitRel32(program
->FindOrMakeRel32Label(target_rva
));
34 virtual uint16
op_size() const OVERRIDE
{ return 4; }
37 explicit DisassemblerElf32X86(const void* start
, size_t length
);
39 virtual ExecutableType
kind() { return EXE_ELF_32_X86
; }
41 virtual e_machine_values
ElfEM() { return EM_386
; }
44 virtual CheckBool
RelToRVA(Elf32_Rel rel
, RVA
* result
)
45 const WARN_UNUSED_RESULT
;
47 virtual CheckBool
ParseRelocationSection(
48 const Elf32_Shdr
*section_header
,
49 AssemblyProgram
* program
) WARN_UNUSED_RESULT
;
51 virtual CheckBool
ParseRel32RelocsFromSection(
52 const Elf32_Shdr
* section
) WARN_UNUSED_RESULT
;
54 #if COURGETTE_HISTOGRAM_TARGETS
55 std::map
<RVA
, int> rel32_target_rvas_
;
58 DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32X86
);
61 } // namespace courgette
63 #endif // COURGETTE_DISASSEMBLER_ELF_32_X86_H_