summaryrefslogtreecommitdiffstats
path: root/courgette/assembly_program.cc
diff options
context:
space:
mode:
authordgarrett@chromium.org <dgarrett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-07 22:49:15 +0000
committerdgarrett@chromium.org <dgarrett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-07 22:49:15 +0000
commit88da5078df0e51dc1c56dac1aa92608a53a03803 (patch)
tree93c6b467379da5dd3ef243e3f0e3bc353b4f3333 /courgette/assembly_program.cc
parent2ca59863a57ed182b9b5a3c89b6212c10e94ec06 (diff)
downloadchromium_src-88da5078df0e51dc1c56dac1aa92608a53a03803.zip
chromium_src-88da5078df0e51dc1c56dac1aa92608a53a03803.tar.gz
chromium_src-88da5078df0e51dc1c56dac1aa92608a53a03803.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/8428009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108929 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'courgette/assembly_program.cc')
-rw-r--r--courgette/assembly_program.cc32
1 files changed, 24 insertions, 8 deletions
diff --git a/courgette/assembly_program.cc b/courgette/assembly_program.cc
index f759e16..9225578 100644
--- a/courgette/assembly_program.cc
+++ b/courgette/assembly_program.cc
@@ -22,7 +22,8 @@ namespace courgette {
// Opcodes of simple assembly language
enum OP {
ORIGIN, // ORIGIN <rva> - set current address for assembly.
- MAKERELOCS, // Generates a base relocation table.
+ MAKEPERELOCS, // Generates a base relocation table.
+ MAKEELFRELOCS, // Generates a base relocation table.
DEFBYTE, // DEFBYTE <value> - emit a byte literal.
REL32, // REL32 <label> - emit a rel32 encoded reference to 'label'.
ABS32, // REL32 <label> - emit am abs32 encoded reference to 'label'.
@@ -58,10 +59,16 @@ class OriginInstruction : public Instruction {
RVA rva_;
};
-// Emits an entire base relocation table.
-class MakeRelocsInstruction : public Instruction {
+// Emits an entire PE base relocation table.
+class PeRelocsInstruction : public Instruction {
public:
- MakeRelocsInstruction() : Instruction(MAKERELOCS) {}
+ PeRelocsInstruction() : Instruction(MAKEPERELOCS) {}
+};
+
+// Emits an ELF relocation table.
+class ElfRelocsInstruction : public Instruction {
+ public:
+ ElfRelocsInstruction() : Instruction(MAKEELFRELOCS) {}
};
// Emits a single byte.
@@ -108,8 +115,12 @@ AssemblyProgram::~AssemblyProgram() {
DeleteContainedLabels(abs32_labels_);
}
-CheckBool AssemblyProgram::EmitMakeRelocsInstruction() {
- return Emit(new(std::nothrow) MakeRelocsInstruction());
+CheckBool AssemblyProgram::EmitPeRelocsInstruction() {
+ return Emit(new(std::nothrow) PeRelocsInstruction());
+}
+
+CheckBool AssemblyProgram::EmitElfRelocationInstruction() {
+ return Emit(new(std::nothrow) ElfRelocsInstruction());
}
CheckBool AssemblyProgram::EmitOriginInstruction(RVA rva) {
@@ -357,8 +368,13 @@ EncodedProgram* AssemblyProgram::Encode() const {
return NULL;
break;
}
- case MAKERELOCS: {
- if (!encoded->AddMakeRelocs())
+ case MAKEPERELOCS: {
+ if (!encoded->AddPeMakeRelocs())
+ return NULL;
+ break;
+ }
+ case MAKEELFRELOCS: {
+ if (!encoded->AddElfMakeRelocs())
return NULL;
break;
}