| 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_ENCODED_PROGRAM_H_ | 5 #ifndef COURGETTE_ENCODED_PROGRAM_H_ |
| 6 #define COURGETTE_ENCODED_PROGRAM_H_ | 6 #define COURGETTE_ENCODED_PROGRAM_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // (2) Address tables and indexes defined first. | 35 // (2) Address tables and indexes defined first. |
| 36 CheckBool DefineRel32Label(int index, RVA address) WARN_UNUSED_RESULT; | 36 CheckBool DefineRel32Label(int index, RVA address) WARN_UNUSED_RESULT; |
| 37 CheckBool DefineAbs32Label(int index, RVA address) WARN_UNUSED_RESULT; | 37 CheckBool DefineAbs32Label(int index, RVA address) WARN_UNUSED_RESULT; |
| 38 void EndLabels(); | 38 void EndLabels(); |
| 39 | 39 |
| 40 // (3) Add instructions in the order needed to generate bytes of file. | 40 // (3) Add instructions in the order needed to generate bytes of file. |
| 41 // NOTE: If any of these methods ever fail, the EncodedProgram instance | 41 // NOTE: If any of these methods ever fail, the EncodedProgram instance |
| 42 // has failed and should be discarded. | 42 // has failed and should be discarded. |
| 43 CheckBool AddOrigin(RVA rva) WARN_UNUSED_RESULT; | 43 CheckBool AddOrigin(RVA rva) WARN_UNUSED_RESULT; |
| 44 CheckBool AddCopy(uint32 count, const void* bytes) WARN_UNUSED_RESULT; | 44 CheckBool AddCopy(size_t count, const void* bytes) WARN_UNUSED_RESULT; |
| 45 CheckBool AddRel32(int label_index) WARN_UNUSED_RESULT; | 45 CheckBool AddRel32(int label_index) WARN_UNUSED_RESULT; |
| 46 CheckBool AddRel32ARM(uint16 op, int label_index) WARN_UNUSED_RESULT; | 46 CheckBool AddRel32ARM(uint16 op, int label_index) WARN_UNUSED_RESULT; |
| 47 CheckBool AddAbs32(int label_index) WARN_UNUSED_RESULT; | 47 CheckBool AddAbs32(int label_index) WARN_UNUSED_RESULT; |
| 48 CheckBool AddPeMakeRelocs(ExecutableType kind) WARN_UNUSED_RESULT; | 48 CheckBool AddPeMakeRelocs(ExecutableType kind) WARN_UNUSED_RESULT; |
| 49 CheckBool AddElfMakeRelocs() WARN_UNUSED_RESULT; | 49 CheckBool AddElfMakeRelocs() WARN_UNUSED_RESULT; |
| 50 CheckBool AddElfARMMakeRelocs() WARN_UNUSED_RESULT; | 50 CheckBool AddElfARMMakeRelocs() WARN_UNUSED_RESULT; |
| 51 | 51 |
| 52 // (3) Serialize binary assembly language tables to a set of streams. | 52 // (3) Serialize binary assembly language tables to a set of streams. |
| 53 CheckBool WriteTo(SinkStreamSet* streams) WARN_UNUSED_RESULT; | 53 CheckBool WriteTo(SinkStreamSet* streams) WARN_UNUSED_RESULT; |
| 54 | 54 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 80 // subset, and 1-12 are the compressed ARM op. | 80 // subset, and 1-12 are the compressed ARM op. |
| 81 REL32ARM8 = 0x1000, | 81 REL32ARM8 = 0x1000, |
| 82 REL32ARM11 = 0x2000, | 82 REL32ARM11 = 0x2000, |
| 83 REL32ARM24 = 0x3000, | 83 REL32ARM24 = 0x3000, |
| 84 REL32ARM25 = 0x4000, | 84 REL32ARM25 = 0x4000, |
| 85 REL32ARM21 = 0x5000, | 85 REL32ARM21 = 0x5000, |
| 86 LAST_ARM = 0x5FFF, | 86 LAST_ARM = 0x5FFF, |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 typedef NoThrowBuffer<RVA> RvaVector; | 89 typedef NoThrowBuffer<RVA> RvaVector; |
| 90 typedef NoThrowBuffer<size_t> SizeTVector; |
| 90 typedef NoThrowBuffer<uint32> UInt32Vector; | 91 typedef NoThrowBuffer<uint32> UInt32Vector; |
| 91 typedef NoThrowBuffer<uint8> UInt8Vector; | 92 typedef NoThrowBuffer<uint8> UInt8Vector; |
| 92 typedef NoThrowBuffer<OP> OPVector; | 93 typedef NoThrowBuffer<OP> OPVector; |
| 93 | 94 |
| 94 void DebuggingSummary(); | 95 void DebuggingSummary(); |
| 95 CheckBool GeneratePeRelocations(SinkStream *buffer, | 96 CheckBool GeneratePeRelocations(SinkStream *buffer, |
| 96 uint8 type) WARN_UNUSED_RESULT; | 97 uint8 type) WARN_UNUSED_RESULT; |
| 97 CheckBool GenerateElfRelocations(Elf32_Word pending_elf_relocation_table, | 98 CheckBool GenerateElfRelocations(Elf32_Word pending_elf_relocation_table, |
| 98 SinkStream *buffer) WARN_UNUSED_RESULT; | 99 SinkStream *buffer) WARN_UNUSED_RESULT; |
| 99 CheckBool DefineLabelCommon(RvaVector*, int, RVA) WARN_UNUSED_RESULT; | 100 CheckBool DefineLabelCommon(RvaVector*, int, RVA) WARN_UNUSED_RESULT; |
| 100 void FinishLabelsCommon(RvaVector* addresses); | 101 void FinishLabelsCommon(RvaVector* addresses); |
| 101 | 102 |
| 102 // Decodes and evaluates courgette ops for ARM rel32 addresses. | 103 // Decodes and evaluates courgette ops for ARM rel32 addresses. |
| 103 CheckBool EvaluateRel32ARM(OP op, size_t& ix_rel32_ix, RVA& current_rva, | 104 CheckBool EvaluateRel32ARM(OP op, size_t& ix_rel32_ix, RVA& current_rva, |
| 104 SinkStream* output); | 105 SinkStream* output); |
| 105 | 106 |
| 106 // Binary assembly language tables. | 107 // Binary assembly language tables. |
| 107 uint64 image_base_; | 108 uint64 image_base_; |
| 108 RvaVector rel32_rva_; | 109 RvaVector rel32_rva_; |
| 109 RvaVector abs32_rva_; | 110 RvaVector abs32_rva_; |
| 110 OPVector ops_; | 111 OPVector ops_; |
| 111 RvaVector origins_; | 112 RvaVector origins_; |
| 112 UInt32Vector copy_counts_; | 113 SizeTVector copy_counts_; |
| 113 UInt8Vector copy_bytes_; | 114 UInt8Vector copy_bytes_; |
| 114 UInt32Vector rel32_ix_; | 115 UInt32Vector rel32_ix_; |
| 115 UInt32Vector abs32_ix_; | 116 UInt32Vector abs32_ix_; |
| 116 | 117 |
| 117 // Table of the addresses containing abs32 relocations; computed during | 118 // Table of the addresses containing abs32 relocations; computed during |
| 118 // assembly, used to generate base relocation table. | 119 // assembly, used to generate base relocation table. |
| 119 UInt32Vector abs32_relocs_; | 120 UInt32Vector abs32_relocs_; |
| 120 | 121 |
| 121 DISALLOW_COPY_AND_ASSIGN(EncodedProgram); | 122 DISALLOW_COPY_AND_ASSIGN(EncodedProgram); |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 } // namespace courgette | 125 } // namespace courgette |
| 125 #endif // COURGETTE_ENCODED_PROGRAM_H_ | 126 #endif // COURGETTE_ENCODED_PROGRAM_H_ |
| OLD | NEW |