This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] MIPS/GAS: Avoid an internal error in constant relocations
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: <binutils at sourceware dot org>
- Cc: Richard Sandiford <rdsandiford at googlemail dot com>
- Date: Fri, 21 Sep 2012 18:47:54 +0100
- Subject: [PATCH] MIPS/GAS: Avoid an internal error in constant relocations
Hi,
As noted previously assembling an instruction like this:
li $2, %got(0)
causes an internal error, one of:
got.s: Assembler messages:
got.s:1: Fatal error: internal Error, line 4100, [...]
or
got.s: Assembler messages:
got.s:1: Fatal error: internal Error, line 13372, [...]
in the standard MIPS and the MIPS16 mode respectively. User errors must
not trigger internal errors, so here's a change to covert code to produce
an ordinary error with an explanatory message. That is intentionally the
same as one I chose for the fixup fix.
To avoid a "may be used uninitialized" message in the MIPS16 case I had
to add an assignment to tmp so that it has a value for the call to
mips16_immed that follows. I chose not to preinitialise it so as to avoid
a situation where another switch case added in the future may accidentally
fail to initialise the variable.
No regressions in MIPS testing, OK to apply?
2012-09-21 Maciej W. Rozycki <macro@codesourcery.com>
gas/
* config/tc-mips.c (append_insn): Report constants in unhandled
relocations as a user rather than internal error.
(mips16_ip): Likewise.
Maciej
binutils-gas-mips-const-error.diff
Index: binutils-fsf-trunk-quilt/gas/config/tc-mips.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/gas/config/tc-mips.c 2012-09-20 21:20:07.000000000 +0100
+++ binutils-fsf-trunk-quilt/gas/config/tc-mips.c 2012-09-20 22:23:24.791781604 +0100
@@ -4097,7 +4097,7 @@ append_insn (struct mips_cl_insn *ip, ex
break;
default:
- internalError ();
+ as_bad (_("Unsupported constant in relocation"));
}
}
@@ -13365,7 +13365,8 @@ mips16_ip (char *str, struct mips_cl_ins
break;
default:
- internalError ();
+ tmp = 0;
+ as_bad (_("Unsupported constant in relocation"));
}
*offset_reloc = BFD_RELOC_UNUSED;