Get PIC jump table working.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58869 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/ARM/ARMJITInfo.cpp b/lib/Target/ARM/ARMJITInfo.cpp
index 96918fd..52036ba 100644
--- a/lib/Target/ARM/ARMJITInfo.cpp
+++ b/lib/Target/ARM/ARMJITInfo.cpp
@@ -170,9 +170,14 @@
intptr_t ARMJITInfo::resolveRelocDestAddr(MachineRelocation *MR) const {
ARM::RelocationType RT = (ARM::RelocationType)MR->getRelocationType();
- if (RT == ARM::reloc_arm_jt_base)
+ if (RT == ARM::reloc_arm_pic_jt)
+ // Destination address - jump table base.
+ return (intptr_t)(MR->getResultPointer()) - MR->getConstantVal();
+ else if (RT == ARM::reloc_arm_jt_base)
+ // Jump table base address.
return getJumpTableBaseAddr(MR->getJumpTableIndex());
else if (RT == ARM::reloc_arm_cp_entry)
+ // Constant pool entry address.
return getConstantPoolEntryAddr(MR->getConstantPoolIndex());
else if (RT == ARM::reloc_arm_machine_cp_entry) {
const MachineConstantPoolEntry &MCPE = (*MCPEs)[MR->getConstantVal()];
@@ -196,8 +201,6 @@
unsigned NumRelocs, unsigned char* GOTBase) {
for (unsigned i = 0; i != NumRelocs; ++i, ++MR) {
void *RelocPos = (char*)Function + MR->getMachineCodeOffset();
- // If this is a constpool relocation, get the address of the
- // constpool_entry instruction.
intptr_t ResultPtr = resolveRelocDestAddr(MR);
switch ((ARM::RelocationType)MR->getRelocationType()) {
case ARM::reloc_arm_cp_entry:
@@ -220,6 +223,7 @@
*((unsigned*)RelocPos) |= 0xF << 16;
break;
}
+ case ARM::reloc_arm_pic_jt:
case ARM::reloc_arm_machine_cp_entry:
case ARM::reloc_arm_absolute: {
// These addresses have already been resolved.
@@ -244,12 +248,6 @@
*((unsigned*)RelocPos) |= ResultPtr;
break;
}
- case ARM::reloc_arm_pic_jt: {
- // PIC JT entry is destination - JT base.
- ResultPtr = ResultPtr - (intptr_t)RelocPos;
- *((unsigned*)RelocPos) |= ResultPtr;
- break;
- }
}
}
}