Support for ARM 32-bit ELF binaries in Courgette
Notes for reviewers:
dgarrett: courgette correctness, ARM
benchan: style, correctness
BUG=258640,258645,258653
Review URL: https://chromiumcodereview.appspot.com/20099004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214873 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/courgette/encoded_program.h b/courgette/encoded_program.h
index 0de4f6b9..3eca364 100644
--- a/courgette/encoded_program.h
+++ b/courgette/encoded_program.h
@@ -43,6 +43,7 @@
CheckBool AddOrigin(RVA rva) WARN_UNUSED_RESULT;
CheckBool AddCopy(uint32 count, const void* bytes) WARN_UNUSED_RESULT;
CheckBool AddRel32(int label_index) WARN_UNUSED_RESULT;
+ CheckBool AddRel32ARM(uint16 op, int label_index) WARN_UNUSED_RESULT;
CheckBool AddAbs32(int label_index) WARN_UNUSED_RESULT;
CheckBool AddPeMakeRelocs() WARN_UNUSED_RESULT;
CheckBool AddElfMakeRelocs() WARN_UNUSED_RESULT;
@@ -74,6 +75,14 @@
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
+ // 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,
};
typedef NoThrowBuffer<RVA> RvaVector;
@@ -88,6 +97,10 @@
CheckBool DefineLabelCommon(RvaVector*, int, RVA) WARN_UNUSED_RESULT;
void FinishLabelsCommon(RvaVector* addresses);
+ // Decodes and evaluates courgette ops for ARM rel32 addresses.
+ CheckBool EvaluateRel32ARM(OP op, size_t& ix_rel32_ix, RVA& current_rva,
+ SinkStream* output);
+
// Binary assembly language tables.
uint64 image_base_;
RvaVector rel32_rva_;