[llvm] r197506 - [mips] Fix off by one issue when applying a fixup.
Matheus Almeida
matheus.almeida at imgtec.com
Tue Dec 17 09:10:00 PST 2013
Author: matheusalmeida
Date: Tue Dec 17 11:10:00 2013
New Revision: 197506
URL: http://llvm.org/viewvc/llvm-project?rev=197506&view=rev
Log:
[mips] Fix off by one issue when applying a fixup.
The branch offset for a R_MIPS_PC16 relocation is indeed a 16-bit signed
immediate.
Added:
llvm/trunk/test/MC/Mips/micromips-pc16-fixup.s
llvm/trunk/test/MC/Mips/mips-pc16-fixup.s
Modified:
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp?rev=197506&r1=197505&r2=197506&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp Tue Dec 17 11:10:00 2013
@@ -64,7 +64,7 @@ static unsigned adjustFixupValue(const M
// address range. Forcing a signed division because Value can be negative.
Value = (int64_t)Value / 4;
// We now check if Value can be encoded as a 16-bit signed immediate.
- if (!isIntN(15, Value) && Ctx)
+ if (!isIntN(16, Value) && Ctx)
Ctx->FatalError(Fixup.getLoc(), "out of range PC16 fixup");
break;
case Mips::fixup_Mips_26:
@@ -97,7 +97,7 @@ static unsigned adjustFixupValue(const M
// Forcing a signed division because Value can be negative.
Value = (int64_t)Value / 2;
// We now check if Value can be encoded as a 16-bit signed immediate.
- if (!isIntN(15, Value) && Ctx)
+ if (!isIntN(16, Value) && Ctx)
Ctx->FatalError(Fixup.getLoc(), "out of range PC16 fixup");
break;
}
Added: llvm/trunk/test/MC/Mips/micromips-pc16-fixup.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/micromips-pc16-fixup.s?rev=197506&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/micromips-pc16-fixup.s (added)
+++ llvm/trunk/test/MC/Mips/micromips-pc16-fixup.s Tue Dec 17 11:10:00 2013
@@ -0,0 +1,10 @@
+# RUN: llvm-mc %s -triple=mips-unknown-linux -mcpu=mips32r2 -arch=mips -mattr=+micromips 2>&1 -filetype=obj | FileCheck %s
+#
+# CHECK-NOT: LLVM ERROR: out of range PC16 fixup
+
+.text
+ b foo
+ .space 65536 - 8, 1 # -8 = size of b instr plus size of automatically inserted nop
+foo:
+ add $0,$0,$0
+
Added: llvm/trunk/test/MC/Mips/mips-pc16-fixup.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/mips-pc16-fixup.s?rev=197506&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/mips-pc16-fixup.s (added)
+++ llvm/trunk/test/MC/Mips/mips-pc16-fixup.s Tue Dec 17 11:10:00 2013
@@ -0,0 +1,10 @@
+# RUN: llvm-mc %s -triple=mips-unknown-linux -mcpu=mips32r2 -arch=mips 2>&1 -filetype=obj | FileCheck %s
+#
+# CHECK-NOT: LLVM ERROR: out of range PC16 fixup
+
+.text
+ b foo
+ .space 131072 - 8, 1 # -8 = size of b instr plus size of automatically inserted nop
+foo:
+ add $0,$0,$0
+
More information about the llvm-commits
mailing list