Only pass positive values to validate_offset_imm()

This commit is contained in:
Nick Clifton 1999-08-13 08:38:20 +00:00
parent ae5ad4adf9
commit 276b1dc2a2
2 changed files with 25 additions and 16 deletions

View File

@ -1,3 +1,9 @@
1999-08-13 Nick Clifton <nickc@cygnus.com>
* config/tc-arm.c (validate_offset_imm): Work on unsigned values.
(md_apply_fix3): Always pass positive values to
validate_offset_imm.
1999-08-12 Nick Clifton <nickc@cygnus.com>
* config/tc-arm.c (skip_whitespace): New macro.

View File

@ -460,7 +460,7 @@ static void symbol_locate PARAMS ((symbolS *, CONST char *, segT, valueT, fragS
static int add_to_lit_pool PARAMS ((void));
static unsigned validate_immediate PARAMS ((unsigned));
static unsigned validate_immediate_twopart PARAMS ((unsigned int, unsigned int *));
static int validate_offset_imm PARAMS ((int, int));
static int validate_offset_imm PARAMS ((unsigned int, int));
static void opcode_select PARAMS ((int));
static void end_of_line PARAMS ((char *));
static int reg_required_here PARAMS ((char **, int));
@ -1127,11 +1127,10 @@ validate_immediate_twopart (val, highpart)
static int
validate_offset_imm (val, hwse)
int val;
unsigned int val;
int hwse;
{
if ((hwse && (val < -255 || val > 255))
|| (val < -4095 || val > 4095))
if ((hwse && val > 255) || val > 4095)
return FAIL;
return val;
}
@ -2542,7 +2541,7 @@ fp_op2 (str)
int i;
inst.error = NULL;
skip_whitespace (* str);
/* First try and match exact strings, this is to guarantee that
@ -2848,7 +2847,7 @@ do_ldst (str, flags)
int reg;
str++;
skip_whitespace (str);
if ((reg = reg_required_here (&str, 16)) == FAIL)
@ -5396,13 +5395,15 @@ md_apply_fix3 (fixP, val, seg)
case BFD_RELOC_ARM_OFFSET_IMM:
sign = value >= 0;
if ((value = validate_offset_imm (value, 0)) == FAIL)
if (value < 0)
value = - value;
if (validate_offset_imm (value, 0) == FAIL)
{
as_bad (_("bad immediate value for offset (%ld)"), (long) value);
break;
}
if (value < 0)
value = -value;
newval = md_chars_to_number (buf, INSN_SIZE);
newval &= 0xff7ff000;
@ -5413,19 +5414,20 @@ md_apply_fix3 (fixP, val, seg)
case BFD_RELOC_ARM_OFFSET_IMM8:
case BFD_RELOC_ARM_HWLITERAL:
sign = value >= 0;
if ((value = validate_offset_imm (value, 1)) == FAIL)
if (value < 0)
value = - value;
if (validate_offset_imm (value, 1) == FAIL)
{
if (fixP->fx_r_type == BFD_RELOC_ARM_HWLITERAL)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("invalid literal constant: pool needs to be closer\n"));
else
as_bad (_("bad immediate value for offset (%ld)"), (long) value);
as_bad (_("bad immediate value for half-word offset (%ld)"), (long) value);
break;
}
if (value < 0)
value = -value;
newval = md_chars_to_number (buf, INSN_SIZE);
newval &= 0xff7ff0f0;
newval |= ((value >> 4) << 8) | (value & 0xf) | (sign ? INDEX_UP : 0);
@ -5434,10 +5436,11 @@ md_apply_fix3 (fixP, val, seg)
case BFD_RELOC_ARM_LITERAL:
sign = value >= 0;
if (value < 0)
value = -value;
value = - value;
if ((value = validate_offset_imm (value, 0)) == FAIL)
if (validate_offset_imm (value, 0) == FAIL)
{
as_bad_where (fixP->fx_file, fixP->fx_line,
_("invalid literal constant: pool needs to be closer\n"));