diff options
Diffstat (limited to 'llvm/lib/Target/ARM/ARMJITInfo.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/ARMJITInfo.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Target/ARM/ARMJITInfo.cpp b/llvm/lib/Target/ARM/ARMJITInfo.cpp index 3c50caaf6d0..6a2c253ff11 100644 --- a/llvm/lib/Target/ARM/ARMJITInfo.cpp +++ b/llvm/lib/Target/ARM/ARMJITInfo.cpp @@ -174,8 +174,14 @@ 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(); + ARM::RelocationType RT = (ARM::RelocationType)MR->getRelocationType(); + // If this is a constpool relocation, get the address of the + // constpool_entry instruction. + intptr_t ResultPtr = (RT == ARM::reloc_arm_cp_entry) + ? getConstantPoolEntryAddr(MR->getConstantPoolIndex()) + : (intptr_t)MR->getResultPointer(); switch ((ARM::RelocationType)MR->getRelocationType()) { + case ARM::reloc_arm_cp_entry: case ARM::reloc_arm_relative: { // It is necessary to calculate the correct PC relative value. We // subtract the base addr from the target addr to form a byte offset. @@ -195,6 +201,10 @@ void ARMJITInfo::relocate(void *Function, MachineRelocation *MR, *((unsigned*)RelocPos) |= 0xF << 16; break; } + case ARM::reloc_arm_absolute: { + *((unsigned*)RelocPos) += (unsigned)ResultPtr; + break; + } case ARM::reloc_arm_branch: { // It is necessary to calculate the correct value of signed_immed_24 // field. We subtract the base addr from the target addr to form a |