From eefc3365838ed15c02bd7da39fbc31c00d07b398 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Wed, 14 Dec 2016 21:20:01 +0000 Subject: MIPS16/GAS: Fix assertion failures with relocations on 16-bit instructions Complement commit c9775dde3277 ("MIPS16: Add R_MIPS16_PC16_S1 branch relocation support)" and report an assembly error when a relocation is required for an instruction, currently a branch only, that has been forced to use its unextended encoding, either with the use of an explicit `.t' mnemonic suffix, or by means of `.set noautoextend' being active, fixing an assertion failure currently caused instead. gas/ * config/tc-mips.c (md_convert_frag): Report an error instead of asserting on `ext'. * testsuite/gas/mips/mips16-branch-unextended-1.d: New test. * testsuite/gas/mips/mips16-branch-unextended-2.d: New test. * testsuite/gas/mips/mips16-branch-unextended-1.s: New test source. * testsuite/gas/mips/mips16-branch-unextended-2.s: New test. * testsuite/gas/mips/mips16-branch-unextended.l: New stderr output. * testsuite/gas/mips/mips.exp: Run the new tests. --- gas/config/tc-mips.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gas/config/tc-mips.c') diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 4288d96..1241b9c 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -18369,10 +18369,10 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp) _("unsupported relocation")); break; } - if (reloc != BFD_RELOC_NONE) + if (reloc == BFD_RELOC_NONE) + ; + else if (ext) { - gas_assert (ext); - exp.X_op = O_symbol; exp.X_add_symbol = fragp->fr_symbol; exp.X_add_number = fragp->fr_offset; @@ -18387,6 +18387,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp) in 2 octets. */ fixp->fx_no_overflow = 1; } + else + as_bad_where (fragp->fr_file, fragp->fr_line, + _("invalid unextended operand value")); } else mips16_immed (fragp->fr_file, fragp->fr_line, type, -- cgit v1.1