From 276b1dc2a2663680f734c8603a40e3cb8250f318 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 13 Aug 1999 08:38:20 +0000 Subject: [PATCH] Only pass positive values to validate_offset_imm() --- gas/ChangeLog | 6 ++++++ gas/config/tc-arm.c | 35 +++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 1be3cbfaafb..421d3c6dc47 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +1999-08-13 Nick Clifton + + * 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 * config/tc-arm.c (skip_whitespace): New macro. diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 999d607faa6..0f0cd706b60 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -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")); -- 2.30.2