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_
13 #include "base/macros.h"
14 #include "courgette/disassembler_elf_32.h"
15 #include "courgette/types_elf.h"
19 class InstructionReceptor;
21 class DisassemblerElf32X86 : public DisassemblerElf32 {
23 // Returns true if a valid executable is detected using only quick checks.
24 static bool QuickDetect(const uint8_t* start, size_t length) {
25 return DisassemblerElf32::QuickDetect(start, length, EM_386);
28 class TypedRVAX86 : public TypedRVA {
30 explicit TypedRVAX86(RVA rva) : TypedRVA(rva) { }
31 ~TypedRVAX86() override { }
33 // TypedRVA interfaces.
34 CheckBool ComputeRelativeTarget(const uint8_t* op_pointer) override;
35 CheckBool EmitInstruction(Label* label,
36 InstructionReceptor* receptor) override;
37 uint16_t op_size() const override;
40 DisassemblerElf32X86(const uint8_t* start, size_t length);
42 ~DisassemblerElf32X86() override { }
44 // DisassemblerElf32 interfaces.
45 ExecutableType kind() const override { return EXE_ELF_32_X86; }
46 e_machine_values ElfEM() const override { return EM_386; }
49 // DisassemblerElf32 interfaces.
50 CheckBool RelToRVA(Elf32_Rel rel,
51 RVA* result) const override WARN_UNUSED_RESULT;
52 CheckBool ParseRelocationSection(const Elf32_Shdr* section_header,
53 InstructionReceptor* receptor) const override
55 CheckBool ParseRel32RelocsFromSection(const Elf32_Shdr* section)
56 override WARN_UNUSED_RESULT;
58 #if COURGETTE_HISTOGRAM_TARGETS
59 std::map<RVA, int> rel32_target_rvas_;
63 DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32X86);
66 } // namespace courgette
68 #endif // COURGETTE_DISASSEMBLER_ELF_32_X86_H_