Correct way to handle CONSTPOOL_ENTRY instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58409 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/ARM/ARMJITInfo.cpp b/lib/Target/ARM/ARMJITInfo.cpp
index 3c50caa..6a2c253 100644
--- a/lib/Target/ARM/ARMJITInfo.cpp
+++ b/lib/Target/ARM/ARMJITInfo.cpp
@@ -174,8 +174,14 @@
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 @@
*((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