| Index: courgette/disassembler_elf_32_arm.h
|
| diff --git a/courgette/disassembler_elf_32_arm.h b/courgette/disassembler_elf_32_arm.h
|
| index 17ebb2557530749218510bacf18e8ded45553dbb..fef959a94f37e08b8b437cb66d999e0c165f41f4 100644
|
| --- a/courgette/disassembler_elf_32_arm.h
|
| +++ b/courgette/disassembler_elf_32_arm.h
|
| @@ -8,9 +8,10 @@
|
| #include <stddef.h>
|
| #include <stdint.h>
|
|
|
| +#include <map>
|
| +
|
| #include "base/macros.h"
|
| #include "courgette/disassembler_elf_32.h"
|
| -#include "courgette/memory_allocator.h"
|
| #include "courgette/types_elf.h"
|
|
|
| namespace courgette {
|
| @@ -31,50 +32,61 @@ class DisassemblerElf32ARM : public DisassemblerElf32 {
|
| public:
|
| TypedRVAARM(ARM_RVA type, RVA rva) : TypedRVA(rva), type_(type) { }
|
|
|
| - uint16_t c_op() const { return c_op_; }
|
| -
|
| - virtual CheckBool ComputeRelativeTarget(const uint8_t* op_pointer);
|
| + ~TypedRVAARM() override { }
|
|
|
| - virtual CheckBool EmitInstruction(AssemblyProgram* program,
|
| - RVA target_rva);
|
| + // TypedRVA interfaces.
|
| + CheckBool ComputeRelativeTarget(const uint8_t* op_pointer) override;
|
| + CheckBool EmitInstruction(AssemblyProgram* program,
|
| + RVA target_rva) override;
|
| + uint16_t op_size() const override;
|
|
|
| - virtual uint16_t op_size() const;
|
| + uint16_t c_op() const { return c_op_; }
|
|
|
| private:
|
| ARM_RVA type_;
|
| -
|
| - uint16_t c_op_; // set by ComputeRelativeTarget()
|
| + uint16_t c_op_; // Set by ComputeRelativeTarget().
|
| const uint8_t* arm_op_;
|
| };
|
|
|
| - explicit DisassemblerElf32ARM(const void* start, size_t length);
|
| + DisassemblerElf32ARM(const void* start, size_t length);
|
|
|
| - virtual ExecutableType kind() { return EXE_ELF_32_ARM; }
|
| + ~DisassemblerElf32ARM() override { };
|
|
|
| - virtual e_machine_values ElfEM() { return EM_ARM; }
|
| + // DisassemblerElf32 interfaces.
|
| + ExecutableType kind() const override { return EXE_ELF_32_ARM; }
|
| + e_machine_values ElfEM() const override { return EM_ARM; }
|
|
|
| + // Takes an ARM or thumb opcode |arm_op| of specified |type| and located at
|
| + // |rva|, extracts the instruction-relative target RVA into |*addr| and
|
| + // encodes the corresponding Courgette opcode as |*c_op|.
|
| + //
|
| + // Details on ARM opcodes, and target RVA extraction are taken from
|
| + // "ARM Architecture Reference Manual", section A4.1.5 and
|
| + // "Thumb-2 supplement", section 4.6.12.
|
| + // ARM_OFF24 is for the ARM opcode. The rest are for thumb opcodes.
|
| static CheckBool Compress(ARM_RVA type,
|
| uint32_t arm_op,
|
| RVA rva,
|
| uint16_t* c_op /* out */,
|
| uint32_t* addr /* out */);
|
|
|
| + // Inverts the process in Compress() method. Takes Courgette op |c_op| and
|
| + // relative address |addr| to reconstruct the original ARM or thumb op
|
| + // |*arm_op|.
|
| static CheckBool Decompress(ARM_RVA type,
|
| uint16_t c_op,
|
| uint32_t addr,
|
| uint32_t* arm_op /* out */);
|
|
|
| protected:
|
| -
|
| - virtual CheckBool RelToRVA(Elf32_Rel rel, RVA* result)
|
| - const WARN_UNUSED_RESULT;
|
| -
|
| - virtual CheckBool ParseRelocationSection(
|
| - const Elf32_Shdr *section_header,
|
| - AssemblyProgram* program) WARN_UNUSED_RESULT;
|
| -
|
| - virtual CheckBool ParseRel32RelocsFromSection(
|
| - const Elf32_Shdr* section) WARN_UNUSED_RESULT;
|
| + // DisassemblerElf32 interfaces.
|
| + CheckBool RelToRVA(Elf32_Rel rel, RVA* result)
|
| + const WARN_UNUSED_RESULT override;
|
| + CheckBool ParseRelocationSection(
|
| + const Elf32_Shdr* section_header,
|
| + AssemblyProgram* program) WARN_UNUSED_RESULT override;
|
| + CheckBool ParseRel32RelocsFromSection(
|
| + const Elf32_Shdr* section) WARN_UNUSED_RESULT override;
|
|
|
| #if COURGETTE_HISTOGRAM_TARGETS
|
| std::map<RVA, int> rel32_target_rvas_;
|
|
|