summaryrefslogtreecommitdiffstats
path: root/courgette/encoded_program.h
diff options
context:
space:
mode:
authordgarrett@chromium.org <dgarrett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-08 20:32:26 +0000
committerdgarrett@chromium.org <dgarrett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-08 20:32:26 +0000
commit4b3d192b4f437336378b175372b417451943ab93 (patch)
tree0e78c58f4fa696b9bf0c48c1b4d2c6dcafe8818c /courgette/encoded_program.h
parent8008f0a0e3242e638fc7209ace9311981de11d3b (diff)
downloadchromium_src-4b3d192b4f437336378b175372b417451943ab93.zip
chromium_src-4b3d192b4f437336378b175372b417451943ab93.tar.gz
chromium_src-4b3d192b4f437336378b175372b417451943ab93.tar.bz2
Add Elf 32 Support to Courgette.
This change takes advantage of recent refactoring and adds support for Elf X86 32 executables to courgette. It should have no effect on handling of Windows PE executables. We have planned ahead to be able to restrict the code size of the courgette library in different cases to reduce patcher sizes, but this change does not yet take advantage of that (all platforms are supported everywhere). Also, the patcher class currently contains a very small amount of Elf/PE specific code for recreating relocation tables that cannot (currently) be compiled out. BUG=chromium-os:22149 TEST=Please verify that Chrome/Chromium patches can still be generated and work. Also, please see how much the updater executable which is downloaded to users has changed in size since R16. Review URL: http://codereview.chromium.org/8477045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'courgette/encoded_program.h')
-rw-r--r--courgette/encoded_program.h26
1 files changed, 15 insertions, 11 deletions
diff --git a/courgette/encoded_program.h b/courgette/encoded_program.h
index b120353..62f1439 100644
--- a/courgette/encoded_program.h
+++ b/courgette/encoded_program.h
@@ -43,7 +43,8 @@ class EncodedProgram {
CheckBool AddCopy(uint32 count, const void* bytes) WARN_UNUSED_RESULT;
CheckBool AddRel32(int label_index) WARN_UNUSED_RESULT;
CheckBool AddAbs32(int label_index) WARN_UNUSED_RESULT;
- CheckBool AddMakeRelocs() WARN_UNUSED_RESULT;
+ CheckBool AddPeMakeRelocs() WARN_UNUSED_RESULT;
+ CheckBool AddElfMakeRelocs() WARN_UNUSED_RESULT;
// (3) Serialize binary assembly language tables to a set of streams.
CheckBool WriteTo(SinkStreamSet* streams) WARN_UNUSED_RESULT;
@@ -58,16 +59,18 @@ class EncodedProgram {
private:
// Binary assembly language operations.
+ // These are part of the patch format. Reusing an existing value will
+ // break backwards compatibility.
enum OP {
- ORIGIN, // ORIGIN <rva> - set address for subsequent assembly.
- COPY, // COPY <count> <bytes> - copy bytes to output.
- COPY1, // COPY1 <byte> - same as COPY 1 <byte>.
- REL32, // REL32 <index> - emit rel32 encoded reference to address at
- // address table offset <index>
- ABS32, // ABS32 <index> - emit abs32 encoded reference to address at
- // address table offset <index>
- MAKE_BASE_RELOCATION_TABLE, // Emit base relocation table blocks.
- OP_LAST
+ 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.
};
typedef NoThrowBuffer<RVA> RvaVector;
@@ -76,7 +79,8 @@ class EncodedProgram {
typedef NoThrowBuffer<OP> OPVector;
void DebuggingSummary();
- CheckBool GenerateBaseRelocations(SinkStream *buffer) WARN_UNUSED_RESULT;
+ CheckBool GeneratePeRelocations(SinkStream *buffer) WARN_UNUSED_RESULT;
+ CheckBool GenerateElfRelocations(SinkStream *buffer) WARN_UNUSED_RESULT;
CheckBool DefineLabelCommon(RvaVector*, int, RVA) WARN_UNUSED_RESULT;
void FinishLabelsCommon(RvaVector* addresses);