OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // Using an EncodedProgram to generate a byte stream: | 48 // Using an EncodedProgram to generate a byte stream: |
49 // | 49 // |
50 // (4) Deserializes a fresh EncodedProgram from a set of streams. | 50 // (4) Deserializes a fresh EncodedProgram from a set of streams. |
51 bool ReadFrom(SourceStreamSet *streams); | 51 bool ReadFrom(SourceStreamSet *streams); |
52 | 52 |
53 // (5) Assembles the 'binary assembly language' into final file. | 53 // (5) Assembles the 'binary assembly language' into final file. |
54 bool AssembleTo(SinkStream *buffer); | 54 bool AssembleTo(SinkStream *buffer); |
55 | 55 |
56 private: | 56 private: |
57 enum OP; // Binary assembly language operations. | 57 // Binary assembly language operations. |
| 58 enum OP { |
| 59 ORIGIN, // ORIGIN <rva> - set address for subsequent assembly. |
| 60 COPY, // COPY <count> <bytes> - copy bytes to output. |
| 61 COPY1, // COPY1 <byte> - same as COPY 1 <byte>. |
| 62 REL32, // REL32 <index> - emit rel32 encoded reference to address at |
| 63 // address table offset <index> |
| 64 ABS32, // ABS32 <index> - emit abs32 encoded reference to address at |
| 65 // address table offset <index> |
| 66 MAKE_BASE_RELOCATION_TABLE, // Emit base relocation table blocks. |
| 67 OP_LAST |
| 68 }; |
58 | 69 |
59 void DebuggingSummary(); | 70 void DebuggingSummary(); |
60 void GenerateBaseRelocations(SinkStream *buffer); | 71 void GenerateBaseRelocations(SinkStream *buffer); |
61 void DefineLabelCommon(std::vector<RVA>*, int, RVA); | 72 void DefineLabelCommon(std::vector<RVA>*, int, RVA); |
62 void FinishLabelsCommon(std::vector<RVA>* addresses); | 73 void FinishLabelsCommon(std::vector<RVA>* addresses); |
63 | 74 |
64 // Binary assembly language tables. | 75 // Binary assembly language tables. |
65 uint64 image_base_; | 76 uint64 image_base_; |
66 std::vector<RVA> rel32_rva_; | 77 std::vector<RVA> rel32_rva_; |
67 std::vector<RVA> abs32_rva_; | 78 std::vector<RVA> abs32_rva_; |
68 std::vector<OP> ops_; | 79 std::vector<OP> ops_; |
69 std::vector<RVA> origins_; | 80 std::vector<RVA> origins_; |
70 std::vector<int> copy_counts_; | 81 std::vector<int> copy_counts_; |
71 std::vector<uint8> copy_bytes_; | 82 std::vector<uint8> copy_bytes_; |
72 std::vector<uint32> rel32_ix_; | 83 std::vector<uint32> rel32_ix_; |
73 std::vector<uint32> abs32_ix_; | 84 std::vector<uint32> abs32_ix_; |
74 | 85 |
75 // Table of the addresses containing abs32 relocations; computed during | 86 // Table of the addresses containing abs32 relocations; computed during |
76 // assembly, used to generate base relocation table. | 87 // assembly, used to generate base relocation table. |
77 std::vector<uint32> abs32_relocs_; | 88 std::vector<uint32> abs32_relocs_; |
78 | 89 |
79 DISALLOW_COPY_AND_ASSIGN(EncodedProgram); | 90 DISALLOW_COPY_AND_ASSIGN(EncodedProgram); |
80 }; | 91 }; |
81 | 92 |
82 } // namespace courgette | 93 } // namespace courgette |
83 #endif // COURGETTE_ENCODED_FORMAT_H_ | 94 #endif // COURGETTE_ENCODED_PROGRAM_H_ |
OLD | NEW |