Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: courgette/encoded_program.h

Issue 8477045: Add Elf 32 Support to Courgette. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Remove debug printf present by mistake. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « courgette/encode_decode_unittest.cc ('k') | courgette/encoded_program.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 CheckBool DefineAbs32Label(int index, RVA address) WARN_UNUSED_RESULT; 36 CheckBool DefineAbs32Label(int index, RVA address) WARN_UNUSED_RESULT;
37 void EndLabels(); 37 void EndLabels();
38 38
39 // (3) Add instructions in the order needed to generate bytes of file. 39 // (3) Add instructions in the order needed to generate bytes of file.
40 // NOTE: If any of these methods ever fail, the EncodedProgram instance 40 // NOTE: If any of these methods ever fail, the EncodedProgram instance
41 // has failed and should be discarded. 41 // has failed and should be discarded.
42 CheckBool AddOrigin(RVA rva) WARN_UNUSED_RESULT; 42 CheckBool AddOrigin(RVA rva) WARN_UNUSED_RESULT;
43 CheckBool AddCopy(uint32 count, const void* bytes) WARN_UNUSED_RESULT; 43 CheckBool AddCopy(uint32 count, const void* bytes) WARN_UNUSED_RESULT;
44 CheckBool AddRel32(int label_index) WARN_UNUSED_RESULT; 44 CheckBool AddRel32(int label_index) WARN_UNUSED_RESULT;
45 CheckBool AddAbs32(int label_index) WARN_UNUSED_RESULT; 45 CheckBool AddAbs32(int label_index) WARN_UNUSED_RESULT;
46 CheckBool AddMakeRelocs() WARN_UNUSED_RESULT; 46 CheckBool AddPeMakeRelocs() WARN_UNUSED_RESULT;
47 CheckBool AddElfMakeRelocs() WARN_UNUSED_RESULT;
47 48
48 // (3) Serialize binary assembly language tables to a set of streams. 49 // (3) Serialize binary assembly language tables to a set of streams.
49 CheckBool WriteTo(SinkStreamSet* streams) WARN_UNUSED_RESULT; 50 CheckBool WriteTo(SinkStreamSet* streams) WARN_UNUSED_RESULT;
50 51
51 // Using an EncodedProgram to generate a byte stream: 52 // Using an EncodedProgram to generate a byte stream:
52 // 53 //
53 // (4) Deserializes a fresh EncodedProgram from a set of streams. 54 // (4) Deserializes a fresh EncodedProgram from a set of streams.
54 bool ReadFrom(SourceStreamSet* streams); 55 bool ReadFrom(SourceStreamSet* streams);
55 56
56 // (5) Assembles the 'binary assembly language' into final file. 57 // (5) Assembles the 'binary assembly language' into final file.
57 CheckBool AssembleTo(SinkStream* buffer) WARN_UNUSED_RESULT; 58 CheckBool AssembleTo(SinkStream* buffer) WARN_UNUSED_RESULT;
58 59
59 private: 60 private:
60 // Binary assembly language operations. 61 // Binary assembly language operations.
62 // These are part of the patch format. Reusing an existing value will
63 // break backwards compatibility.
61 enum OP { 64 enum OP {
62 ORIGIN, // ORIGIN <rva> - set address for subsequent assembly. 65 ORIGIN = 0, // ORIGIN <rva> - set address for subsequent assembly.
63 COPY, // COPY <count> <bytes> - copy bytes to output. 66 COPY = 1, // COPY <count> <bytes> - copy bytes to output.
64 COPY1, // COPY1 <byte> - same as COPY 1 <byte>. 67 COPY1 = 2, // COPY1 <byte> - same as COPY 1 <byte>.
65 REL32, // REL32 <index> - emit rel32 encoded reference to address at 68 REL32 = 3, // REL32 <index> - emit rel32 encoded reference to address at
66 // address table offset <index> 69 // address table offset <index>
67 ABS32, // ABS32 <index> - emit abs32 encoded reference to address at 70 ABS32 = 4, // ABS32 <index> - emit abs32 encoded reference to address at
68 // address table offset <index> 71 // address table offset <index>
69 MAKE_BASE_RELOCATION_TABLE, // Emit base relocation table blocks. 72 MAKE_PE_RELOCATION_TABLE = 5, // Emit PE base relocation table blocks.
70 OP_LAST 73 MAKE_ELF_RELOCATION_TABLE = 6, // Emit Elf relocation table.
71 }; 74 };
72 75
73 typedef NoThrowBuffer<RVA> RvaVector; 76 typedef NoThrowBuffer<RVA> RvaVector;
74 typedef NoThrowBuffer<uint32> UInt32Vector; 77 typedef NoThrowBuffer<uint32> UInt32Vector;
75 typedef NoThrowBuffer<uint8> UInt8Vector; 78 typedef NoThrowBuffer<uint8> UInt8Vector;
76 typedef NoThrowBuffer<OP> OPVector; 79 typedef NoThrowBuffer<OP> OPVector;
77 80
78 void DebuggingSummary(); 81 void DebuggingSummary();
79 CheckBool GenerateBaseRelocations(SinkStream *buffer) WARN_UNUSED_RESULT; 82 CheckBool GeneratePeRelocations(SinkStream *buffer) WARN_UNUSED_RESULT;
83 CheckBool GenerateElfRelocations(SinkStream *buffer) WARN_UNUSED_RESULT;
80 CheckBool DefineLabelCommon(RvaVector*, int, RVA) WARN_UNUSED_RESULT; 84 CheckBool DefineLabelCommon(RvaVector*, int, RVA) WARN_UNUSED_RESULT;
81 void FinishLabelsCommon(RvaVector* addresses); 85 void FinishLabelsCommon(RvaVector* addresses);
82 86
83 // Binary assembly language tables. 87 // Binary assembly language tables.
84 uint64 image_base_; 88 uint64 image_base_;
85 RvaVector rel32_rva_; 89 RvaVector rel32_rva_;
86 RvaVector abs32_rva_; 90 RvaVector abs32_rva_;
87 OPVector ops_; 91 OPVector ops_;
88 RvaVector origins_; 92 RvaVector origins_;
89 UInt32Vector copy_counts_; 93 UInt32Vector copy_counts_;
90 UInt8Vector copy_bytes_; 94 UInt8Vector copy_bytes_;
91 UInt32Vector rel32_ix_; 95 UInt32Vector rel32_ix_;
92 UInt32Vector abs32_ix_; 96 UInt32Vector abs32_ix_;
93 97
94 // Table of the addresses containing abs32 relocations; computed during 98 // Table of the addresses containing abs32 relocations; computed during
95 // assembly, used to generate base relocation table. 99 // assembly, used to generate base relocation table.
96 UInt32Vector abs32_relocs_; 100 UInt32Vector abs32_relocs_;
97 101
98 DISALLOW_COPY_AND_ASSIGN(EncodedProgram); 102 DISALLOW_COPY_AND_ASSIGN(EncodedProgram);
99 }; 103 };
100 104
101 } // namespace courgette 105 } // namespace courgette
102 #endif // COURGETTE_ENCODED_PROGRAM_H_ 106 #endif // COURGETTE_ENCODED_PROGRAM_H_
OLDNEW
« no previous file with comments | « courgette/encode_decode_unittest.cc ('k') | courgette/encoded_program.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698