[Courgette] Clean up EnsembleProgram.
Before commiting the main CL for AssemblyProgram reduction, we clean up
EnsenbleProgram to reduce noise. Details:
- Fix includes and comments; run linter and formatter.
- EncodedProgram::EvaluateRel32ARM(): Change non-const ref params to
pointers.
BUG=660980
Review-Url: https://codereview.chromium.org/2858593002
Cr-Commit-Position: refs/heads/master@{#468685}
diff --git a/courgette/encoded_program.h b/courgette/encoded_program.h
index 814a45c..1169331 100644
--- a/courgette/encoded_program.h
+++ b/courgette/encoded_program.h
@@ -12,8 +12,8 @@
#include <vector>
#include "base/macros.h"
-#include "courgette/disassembler.h"
-#include "courgette/label_manager.h"
+#include "courgette/courgette.h"
+#include "courgette/image_utils.h"
#include "courgette/memory_allocator.h"
#include "courgette/types_elf.h"
@@ -32,14 +32,14 @@
const int kStreamLimit = 9;
+class LabelManager;
class SinkStream;
class SinkStreamSet;
class SourceStreamSet;
-// An EncodedProgram is a set of tables that contain a simple 'binary assembly
-// language' that can be assembled to produce a sequence of bytes, for example,
-// a Windows 32-bit executable.
-//
+// EncodedProgram encodes Courgette's simple "binary assembly language", which
+// can be assembled to produce a sequence of bytes (e.g., a Windows 32-bit
+// executable).
class EncodedProgram {
public:
EncodedProgram();
@@ -85,27 +85,27 @@
// These are part of the patch format. Reusing an existing value will
// break backwards compatibility.
enum OP {
- ORIGIN = 0, // ORIGIN <rva> - set address for subsequent assembly.
- COPY = 1, // COPY <count> <bytes> - copy bytes to output.
- COPY1 = 2, // COPY1 <byte> - same as COPY 1 <byte>.
- REL32 = 3, // REL32 <index> - emit rel32 encoded reference to address at
- // address table offset <index>
- ABS32 = 4, // ABS32 <index> - emit abs32 encoded reference to address at
- // address table offset <index>
- MAKE_PE_RELOCATION_TABLE = 5, // Emit PE base relocation table blocks.
- MAKE_ELF_RELOCATION_TABLE = 6, // Emit Elf relocation table for X86
- MAKE_ELF_ARM_RELOCATION_TABLE = 7, // Emit Elf relocation table for ARM
- MAKE_PE64_RELOCATION_TABLE = 8, // Emit PE64 base relocation table blocks.
- ABS64 = 9, // ABS64 <index> - emit abs64 encoded reference to address at
- // address table offset <index>
+ ORIGIN = 0, // ORIGIN <rva> - set address for subsequent assembly.
+ COPY = 1, // COPY <count> <bytes> - copy bytes to output.
+ COPY1 = 2, // COPY1 <byte> - same as COPY 1 <byte>.
+ REL32 = 3, // REL32 <index> - emit rel32 encoded reference to address at
+ // address table offset <index>
+ ABS32 = 4, // ABS32 <index> - emit abs32 encoded reference to address at
+ // address table offset <index>
+ MAKE_PE_RELOCATION_TABLE = 5, // Emit PE base relocation table blocks.
+ MAKE_ELF_RELOCATION_TABLE = 6, // Emit Elf relocation table for X86
+ MAKE_ELF_ARM_RELOCATION_TABLE = 7, // Emit Elf relocation table for ARM
+ MAKE_PE64_RELOCATION_TABLE = 8, // Emit PE64 base relocation table blocks.
+ ABS64 = 9, // ABS64 <index> - emit abs64 encoded reference to address at
+ // address table offset <index>
// ARM reserves 0x1000-LAST_ARM, bits 13-16 define the opcode
// subset, and 1-12 are the compressed ARM op.
- REL32ARM8 = 0x1000,
- REL32ARM11 = 0x2000,
- REL32ARM24 = 0x3000,
- REL32ARM25 = 0x4000,
- REL32ARM21 = 0x5000,
- LAST_ARM = 0x5FFF,
+ REL32ARM8 = 0x1000,
+ REL32ARM11 = 0x2000,
+ REL32ARM24 = 0x3000,
+ REL32ARM25 = 0x4000,
+ REL32ARM21 = 0x5000,
+ LAST_ARM = 0x5FFF,
};
typedef NoThrowBuffer<RVA> RvaVector;
@@ -126,10 +126,12 @@
CheckBool GeneratePeRelocations(SinkStream* buffer,
uint8_t type) WARN_UNUSED_RESULT;
CheckBool GenerateElfRelocations(Elf32_Word pending_elf_relocation_table,
- SinkStream *buffer) WARN_UNUSED_RESULT;
+ SinkStream* buffer) WARN_UNUSED_RESULT;
// Decodes and evaluates courgette ops for ARM rel32 addresses.
- CheckBool EvaluateRel32ARM(OP op, size_t& ix_rel32_ix, RVA& current_rva,
+ CheckBool EvaluateRel32ARM(OP op,
+ size_t* ix_rel32_ix,
+ RVA* current_rva,
SinkStream* output);
// Binary assembly language tables.