aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/ARM/ARMJITInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/ARM/ARMJITInfo.cpp')
-rw-r--r--lib/Target/ARM/ARMJITInfo.cpp20
1 files changed, 19 insertions, 1 deletions
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 @@ void *ARMJITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
/// 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;
+ }
+ }
+ }
}