summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Mips/MipsJITInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/Mips/MipsJITInfo.cpp')
-rw-r--r--llvm/lib/Target/Mips/MipsJITInfo.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Target/Mips/MipsJITInfo.cpp b/llvm/lib/Target/Mips/MipsJITInfo.cpp
index e3f6a753c40..a0ee722996d 100644
--- a/llvm/lib/Target/Mips/MipsJITInfo.cpp
+++ b/llvm/lib/Target/Mips/MipsJITInfo.cpp
@@ -218,10 +218,16 @@ void MipsJITInfo::relocate(void *Function, MachineRelocation *MR,
*((unsigned*) RelocPos) |= (unsigned) ResultPtr;
break;
- case Mips::reloc_mips_lo:
- ResultPtr = ResultPtr & 0xffff;
+ case Mips::reloc_mips_lo: {
+ // Addend is needed for unaligned load/store instructions, where offset
+ // for the second load/store in the expanded instruction sequence must
+ // be modified by +1 or +3. Otherwise, Addend is 0.
+ int Addend = *((unsigned*) RelocPos) & 0xffff;
+ ResultPtr = (ResultPtr + Addend) & 0xffff;
+ *((unsigned*) RelocPos) &= 0xffff0000;
*((unsigned*) RelocPos) |= (unsigned) ResultPtr;
break;
+ }
default:
llvm_unreachable("ERROR: Unknown Mips relocation.");
OpenPOWER on IntegriCloud