Initial JIT support for ARM by Raul Fernandes Herbster.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40887 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/ARM/ARMJITInfo.cpp b/lib/Target/ARM/ARMJITInfo.cpp
index 294a12b..9622a29 100644
--- a/lib/Target/ARM/ARMJITInfo.cpp
+++ b/lib/Target/ARM/ARMJITInfo.cpp
@@ -127,5 +127,23 @@
 /// referenced global symbols.
 void ARMJITInfo::relocate(void *Function, MachineRelocation *MR,
                           unsigned NumRelocs, unsigned char* GOTBase) {
-
+  for (unsigned i = 0; i != NumRelocs; ++i, ++MR) {
+    void *RelocPos = (char*)Function + MR->getMachineCodeOffset();
+    intptr_t ResultPtr = (intptr_t)MR->getResultPointer();
+    switch ((ARM::RelocationType)MR->getRelocationType()) {
+    case ARM::reloc_arm_relative: {
+      // PC relative relocation
+      *((unsigned*)RelocPos) += (unsigned)ResultPtr;
+      break;
+    }
+    case ARM::reloc_arm_absolute:
+      break;
+    case ARM::reloc_arm_branch: {
+      // relocation to b and bl instructions
+      ResultPtr = (ResultPtr-(intptr_t)RelocPos) >> 2;
+      *((unsigned*)RelocPos) |= ResultPtr;
+      break;
+    }
+    }
+  }
 }