MIPS16/GAS: Restore unsupported relocation diagnostics
authorMaciej W. Rozycki <macro@imgtec.com>
Fri, 24 Jun 2016 23:49:10 +0000 (00:49 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Fri, 24 Jun 2016 23:54:59 +0000 (00:54 +0100)
commit88a7ef1689279e498354094e123191926a801002
treeb0f603e9cac70bcaca933b4d1d1d3b4fe4413e5e
parent2907f41490b2b5602f47c5acdf9ad7ae94eaeff9
MIPS16/GAS: Restore unsupported relocation diagnostics

Correct a MIPS16 relocation handling regression in GAS introduced with:

commit 177b4a6ad0047c8995fbc55016bc4f4b68d53b4a
Author: Alexandre Oliva <aoliva@redhat.com>
Date:   Mon Mar 18 18:56:18 2002 +0000

discussed at <https://sourceware.org/ml/binutils/2002-03/msg00345.html>,
which removed a preparatory call to `mips16_extended_frag' previously
made from `md_estimate_size_before_relax'.  As a result the function is
never called with its `sec' parameter non-NULL and consequently all the
unsupported relocation checks within are dead and never trigger, causing
any unhandled relocations to silently resolve to 0.  Unfortunately there
was no sufficient test suite coverage back then to catch this.

Remove all dead code then, and all the associated comments.  Update the
remaining call to `mips16_extended_frag' from `mips_relax_frag' to pass
the relocation section as the `sec' parameter and use it to mark frags
which require an external relocation, as extended.  Finally handle any
outstanding MIPS16 relocations in `md_convert_frag' and report an error
since we don't support any except with percent operators.

gas/
* config/tc-mips.c (append_insn): Use any `O_symbol' expression
unchanged with relaxed MIPS16 instructions.
(mips16_extended_frag): Adjust accordingly.  Return 1 right
away if a relocation will be required for the symbol requested.
Remove dead first relaxation pass code.
(mips_relax_frag): Pass `sec' down to `mips16_extended_frag'.
(md_convert_frag): Adjust symbol value calculation.  Raise an
error if a relocation is required for the symbol requested.
* testsuite/gas/mips/mips16@relax-swap3.d: Remove dump patterns,
add error output.
* testsuite/gas/mips/mips16@relax-swap3.l: New error output.
* testsuite/gas/mips/mips16-pcrel-relax-0.d: New test.
* testsuite/gas/mips/mips16-pcrel-relax-1.d: New test.
* testsuite/gas/mips/mips16-pcrel-relax-2.d: New test.
* testsuite/gas/mips/mips16-pcrel-relax-3.d: New test.
* testsuite/gas/mips/mips16-pcrel-reloc-0.d: New test.
* testsuite/gas/mips/mips16-pcrel-reloc-1.d: New test.
* testsuite/gas/mips/mips16-pcrel-reloc-2.d: New test.
* testsuite/gas/mips/mips16-pcrel-reloc-3.d: New test.
* testsuite/gas/mips/mips16-pcrel-reloc-4.d: New test.
* testsuite/gas/mips/mips16-pcrel-reloc-5.d: New test.
* testsuite/gas/mips/mips16-pcrel-reloc-6.d: New test.
* testsuite/gas/mips/mips16-pcrel-reloc-7.d: New test.
* testsuite/gas/mips/mips16-pcrel-addend-0.d: New test.
* testsuite/gas/mips/mips16-pcrel-addend-1.d: New test.
* testsuite/gas/mips/mips16-pcrel-addend-2.d: New test.
* testsuite/gas/mips/mips16-pcrel-addend-3.d: New test.
* testsuite/gas/mips/mips16-pcrel-absolute.d: New test.
* testsuite/gas/mips/mips16-branch-reloc-0.d: New test.
* testsuite/gas/mips/mips16-branch-reloc-1.d: New test.
* testsuite/gas/mips/mips16-branch-reloc-2.d: New test.
* testsuite/gas/mips/mips16-branch-reloc-3.d: New test.
* testsuite/gas/mips/mips16-branch-addend-0.d: New test.
* testsuite/gas/mips/mips16-branch-addend-1.d: New test.
* testsuite/gas/mips/mips16-branch-addend-2.d: New test.
* testsuite/gas/mips/mips16-branch-addend-3.d: New test.
* testsuite/gas/mips/mips16-branch-absolute.d: New test.
* testsuite/gas/mips/mips16-absolute-reloc-0.d: New test.
* testsuite/gas/mips/mips16-absolute-reloc-1.d: New test.
* testsuite/gas/mips/mips16-absolute-reloc-2.d: New test.
* testsuite/gas/mips/mips16-absolute-reloc-3.d: New test.
* testsuite/gas/mips/mips16-pcrel-reloc-2.l: New error output.
* testsuite/gas/mips/mips16-pcrel-reloc-3.l: New error output.
* testsuite/gas/mips/mips16-pcrel-reloc-6.l: New error output.
* testsuite/gas/mips/mips16-pcrel-reloc-7.l: New error output.
* testsuite/gas/mips/mips16-pcrel-addend-2.l: New error output.
* testsuite/gas/mips/mips16-pcrel-addend-3.l: New error output.
* testsuite/gas/mips/mips16-pcrel-absolute.l: New error output.
* testsuite/gas/mips/mips16-branch-reloc-2.l: New error output.
* testsuite/gas/mips/mips16-branch-reloc-3.l: New error output.
* testsuite/gas/mips/mips16-branch-addend-2.l: New error output.
* testsuite/gas/mips/mips16-branch-addend-3.l: New error output.
* testsuite/gas/mips/mips16-branch-absolute.l: New error output.
* testsuite/gas/mips/mips16-absolute-reloc-2.l: New error output.
* testsuite/gas/mips/mips16-absolute-reloc-3.l: New error output.
* testsuite/gas/mips/mips16-pcrel-relax-0.s: New test source.
* testsuite/gas/mips/mips16-pcrel-relax-2.s: New test source.
* testsuite/gas/mips/mips16-pcrel-reloc-0.s: New test source.
* testsuite/gas/mips/mips16-pcrel-reloc-1.s: New test source.
* testsuite/gas/mips/mips16-pcrel-reloc-2.s: New test source.
* testsuite/gas/mips/mips16-pcrel-reloc-3.s: New test source.
* testsuite/gas/mips/mips16-pcrel-reloc-4.s: New test source.
* testsuite/gas/mips/mips16-pcrel-reloc-5.s: New test source.
* testsuite/gas/mips/mips16-pcrel-reloc-6.s: New test source.
* testsuite/gas/mips/mips16-pcrel-reloc-7.s: New test source.
* testsuite/gas/mips/mips16-pcrel-addend-0.s: New test source.
* testsuite/gas/mips/mips16-pcrel-addend-1.s: New test source.
* testsuite/gas/mips/mips16-pcrel-addend-2.s: New test source.
* testsuite/gas/mips/mips16-pcrel-addend-3.s: New test source.
* testsuite/gas/mips/mips16-pcrel-absolute.s: New test source.
* testsuite/gas/mips/mips16-branch-reloc-0.s: New test source.
* testsuite/gas/mips/mips16-branch-reloc-1.s: New test source.
* testsuite/gas/mips/mips16-branch-reloc-2.s: New test source.
* testsuite/gas/mips/mips16-branch-reloc-3.s: New test source.
* testsuite/gas/mips/mips16-branch-addend-0.s: New test source.
* testsuite/gas/mips/mips16-branch-addend-1.s: New test source.
* testsuite/gas/mips/mips16-branch-addend-2.s: New test source.
* testsuite/gas/mips/mips16-branch-addend-3.s: New test source.
* testsuite/gas/mips/mips16-branch-absolute.s: New test source.
* testsuite/gas/mips/mips16-absolute-reloc-0.s: New test source.
* testsuite/gas/mips/mips16-absolute-reloc-1.s: New test source.
* testsuite/gas/mips/mips16-absolute-reloc-2.s: New test source.
* testsuite/gas/mips/mips16-absolute-reloc-3.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.
77 files changed:
gas/ChangeLog
gas/config/tc-mips.c
gas/testsuite/gas/mips/mips.exp
gas/testsuite/gas/mips/mips16-absolute-reloc-0.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-absolute-reloc-0.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-absolute-reloc-1.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-absolute-reloc-1.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-absolute-reloc-2.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-absolute-reloc-2.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-absolute-reloc-2.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-absolute-reloc-3.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-absolute-reloc-3.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-absolute-reloc-3.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-absolute.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-absolute.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-absolute.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-addend-0.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-addend-0.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-addend-1.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-addend-1.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-addend-2.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-addend-2.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-addend-2.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-addend-3.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-addend-3.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-addend-3.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-reloc-0.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-reloc-0.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-reloc-1.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-reloc-1.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-reloc-2.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-reloc-2.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-reloc-2.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-reloc-3.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-reloc-3.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-branch-reloc-3.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-absolute.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-absolute.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-absolute.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-addend-0.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-addend-0.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-addend-1.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-addend-1.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-addend-2.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-addend-2.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-addend-2.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-addend-3.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-addend-3.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-addend-3.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-relax-0.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-relax-0.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-relax-1.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-relax-2.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-relax-2.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-relax-3.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-0.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-0.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-1.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-1.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-2.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-2.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-2.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-3.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-3.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-3.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-4.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-4.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-5.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-5.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-6.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-6.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-6.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-7.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-7.l [new file with mode: 0644]
gas/testsuite/gas/mips/mips16-pcrel-reloc-7.s [new file with mode: 0644]
gas/testsuite/gas/mips/mips16@relax-swap3.d
gas/testsuite/gas/mips/mips16@relax-swap3.l [new file with mode: 0644]