diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-11-07 22:30:53 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-11-07 22:30:53 +0000 |
commit | 8467e2459a291164d8a0d95baac01dc7dc7195de (patch) | |
tree | 48a671ea424b76fa854ee40e1313b3723a6916eb /llvm/lib/Target/ARM/ARMJITInfo.cpp | |
parent | 077f686d4b453d595e5b1653f25cc285be9c556b (diff) | |
download | bcm5719-llvm-8467e2459a291164d8a0d95baac01dc7dc7195de.tar.gz bcm5719-llvm-8467e2459a291164d8a0d95baac01dc7dc7195de.zip |
Get PIC jump table working.
llvm-svn: 58869
Diffstat (limited to 'llvm/lib/Target/ARM/ARMJITInfo.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/ARMJITInfo.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/llvm/lib/Target/ARM/ARMJITInfo.cpp b/llvm/lib/Target/ARM/ARMJITInfo.cpp index 96918fd3259..52036ba3517 100644 --- a/llvm/lib/Target/ARM/ARMJITInfo.cpp +++ b/llvm/lib/Target/ARM/ARMJITInfo.cpp @@ -170,9 +170,14 @@ void *ARMJITInfo::emitFunctionStub(const Function* F, void *Fn, 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 @@ 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(); - // 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 @@ void ARMJITInfo::relocate(void *Function, MachineRelocation *MR, *((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 @@ void ARMJITInfo::relocate(void *Function, MachineRelocation *MR, *((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; - } } } } |