From f7c6effc44d6843ed2ed6d1a08a88c050486d752 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Tue, 7 Aug 2007 01:37:15 +0000 Subject: Initial JIT support for ARM by Raul Fernandes Herbster. llvm-svn: 40887 --- llvm/lib/Target/ARM/ARMJITInfo.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Target/ARM/ARMJITInfo.cpp') diff --git a/llvm/lib/Target/ARM/ARMJITInfo.cpp b/llvm/lib/Target/ARM/ARMJITInfo.cpp index 294a12bc786..9622a29272c 100644 --- a/llvm/lib/Target/ARM/ARMJITInfo.cpp +++ b/llvm/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; + } + } + } } -- cgit v1.2.3