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

Side by Side Diff: courgette/encoded_program.h

Issue 1543643002: Switch to standard integer types in courgette/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years 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
« 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 <stddef.h>
9 #include <stdint.h>
10
8 #include <vector> 11 #include <vector>
9 12
10 #include "base/basictypes.h" 13 #include "base/macros.h"
11 #include "courgette/disassembler.h" 14 #include "courgette/disassembler.h"
12 #include "courgette/memory_allocator.h" 15 #include "courgette/memory_allocator.h"
13 #include "courgette/types_elf.h" 16 #include "courgette/types_elf.h"
14 17
15 namespace courgette { 18 namespace courgette {
16 19
17 // Stream indexes. 20 // Stream indexes.
18 const int kStreamMisc = 0; 21 const int kStreamMisc = 0;
19 const int kStreamOps = 1; 22 const int kStreamOps = 1;
20 const int kStreamBytes = 2; 23 const int kStreamBytes = 2;
(...skipping 15 matching lines...) Expand all
36 // a Windows 32-bit executable. 39 // a Windows 32-bit executable.
37 // 40 //
38 class EncodedProgram { 41 class EncodedProgram {
39 public: 42 public:
40 EncodedProgram(); 43 EncodedProgram();
41 ~EncodedProgram(); 44 ~EncodedProgram();
42 45
43 // Generating an EncodedProgram: 46 // Generating an EncodedProgram:
44 // 47 //
45 // (1) The image base can be specified at any time. 48 // (1) The image base can be specified at any time.
46 void set_image_base(uint64 base) { image_base_ = base; } 49 void set_image_base(uint64_t base) { image_base_ = base; }
47 50
48 // (2) Address tables and indexes defined first. 51 // (2) Address tables and indexes defined first.
49 CheckBool DefineRel32Label(int index, RVA address) WARN_UNUSED_RESULT; 52 CheckBool DefineRel32Label(int index, RVA address) WARN_UNUSED_RESULT;
50 CheckBool DefineAbs32Label(int index, RVA address) WARN_UNUSED_RESULT; 53 CheckBool DefineAbs32Label(int index, RVA address) WARN_UNUSED_RESULT;
51 void EndLabels(); 54 void EndLabels();
52 55
53 // (3) Add instructions in the order needed to generate bytes of file. 56 // (3) Add instructions in the order needed to generate bytes of file.
54 // NOTE: If any of these methods ever fail, the EncodedProgram instance 57 // NOTE: If any of these methods ever fail, the EncodedProgram instance
55 // has failed and should be discarded. 58 // has failed and should be discarded.
56 CheckBool AddOrigin(RVA rva) WARN_UNUSED_RESULT; 59 CheckBool AddOrigin(RVA rva) WARN_UNUSED_RESULT;
57 CheckBool AddCopy(size_t count, const void* bytes) WARN_UNUSED_RESULT; 60 CheckBool AddCopy(size_t count, const void* bytes) WARN_UNUSED_RESULT;
58 CheckBool AddRel32(int label_index) WARN_UNUSED_RESULT; 61 CheckBool AddRel32(int label_index) WARN_UNUSED_RESULT;
59 CheckBool AddRel32ARM(uint16 op, int label_index) WARN_UNUSED_RESULT; 62 CheckBool AddRel32ARM(uint16_t op, int label_index) WARN_UNUSED_RESULT;
60 CheckBool AddAbs32(int label_index) WARN_UNUSED_RESULT; 63 CheckBool AddAbs32(int label_index) WARN_UNUSED_RESULT;
61 CheckBool AddAbs64(int label_index) WARN_UNUSED_RESULT; 64 CheckBool AddAbs64(int label_index) WARN_UNUSED_RESULT;
62 CheckBool AddPeMakeRelocs(ExecutableType kind) WARN_UNUSED_RESULT; 65 CheckBool AddPeMakeRelocs(ExecutableType kind) WARN_UNUSED_RESULT;
63 CheckBool AddElfMakeRelocs() WARN_UNUSED_RESULT; 66 CheckBool AddElfMakeRelocs() WARN_UNUSED_RESULT;
64 CheckBool AddElfARMMakeRelocs() WARN_UNUSED_RESULT; 67 CheckBool AddElfARMMakeRelocs() WARN_UNUSED_RESULT;
65 68
66 // (3) Serialize binary assembly language tables to a set of streams. 69 // (3) Serialize binary assembly language tables to a set of streams.
67 CheckBool WriteTo(SinkStreamSet* streams) WARN_UNUSED_RESULT; 70 CheckBool WriteTo(SinkStreamSet* streams) WARN_UNUSED_RESULT;
68 71
69 // Using an EncodedProgram to generate a byte stream: 72 // Using an EncodedProgram to generate a byte stream:
(...skipping 27 matching lines...) Expand all
97 REL32ARM8 = 0x1000, 100 REL32ARM8 = 0x1000,
98 REL32ARM11 = 0x2000, 101 REL32ARM11 = 0x2000,
99 REL32ARM24 = 0x3000, 102 REL32ARM24 = 0x3000,
100 REL32ARM25 = 0x4000, 103 REL32ARM25 = 0x4000,
101 REL32ARM21 = 0x5000, 104 REL32ARM21 = 0x5000,
102 LAST_ARM = 0x5FFF, 105 LAST_ARM = 0x5FFF,
103 }; 106 };
104 107
105 typedef NoThrowBuffer<RVA> RvaVector; 108 typedef NoThrowBuffer<RVA> RvaVector;
106 typedef NoThrowBuffer<size_t> SizeTVector; 109 typedef NoThrowBuffer<size_t> SizeTVector;
107 typedef NoThrowBuffer<uint32> UInt32Vector; 110 typedef NoThrowBuffer<uint32_t> UInt32Vector;
108 typedef NoThrowBuffer<uint8> UInt8Vector; 111 typedef NoThrowBuffer<uint8_t> UInt8Vector;
109 typedef NoThrowBuffer<OP> OPVector; 112 typedef NoThrowBuffer<OP> OPVector;
110 113
111 void DebuggingSummary(); 114 void DebuggingSummary();
112 CheckBool GeneratePeRelocations(SinkStream *buffer, 115 CheckBool GeneratePeRelocations(SinkStream* buffer,
113 uint8 type) WARN_UNUSED_RESULT; 116 uint8_t type) WARN_UNUSED_RESULT;
114 CheckBool GenerateElfRelocations(Elf32_Word pending_elf_relocation_table, 117 CheckBool GenerateElfRelocations(Elf32_Word pending_elf_relocation_table,
115 SinkStream *buffer) WARN_UNUSED_RESULT; 118 SinkStream *buffer) WARN_UNUSED_RESULT;
116 CheckBool DefineLabelCommon(RvaVector*, int, RVA) WARN_UNUSED_RESULT; 119 CheckBool DefineLabelCommon(RvaVector*, int, RVA) WARN_UNUSED_RESULT;
117 void FinishLabelsCommon(RvaVector* addresses); 120 void FinishLabelsCommon(RvaVector* addresses);
118 121
119 // Decodes and evaluates courgette ops for ARM rel32 addresses. 122 // Decodes and evaluates courgette ops for ARM rel32 addresses.
120 CheckBool EvaluateRel32ARM(OP op, size_t& ix_rel32_ix, RVA& current_rva, 123 CheckBool EvaluateRel32ARM(OP op, size_t& ix_rel32_ix, RVA& current_rva,
121 SinkStream* output); 124 SinkStream* output);
122 125
123 // Binary assembly language tables. 126 // Binary assembly language tables.
124 uint64 image_base_; 127 uint64_t image_base_;
125 RvaVector rel32_rva_; 128 RvaVector rel32_rva_;
126 RvaVector abs32_rva_; 129 RvaVector abs32_rva_;
127 OPVector ops_; 130 OPVector ops_;
128 RvaVector origins_; 131 RvaVector origins_;
129 SizeTVector copy_counts_; 132 SizeTVector copy_counts_;
130 UInt8Vector copy_bytes_; 133 UInt8Vector copy_bytes_;
131 UInt32Vector rel32_ix_; 134 UInt32Vector rel32_ix_;
132 UInt32Vector abs32_ix_; 135 UInt32Vector abs32_ix_;
133 136
134 // Table of the addresses containing abs32 relocations; computed during 137 // Table of the addresses containing abs32 relocations; computed during
135 // assembly, used to generate base relocation table. 138 // assembly, used to generate base relocation table.
136 UInt32Vector abs32_relocs_; 139 UInt32Vector abs32_relocs_;
137 140
138 DISALLOW_COPY_AND_ASSIGN(EncodedProgram); 141 DISALLOW_COPY_AND_ASSIGN(EncodedProgram);
139 }; 142 };
140 143
141 } // namespace courgette 144 } // namespace courgette
142 #endif // COURGETTE_ENCODED_PROGRAM_H_ 145 #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