Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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. | |
| 4 | |
| 5 #ifndef COURGETTE_INSTRUCTION_UTILS_H_ | |
| 6 #define COURGETTE_INSTRUCTION_UTILS_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "courgette/image_utils.h" | |
| 13 #include "courgette/memory_allocator.h" | |
| 14 | |
| 15 namespace courgette { | |
| 16 | |
| 17 // An interface to receive emitted instructions parsed from an executable. | |
|
huangs
2017/03/23 18:51:23
InstructionReceptor identical to the code deleted
| |
| 18 class InstructionReceptor { | |
| 19 public: | |
| 20 InstructionReceptor() = default; | |
| 21 virtual ~InstructionReceptor() = default; | |
| 22 | |
| 23 // Generates an entire base relocation table. | |
| 24 virtual CheckBool EmitPeRelocs() = 0; | |
| 25 | |
| 26 // Generates an ELF style relocation table for X86. | |
| 27 virtual CheckBool EmitElfRelocation() = 0; | |
| 28 | |
| 29 // Generates an ELF style relocation table for ARM. | |
| 30 virtual CheckBool EmitElfARMRelocation() = 0; | |
| 31 | |
| 32 // Following instruction will be assembled at address 'rva'. | |
| 33 virtual CheckBool EmitOrigin(RVA rva) = 0; | |
| 34 | |
| 35 // Generates a single byte of data or machine instruction. | |
| 36 virtual CheckBool EmitSingleByte(uint8_t byte) = 0; | |
| 37 | |
| 38 // Generates multiple bytes of data or machine instructions. | |
| 39 virtual CheckBool EmitMultipleBytes(const uint8_t* bytes, size_t len) = 0; | |
| 40 | |
| 41 // Generates a 4-byte relative reference to address of 'label'. | |
| 42 virtual CheckBool EmitRel32(Label* label) = 0; | |
| 43 | |
| 44 // Generates a 4-byte relative reference to address of 'label' for ARM. | |
| 45 virtual CheckBool EmitRel32ARM(uint16_t op, | |
| 46 Label* label, | |
| 47 const uint8_t* arm_op, | |
| 48 uint16_t op_size) = 0; | |
| 49 | |
| 50 // Generates a 4-byte absolute reference to address of 'label'. | |
| 51 virtual CheckBool EmitAbs32(Label* label) = 0; | |
| 52 | |
| 53 // Generates an 8-byte absolute reference to address of 'label'. | |
| 54 virtual CheckBool EmitAbs64(Label* label) = 0; | |
| 55 | |
| 56 private: | |
| 57 DISALLOW_COPY_AND_ASSIGN(InstructionReceptor); | |
| 58 }; | |
| 59 | |
| 60 // A rerunable callback that emit instructions to a provided receptor. Returns | |
| 61 // true on success, and false otherwise. | |
| 62 using InstructionGenerator = base::Callback<CheckBool(InstructionReceptor*)>; | |
|
huangs
2017/03/23 18:51:23
Compared to old code in assembly_program.h, remove
| |
| 63 | |
| 64 } // namespace courgette | |
| 65 | |
| 66 #endif // COURGETTE_INSTRUCTION_UTILS_H_ | |
| OLD | NEW |