This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: mipsisa32-unknown-elf-as: Error: too large constant specified
Thiemo Seufer wrote:
[snip]
> 2003-10-15 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
>
> /gas/ChangeLog
> * config/tc-mips.c (check_absolute_expr): Unset high bits set by
> 32/64 bit unaware gas expression evaluation.
> (mips_ip): Likewise.
I applied the improved version appended below.
Thiemo
2003-10-19 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
/gas/ChangeLog
* config/tc-mips.c (normalize_constant_expr): New function to fix sign
extensions broken by gas' expression evaluation of constants.
(check_absolute_expr): Use it.
(mips_ip): Likewise.
--- source-orig/gas/config/tc-mips.c Wed Oct 8 20:54:10 2003
+++ source/gas/config/tc-mips.c Sun Oct 19 13:03:07 2003
@@ -3329,6 +3339,14 @@ set_at (int *counter, int reg, int unsig
}
}
+static void
+normalize_constant_expr (expressionS *ex)
+{
+ if (ex->X_op == O_constant && HAVE_32BIT_GPRS)
+ ex->X_add_number = (((ex->X_add_number & 0xffffffff) ^ 0x80000000)
+ - 0x80000000);
+}
+
/* Warn if an expression is not a constant. */
static void
@@ -3338,6 +3356,8 @@ check_absolute_expr (struct mips_cl_insn
as_bad (_("unsupported large constant"));
else if (ex->X_op != O_constant)
as_bad (_("Instruction %s requires absolute expression"), ip->insn_mo->name);
+
+ normalize_constant_expr (ex);
}
/* Count the leading zeroes by performing a binary chop. This is a
@@ -8562,6 +8582,7 @@ do_msbd:
if (imm2_expr.X_op != O_big
&& imm2_expr.X_op != O_constant)
insn_error = _("absolute expression required");
+ normalize_constant_expr (&imm2_expr);
s = expr_end;
continue;
@@ -9050,6 +9071,7 @@ do_msbd:
if (imm_expr.X_op != O_big
&& imm_expr.X_op != O_constant)
insn_error = _("absolute expression required");
+ normalize_constant_expr (&imm_expr);
s = expr_end;
continue;