This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch] Arm Thumb-2 offset checking off-by-one
- From: Paul Brook <paul at codesourcery dot com>
- To: binutils at sourceware dot org
- Date: Mon, 20 Feb 2006 23:22:46 +0000
- Subject: [patch] Arm Thumb-2 offset checking off-by-one
The patch below fixes a bunch of off-by-one errors in the checking of
immediate offsets in Thumb-2 address operands.
The offsets is stored in the instruction as an unbiased unsigned integer, and
the all ones value has no special meaning.
Tested with cross to arm-none-eabi.
Ok?
Paul
2006-02-20 Paul Brook <paul@codesourcery.com>
* config/tc-arm.c (md_apply_fix): Fix off-by-one errors.
Index: gas/config/tc-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/gas/config/tc-arm.c,v
retrieving revision 1.240
diff -u -p -r1.240 tc-arm.c
--- gas/config/tc-arm.c 2 Feb 2006 20:19:56 -0000 1.240
+++ gas/config/tc-arm.c 20 Feb 2006 22:54:54 -0000
@@ -11431,7 +11543,7 @@ md_apply_fix (fixS * fixP,
break;
}
value /= 4;
- if (value >= 0xff)
+ if (value > 0xff)
{
as_bad_where (fixP->fx_file, fixP->fx_line,
_("offset out of range"));
@@ -11446,7 +11558,7 @@ md_apply_fix (fixS * fixP,
newval |= (1 << 23);
else
value = -value;
- if (value >= 0xfff)
+ if (value > 0xfff)
{
as_bad_where (fixP->fx_file, fixP->fx_line,
_("offset out of range"));
@@ -11461,7 +11573,7 @@ md_apply_fix (fixS * fixP,
newval |= (1 << 9);
else
value = -value;
- if (value >= 0xff)
+ if (value > 0xff)
{
as_bad_where (fixP->fx_file, fixP->fx_line,
_("offset out of range"));
@@ -11472,7 +11584,7 @@ md_apply_fix (fixS * fixP,
else if ((newval & 0x00000f00) == 0x00000e00)
{
/* T-instruction: positive 8-bit offset. */
- if (value < 0 || value >= 0xff)
+ if (value < 0 || value > 0xff)
{
as_bad_where (fixP->fx_file, fixP->fx_line,
_("offset out of range"));