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)
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]

index 221f925130d6029fce2027d28ef62c81b2f90bab..1c3e80a5780247e81d3945f70bb55e70d3b158ba 100644 (file)
@@ -1,3 +1,90 @@
+2016-06-24  Maciej W. Rozycki  <macro@imgtec.com>
+
+       * 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.
+
 2016-06-24  Alan Modra  <amodra@gmail.com>
 
        * configure.tgt (alpha-*-openbsd*): Use em=nbsd.
index bbb604ae179d1a325b9779261f2f16089bbaf475..ab2ea0c8c7cdf3268e5d6634607ee98921755cd3 100644 (file)
@@ -7307,15 +7307,31 @@ append_insn (struct mips_cl_insn *ip, expressionS *address_expr,
     }
   else if (mips_opts.mips16 && *reloc_type > BFD_RELOC_UNUSED)
     {
+      symbolS *symbol;
+      offsetT offset;
+
       /* We need to set up a variant frag.  */
       gas_assert (address_expr != NULL);
+      /* Pass any `O_symbol' expression unchanged as an `expr_section'
+         symbol created by `make_expr_symbol' may not get a necessary
+         external relocation produced.  */
+      if (address_expr->X_op == O_symbol)
+       {
+         symbol = address_expr->X_add_symbol;
+         offset = address_expr->X_add_number;
+       }
+      else
+       {
+         symbol = make_expr_symbol (address_expr);
+         offset = 0;
+       }
       add_relaxed_insn (ip, 4, 0,
                        RELAX_MIPS16_ENCODE
                        (*reloc_type - BFD_RELOC_UNUSED,
                         forced_insn_length == 2, forced_insn_length == 4,
                         delayed_branch_p (&history[0]),
                         history[0].mips16_absolute_jump_p),
-                       make_expr_symbol (address_expr), 0);
+                       symbol, offset);
     }
   else if (mips_opts.mips16 && insn_length (ip) == 2)
     {
@@ -16731,12 +16747,17 @@ mips16_extended_frag (fragS *fragp, asection *sec, long stretch)
   if (RELAX_MIPS16_USER_EXT (fragp->fr_subtype))
     return 1;
 
+  symsec = S_GET_SEGMENT (fragp->fr_symbol);
   type = RELAX_MIPS16_TYPE (fragp->fr_subtype);
   operand = mips16_immed_operand (type, FALSE);
+  if (S_FORCE_RELOC (fragp->fr_symbol, TRUE)
+      || (operand->root.type == OP_PCREL
+         ? sec != symsec
+         : !bfd_is_abs_section (symsec)))
+    return 1;
 
   sym_frag = symbol_get_frag (fragp->fr_symbol);
-  val = S_GET_VALUE (fragp->fr_symbol);
-  symsec = S_GET_SEGMENT (fragp->fr_symbol);
+  val = S_GET_VALUE (fragp->fr_symbol) + fragp->fr_offset;
 
   if (operand->root.type == OP_PCREL)
     {
@@ -16744,47 +16765,16 @@ mips16_extended_frag (fragS *fragp, asection *sec, long stretch)
       addressT addr;
       offsetT maxtiny;
 
-      /* We won't have the section when we are called from
-         mips_relax_frag.  However, we will always have been called
-         from md_estimate_size_before_relax first.  If this is a
-         branch to a different section, we mark it as such.  If SEC is
-         NULL, and the frag is not marked, then it must be a branch to
-         the same section.  */
-      pcrel_op = (const struct mips_pcrel_operand *) operand;
-      if (sec == NULL)
-       {
-         if (RELAX_MIPS16_LONG_BRANCH (fragp->fr_subtype))
-           return 1;
-       }
-      else
-       {
-         /* Must have been called from md_estimate_size_before_relax.  */
-         if (symsec != sec)
-           {
-             fragp->fr_subtype =
-               RELAX_MIPS16_MARK_LONG_BRANCH (fragp->fr_subtype);
-
-             /* FIXME: We should support this, and let the linker
-                 catch branches and loads that are out of range.  */
-             as_bad_where (fragp->fr_file, fragp->fr_line,
-                           _("unsupported PC relative reference to different section"));
+      if (RELAX_MIPS16_LONG_BRANCH (fragp->fr_subtype))
+       return 1;
 
-             return 1;
-           }
-         if (fragp != sym_frag && sym_frag->fr_address == 0)
-           /* Assume non-extended on the first relaxation pass.
-              The address we have calculated will be bogus if this is
-              a forward branch to another frag, as the forward frag
-              will have fr_address == 0.  */
-           return 0;
-       }
+      pcrel_op = (const struct mips_pcrel_operand *) operand;
 
-      /* In this case, we know for sure that the symbol fragment is in
-        the same section.  If the relax_marker of the symbol fragment
-        differs from the relax_marker of this fragment, we have not
-        yet adjusted the symbol fragment fr_address.  We want to add
-        in STRETCH in order to get a better estimate of the address.
-        This particularly matters because of the shift bits.  */
+      /* If the relax_marker of the symbol fragment differs from the
+        relax_marker of this fragment, we have not yet adjusted the
+        symbol fragment fr_address.  We want to add in STRETCH in
+        order to get a better estimate of the address.  This
+        particularly matters because of the shift bits.  */
       if (stretch != 0
          && sym_frag->relax_marker != fragp->relax_marker)
        {
@@ -16844,9 +16834,8 @@ mips16_extended_frag (fragS *fragp, asection *sec, long stretch)
       /* If any of the shifted bits are set, we must use an extended
          opcode.  If the address depends on the size of this
          instruction, this can lead to a loop, so we arrange to always
-         use an extended opcode.  We only check this when we are in
-         the main relaxation loop, when SEC is NULL.  */
-      if ((val & ((1 << operand->shift) - 1)) != 0 && sec == NULL)
+         use an extended opcode.  */
+      if ((val & ((1 << operand->shift) - 1)) != 0)
        {
          fragp->fr_subtype =
            RELAX_MIPS16_MARK_LONG_BRANCH (fragp->fr_subtype);
@@ -16867,16 +16856,13 @@ mips16_extended_frag (fragS *fragp, asection *sec, long stretch)
         extended with the next value above maxtiny.  */
       maxtiny = mips_int_operand_max (operand);
       if (val == maxtiny + (1 << operand->shift)
-         && ! RELAX_MIPS16_EXTENDED (fragp->fr_subtype)
-         && sec == NULL)
+         && ! RELAX_MIPS16_EXTENDED (fragp->fr_subtype))
        {
          fragp->fr_subtype =
            RELAX_MIPS16_MARK_LONG_BRANCH (fragp->fr_subtype);
          return 1;
        }
     }
-  else if (symsec != absolute_section && sec != NULL)
-    as_bad_where (fragp->fr_file, fragp->fr_line, _("unsupported relocation"));
 
   return !mips16_immed_in_range_p (operand, BFD_RELOC_UNUSED, val);
 }
@@ -17367,7 +17353,7 @@ mips_relax_frag (asection *sec, fragS *fragp, long stretch)
   if (! RELAX_MIPS16_P (fragp->fr_subtype))
     return 0;
 
-  if (mips16_extended_frag (fragp, NULL, stretch))
+  if (mips16_extended_frag (fragp, sec, stretch))
     {
       if (RELAX_MIPS16_EXTENDED (fragp->fr_subtype))
        return 0;
@@ -17820,12 +17806,13 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
       unsigned int user_length, length;
       unsigned long insn;
       bfd_boolean ext;
+      segT symsec;
 
       type = RELAX_MIPS16_TYPE (fragp->fr_subtype);
       operand = mips16_immed_operand (type, FALSE);
 
       ext = RELAX_MIPS16_EXTENDED (fragp->fr_subtype);
-      val = resolve_symbol_value (fragp->fr_symbol);
+      val = resolve_symbol_value (fragp->fr_symbol) + fragp->fr_offset;
       if (operand->root.type == OP_PCREL)
        {
          const struct mips_pcrel_operand *pcrel_op;
@@ -17878,8 +17865,16 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec, fragS *fragp)
       else
        user_length = 0;
 
-      mips16_immed (fragp->fr_file, fragp->fr_line, type,
-                   BFD_RELOC_UNUSED, val, user_length, &insn);
+      symsec = S_GET_SEGMENT (fragp->fr_symbol);
+      if (S_FORCE_RELOC (fragp->fr_symbol, TRUE)
+         || (operand->root.type == OP_PCREL
+             ? asec != symsec
+             : !bfd_is_abs_section (symsec)))
+       as_bad_where (fragp->fr_file, fragp->fr_line,
+                     _("unsupported relocation"));
+      else
+       mips16_immed (fragp->fr_file, fragp->fr_line, type,
+                     BFD_RELOC_UNUSED, val, user_length, &insn);
 
       length = (ext ? 4 : 2);
       gas_assert (mips16_opcode_length (insn) == length);
index 30143b86746ed8b86248590f2b87e517d67a0659..d268dc00ce5be3294e79722856082630b414d915 100644 (file)
@@ -1335,6 +1335,37 @@ if { [istarget mips*-*-vxworks*] } {
     run_list_test "pcrel-reloc-6" "-32 --defsym offset=4" \
        "MIPS local PC-relative relocations 6b"
 
+    run_dump_test "mips16-pcrel-relax-0"
+    run_dump_test "mips16-pcrel-relax-1"
+    run_dump_test "mips16-pcrel-relax-2"
+    run_dump_test "mips16-pcrel-relax-3"
+    run_dump_test "mips16-pcrel-reloc-0"
+    run_dump_test "mips16-pcrel-reloc-1"
+    run_dump_test "mips16-pcrel-reloc-2"
+    run_dump_test "mips16-pcrel-reloc-3"
+    run_dump_test "mips16-pcrel-reloc-4"
+    run_dump_test "mips16-pcrel-reloc-5"
+    run_dump_test "mips16-pcrel-reloc-6"
+    run_dump_test "mips16-pcrel-reloc-7"
+    run_dump_test "mips16-pcrel-addend-0"
+    run_dump_test "mips16-pcrel-addend-1"
+    run_dump_test "mips16-pcrel-addend-2"
+    run_dump_test "mips16-pcrel-addend-3"
+    run_dump_test "mips16-pcrel-absolute"
+    run_dump_test "mips16-branch-reloc-0"
+    run_dump_test "mips16-branch-reloc-1"
+    run_dump_test "mips16-branch-reloc-2"
+    run_dump_test "mips16-branch-reloc-3"
+    run_dump_test "mips16-branch-addend-0"
+    run_dump_test "mips16-branch-addend-1"
+    run_dump_test "mips16-branch-addend-2"
+    run_dump_test "mips16-branch-addend-3"
+    run_dump_test "mips16-branch-absolute"
+    run_dump_test "mips16-absolute-reloc-0"
+    run_dump_test "mips16-absolute-reloc-1"
+    run_dump_test "mips16-absolute-reloc-2"
+    run_dump_test "mips16-absolute-reloc-3"
+
     run_dump_test_arches "attr-gnu-4-0" "-32" \
                                    [mips_arch_list_matching mips1]
     run_dump_test_arches "attr-gnu-4-0" "-64" \
diff --git a/gas/testsuite/gas/mips/mips16-absolute-reloc-0.d b/gas/testsuite/gas/mips/mips16-absolute-reloc-0.d
new file mode 100644 (file)
index 0000000..d352a79
--- /dev/null
@@ -0,0 +1,12 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 absolute relocation 0
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> 6806         li      s0,6
+[0-9a-f]+ <[^>]*> f222 0414    addiu   a0,sp,4660
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-absolute-reloc-0.s b/gas/testsuite/gas/mips/mips16-absolute-reloc-0.s
new file mode 100644 (file)
index 0000000..f5b4ab8
--- /dev/null
@@ -0,0 +1,17 @@
+       .text
+
+       .space  0x1000
+
+       .globl  foo
+       .ent    foo
+       .set    mips16
+foo:
+       li      $16, 1f - .
+       addiu   $4, $29, 0x1234
+1:
+       nop
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-absolute-reloc-1.d b/gas/testsuite/gas/mips/mips16-absolute-reloc-1.d
new file mode 100644 (file)
index 0000000..1ff8ffa
--- /dev/null
@@ -0,0 +1,12 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 absolute relocation 1
+#as: -32 -mips3
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> fd06         daddiu  s0,6
+[0-9a-f]+ <[^>]*> f222 ff94    daddiu  a0,sp,4660
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-absolute-reloc-1.s b/gas/testsuite/gas/mips/mips16-absolute-reloc-1.s
new file mode 100644 (file)
index 0000000..cd6f9a2
--- /dev/null
@@ -0,0 +1,17 @@
+       .text
+
+       .space  0x1000
+
+       .globl  foo
+       .ent    foo
+       .set    mips16
+foo:
+       daddiu  $16, 1f - .
+       daddiu  $4, $29, 0x1234
+1:
+       nop
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-absolute-reloc-2.d b/gas/testsuite/gas/mips/mips16-absolute-reloc-2.d
new file mode 100644 (file)
index 0000000..29b2cda
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 absolute relocation 2
+#as: -32
+#error-output: mips16-absolute-reloc-2.l
diff --git a/gas/testsuite/gas/mips/mips16-absolute-reloc-2.l b/gas/testsuite/gas/mips/mips16-absolute-reloc-2.l
new file mode 100644 (file)
index 0000000..1d76bfd
--- /dev/null
@@ -0,0 +1,25 @@
+.*: Assembler messages:
+.*:9: Error: unsupported relocation
+.*:10: Error: unsupported relocation
+.*:11: Error: unsupported relocation
+.*:12: Error: unsupported relocation
+.*:13: Error: unsupported relocation
+.*:14: Error: unsupported relocation
+.*:15: Error: unsupported relocation
+.*:16: Error: unsupported relocation
+.*:17: Error: unsupported relocation
+.*:18: Error: unsupported relocation
+.*:19: Error: unsupported relocation
+.*:20: Error: unsupported relocation
+.*:21: Error: unsupported relocation
+.*:22: Error: unsupported relocation
+.*:23: Error: unsupported relocation
+.*:24: Error: unsupported relocation
+.*:25: Error: unsupported relocation
+.*:26: Error: unsupported relocation
+.*:27: Error: unsupported relocation
+.*:28: Error: unsupported relocation
+.*:29: Error: unsupported relocation
+.*:30: Error: unsupported relocation
+.*:31: Error: unsupported relocation
+.*:32: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-absolute-reloc-2.s b/gas/testsuite/gas/mips/mips16-absolute-reloc-2.s
new file mode 100644 (file)
index 0000000..9026a8f
--- /dev/null
@@ -0,0 +1,37 @@
+       .text
+
+       .space  0x1000
+
+       .globl  foo
+       .ent    foo
+       .set    mips16
+foo:
+       addiu   $2, bar
+       addiu   $2, $3, bar
+       addiu   $2, $pc, bar
+       addiu   $sp, bar
+       addiu   $2, $sp, bar
+       cmpi    $2, bar
+       lb      $2, bar($3)
+       lbu     $2, bar($3)
+       lh      $2, bar($3)
+       lhu     $2, bar($3)
+       li      $2, bar
+       lw      $2, bar($3)
+       lw      $2, bar($pc)
+       lw      $2, bar($sp)
+       sb      $2, bar($3)
+       sh      $2, bar($3)
+       sll     $2, $3, bar
+       slti    $2, bar
+       sltiu   $2, bar
+       sra     $2, $3, bar
+       srl     $2, $3, bar
+       sw      $2, bar($3)
+       sw      $2, bar($sp)
+       sw      $ra, bar($sp)
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-absolute-reloc-3.d b/gas/testsuite/gas/mips/mips16-absolute-reloc-3.d
new file mode 100644 (file)
index 0000000..e099ed0
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 absolute relocation 3
+#as: -32 -mips3
+#error-output: mips16-absolute-reloc-3.l
diff --git a/gas/testsuite/gas/mips/mips16-absolute-reloc-3.l b/gas/testsuite/gas/mips/mips16-absolute-reloc-3.l
new file mode 100644 (file)
index 0000000..5e7d7f0
--- /dev/null
@@ -0,0 +1,16 @@
+.*: Assembler messages:
+.*:9: Error: unsupported relocation
+.*:10: Error: unsupported relocation
+.*:11: Error: unsupported relocation
+.*:12: Error: unsupported relocation
+.*:13: Error: unsupported relocation
+.*:14: Error: unsupported relocation
+.*:15: Error: unsupported relocation
+.*:16: Error: unsupported relocation
+.*:17: Error: unsupported relocation
+.*:18: Error: unsupported relocation
+.*:19: Error: unsupported relocation
+.*:20: Error: unsupported relocation
+.*:21: Error: unsupported relocation
+.*:22: Error: unsupported relocation
+.*:23: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-absolute-reloc-3.s b/gas/testsuite/gas/mips/mips16-absolute-reloc-3.s
new file mode 100644 (file)
index 0000000..4805b96
--- /dev/null
@@ -0,0 +1,28 @@
+       .text
+
+       .space  0x1000
+
+       .globl  foo
+       .ent    foo
+       .set    mips16
+foo:
+       daddiu  $2, bar
+       daddiu  $2, $3, bar
+       daddiu  $2, $pc, bar
+       daddiu  $sp, bar
+       daddiu  $2, $sp, bar
+       dsll    $2, $3, bar
+       dsra    $2, bar
+       dsrl    $2, bar
+       ld      $2, bar($3)
+       ld      $2, bar($pc)
+       ld      $2, bar($sp)
+       lwu     $2, bar($3)
+       sd      $2, bar($3)
+       sd      $2, bar($sp)
+       sd      $ra, bar($sp)
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute.d b/gas/testsuite/gas/mips/mips16-branch-absolute.d
new file mode 100644 (file)
index 0000000..90a9ea7
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 branch to absolute expression
+#as: -32
+#error-output: mips16-branch-absolute.l
diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute.l b/gas/testsuite/gas/mips/mips16-branch-absolute.l
new file mode 100644 (file)
index 0000000..c72b8d0
--- /dev/null
@@ -0,0 +1,6 @@
+.*: Assembler messages:
+.*:8: Error: unsupported relocation
+.*:9: Error: unsupported relocation
+.*:10: Error: unsupported relocation
+.*:11: Error: unsupported relocation
+.*:12: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-branch-absolute.s b/gas/testsuite/gas/mips/mips16-branch-absolute.s
new file mode 100644 (file)
index 0000000..948b0b6
--- /dev/null
@@ -0,0 +1,21 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       b       bar
+       bteqz   bar
+       btnez   bar
+       beqz    $2, bar
+       bnez    $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .set    bar, 0x1234
diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-0.d b/gas/testsuite/gas/mips/mips16-branch-addend-0.d
new file mode 100644 (file)
index 0000000..9fe83e4
--- /dev/null
@@ -0,0 +1,17 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 branch relocation with addend 0
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> f121 1010    b       00002264 <bar\+0x1234>
+[0-9a-f]+ <[^>]*> f121 600e    bteqz   00002264 <bar\+0x1234>
+[0-9a-f]+ <[^>]*> f121 610c    btnez   00002264 <bar\+0x1234>
+[0-9a-f]+ <[^>]*> f121 220a    beqz    v0,00002264 <bar\+0x1234>
+[0-9a-f]+ <[^>]*> f121 2a08    bnez    v0,00002264 <bar\+0x1234>
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-0.s b/gas/testsuite/gas/mips/mips16-branch-addend-0.s
new file mode 100644 (file)
index 0000000..b6f7d68
--- /dev/null
@@ -0,0 +1,30 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       b       bar + 0x1234
+       bteqz   bar + 0x1234
+       btnez   bar + 0x1234
+       beqz    $2, bar + 0x1234
+       bnez    $2, bar + 0x1234
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .ent    bar
+       .set    mips16
+bar:
+       nop
+       .set    nomips16
+       .end    bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-1.d b/gas/testsuite/gas/mips/mips16-branch-addend-1.d
new file mode 100644 (file)
index 0000000..b7b3054
--- /dev/null
@@ -0,0 +1,17 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 branch relocation with addend 1
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
+[0-9a-f]+ <[^>]*> f101 1008    b       00002234 <foo\+0x1214>
+[0-9a-f]+ <[^>]*> f101 6006    bteqz   00002234 <foo\+0x1214>
+[0-9a-f]+ <[^>]*> f101 6104    btnez   00002234 <foo\+0x1214>
+[0-9a-f]+ <[^>]*> f101 2202    beqz    v0,00002234 <foo\+0x1214>
+[0-9a-f]+ <[^>]*> f101 2a00    bnez    v0,00002234 <foo\+0x1214>
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-1.s b/gas/testsuite/gas/mips/mips16-branch-addend-1.s
new file mode 100644 (file)
index 0000000..e33f196
--- /dev/null
@@ -0,0 +1,30 @@
+       .text
+
+       .space  0x1000
+
+       .ent    bar
+       .set    mips16
+bar:
+       nop
+       .set    nomips16
+       .end    bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .ent    foo
+       .set    mips16
+foo:
+       b       bar + 0x1234
+       bteqz   bar + 0x1234
+       btnez   bar + 0x1234
+       beqz    $2, bar + 0x1234
+       bnez    $2, bar + 0x1234
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-2.d b/gas/testsuite/gas/mips/mips16-branch-addend-2.d
new file mode 100644 (file)
index 0000000..ae98546
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 branch relocation with addend 2
+#as: -32
+#error-output: mips16-branch-addend-2.l
diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-2.l b/gas/testsuite/gas/mips/mips16-branch-addend-2.l
new file mode 100644 (file)
index 0000000..d30fd62
--- /dev/null
@@ -0,0 +1,6 @@
+.*: Assembler messages:
+.*:9: Error: unsupported relocation
+.*:10: Error: unsupported relocation
+.*:11: Error: unsupported relocation
+.*:12: Error: unsupported relocation
+.*:13: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-2.s b/gas/testsuite/gas/mips/mips16-branch-addend-2.s
new file mode 100644 (file)
index 0000000..fe9e5b8
--- /dev/null
@@ -0,0 +1,31 @@
+       .text
+       .globl  bar
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       b       bar + 0x1234
+       bteqz   bar + 0x1234
+       btnez   bar + 0x1234
+       beqz    $2, bar + 0x1234
+       bnez    $2, bar + 0x1234
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .ent    bar
+       .set    mips16
+bar:
+       nop
+       .set    nomips16
+       .end    bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-3.d b/gas/testsuite/gas/mips/mips16-branch-addend-3.d
new file mode 100644 (file)
index 0000000..165e8f1
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 branch relocation with addend 3
+#as: -32
+#error-output: mips16-branch-reloc-3.l
diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-3.l b/gas/testsuite/gas/mips/mips16-branch-addend-3.l
new file mode 100644 (file)
index 0000000..c72b8d0
--- /dev/null
@@ -0,0 +1,6 @@
+.*: Assembler messages:
+.*:8: Error: unsupported relocation
+.*:9: Error: unsupported relocation
+.*:10: Error: unsupported relocation
+.*:11: Error: unsupported relocation
+.*:12: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-branch-addend-3.s b/gas/testsuite/gas/mips/mips16-branch-addend-3.s
new file mode 100644 (file)
index 0000000..cb5021a
--- /dev/null
@@ -0,0 +1,19 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       b       bar + 0x1234
+       bteqz   bar + 0x1234
+       btnez   bar + 0x1234
+       beqz    $2, bar + 0x1234
+       bnez    $2, bar + 0x1234
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-0.d b/gas/testsuite/gas/mips/mips16-branch-reloc-0.d
new file mode 100644 (file)
index 0000000..80ad83b
--- /dev/null
@@ -0,0 +1,17 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 branch relocation 0
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> 100f         b       00001020 <bar>
+[0-9a-f]+ <[^>]*> 600e         bteqz   00001020 <bar>
+[0-9a-f]+ <[^>]*> 610d         btnez   00001020 <bar>
+[0-9a-f]+ <[^>]*> 220c         beqz    v0,00001020 <bar>
+[0-9a-f]+ <[^>]*> 2a0b         bnez    v0,00001020 <bar>
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-0.s b/gas/testsuite/gas/mips/mips16-branch-reloc-0.s
new file mode 100644 (file)
index 0000000..3387e18
--- /dev/null
@@ -0,0 +1,30 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       b       bar
+       bteqz   bar
+       btnez   bar
+       beqz    $2, bar
+       bnez    $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .ent    bar
+       .set    mips16
+bar:
+       nop
+       .set    nomips16
+       .end    bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-1.d b/gas/testsuite/gas/mips/mips16-branch-reloc-1.d
new file mode 100644 (file)
index 0000000..d2ae8a7
--- /dev/null
@@ -0,0 +1,17 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 branch relocation 1
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
+[0-9a-f]+ <[^>]*> 17ef         b       00001000 <bar>
+[0-9a-f]+ <[^>]*> 60ee         bteqz   00001000 <bar>
+[0-9a-f]+ <[^>]*> 61ed         btnez   00001000 <bar>
+[0-9a-f]+ <[^>]*> 22ec         beqz    v0,00001000 <bar>
+[0-9a-f]+ <[^>]*> 2aeb         bnez    v0,00001000 <bar>
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-1.s b/gas/testsuite/gas/mips/mips16-branch-reloc-1.s
new file mode 100644 (file)
index 0000000..3b6f4cb
--- /dev/null
@@ -0,0 +1,30 @@
+       .text
+
+       .space  0x1000
+
+       .ent    bar
+       .set    mips16
+bar:
+       nop
+       .set    nomips16
+       .end    bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .ent    foo
+       .set    mips16
+foo:
+       b       bar
+       bteqz   bar
+       btnez   bar
+       beqz    $2, bar
+       bnez    $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-2.d b/gas/testsuite/gas/mips/mips16-branch-reloc-2.d
new file mode 100644 (file)
index 0000000..1e6ecb4
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 branch relocation 2
+#as: -32
+#error-output: mips16-branch-reloc-2.l
diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-2.l b/gas/testsuite/gas/mips/mips16-branch-reloc-2.l
new file mode 100644 (file)
index 0000000..d30fd62
--- /dev/null
@@ -0,0 +1,6 @@
+.*: Assembler messages:
+.*:9: Error: unsupported relocation
+.*:10: Error: unsupported relocation
+.*:11: Error: unsupported relocation
+.*:12: Error: unsupported relocation
+.*:13: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-2.s b/gas/testsuite/gas/mips/mips16-branch-reloc-2.s
new file mode 100644 (file)
index 0000000..513c41b
--- /dev/null
@@ -0,0 +1,31 @@
+       .text
+       .globl  bar
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       b       bar
+       bteqz   bar
+       btnez   bar
+       beqz    $2, bar
+       bnez    $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .ent    bar
+       .set    mips16
+bar:
+       nop
+       .set    nomips16
+       .end    bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-3.d b/gas/testsuite/gas/mips/mips16-branch-reloc-3.d
new file mode 100644 (file)
index 0000000..d25d42e
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 branch relocation 3
+#as: -32
+#error-output: mips16-branch-reloc-3.l
diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-3.l b/gas/testsuite/gas/mips/mips16-branch-reloc-3.l
new file mode 100644 (file)
index 0000000..c72b8d0
--- /dev/null
@@ -0,0 +1,6 @@
+.*: Assembler messages:
+.*:8: Error: unsupported relocation
+.*:9: Error: unsupported relocation
+.*:10: Error: unsupported relocation
+.*:11: Error: unsupported relocation
+.*:12: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-branch-reloc-3.s b/gas/testsuite/gas/mips/mips16-branch-reloc-3.s
new file mode 100644 (file)
index 0000000..8d34703
--- /dev/null
@@ -0,0 +1,19 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       b       bar
+       bteqz   bar
+       btnez   bar
+       beqz    $2, bar
+       bnez    $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-absolute.d b/gas/testsuite/gas/mips/mips16-pcrel-absolute.d
new file mode 100644 (file)
index 0000000..557aa47
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 PC-relative reference to absolute expression
+#as: -32
+#error-output: mips16-pcrel-absolute.l
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-absolute.l b/gas/testsuite/gas/mips/mips16-pcrel-absolute.l
new file mode 100644 (file)
index 0000000..2e42978
--- /dev/null
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*:8: Error: unsupported relocation
+.*:9: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-absolute.s b/gas/testsuite/gas/mips/mips16-pcrel-absolute.s
new file mode 100644 (file)
index 0000000..3766568
--- /dev/null
@@ -0,0 +1,18 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       la      $2, bar
+       lw      $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .set    bar, 0x1234
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-addend-0.d b/gas/testsuite/gas/mips/mips16-pcrel-addend-0.d
new file mode 100644 (file)
index 0000000..09a058b
--- /dev/null
@@ -0,0 +1,13 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 PC-relative relocation with addend 0
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> f242 0a14    la      v0,00002254 <bar\+0x1234>
+[0-9a-f]+ <[^>]*> f242 b210    lw      v0,00002254 <bar\+0x1234>
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-addend-0.s b/gas/testsuite/gas/mips/mips16-pcrel-addend-0.s
new file mode 100644 (file)
index 0000000..be02196
--- /dev/null
@@ -0,0 +1,25 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       la      $2, bar + 0x1234
+       lw      $2, bar + 0x1234
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .type   bar, @object
+bar:
+       .long   0
+       .size   bar, . - bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-addend-1.d b/gas/testsuite/gas/mips/mips16-pcrel-addend-1.d
new file mode 100644 (file)
index 0000000..22e6482
--- /dev/null
@@ -0,0 +1,13 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 PC-relative relocation with addend 1
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+       \.\.\.
+[0-9a-f]+ <[^>]*> f202 0a14    la      v0,00002234 <foo\+0x1214>
+[0-9a-f]+ <[^>]*> f202 b210    lw      v0,00002234 <foo\+0x1214>
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-addend-1.s b/gas/testsuite/gas/mips/mips16-pcrel-addend-1.s
new file mode 100644 (file)
index 0000000..47fc28b
--- /dev/null
@@ -0,0 +1,25 @@
+       .text
+
+       .space  0x1000
+
+       .type   bar, @object
+bar:
+       .long   0
+       .size   bar, . - bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .ent    foo
+       .set    mips16
+foo:
+       la      $2, bar + 0x1234
+       lw      $2, bar + 0x1234
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-addend-2.d b/gas/testsuite/gas/mips/mips16-pcrel-addend-2.d
new file mode 100644 (file)
index 0000000..9a73e3f
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 PC-relative relocation with addend 2
+#as: -32
+#error-output: mips16-pcrel-addend-2.l
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-addend-2.l b/gas/testsuite/gas/mips/mips16-pcrel-addend-2.l
new file mode 100644 (file)
index 0000000..9bc4850
--- /dev/null
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*:9: Error: unsupported relocation
+.*:10: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-addend-2.s b/gas/testsuite/gas/mips/mips16-pcrel-addend-2.s
new file mode 100644 (file)
index 0000000..c5c63d3
--- /dev/null
@@ -0,0 +1,26 @@
+       .text
+       .globl  bar
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       la      $2, bar + 0x1234
+       lw      $2, bar + 0x1234
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .type   bar, @object
+bar:
+       .long   0
+       .size   bar, . - bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-addend-3.d b/gas/testsuite/gas/mips/mips16-pcrel-addend-3.d
new file mode 100644 (file)
index 0000000..5285b2f
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 PC-relative relocation with addend 3
+#as: -32
+#error-output: mips16-pcrel-addend-3.l
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-addend-3.l b/gas/testsuite/gas/mips/mips16-pcrel-addend-3.l
new file mode 100644 (file)
index 0000000..2e42978
--- /dev/null
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*:8: Error: unsupported relocation
+.*:9: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-addend-3.s b/gas/testsuite/gas/mips/mips16-pcrel-addend-3.s
new file mode 100644 (file)
index 0000000..a2a809e
--- /dev/null
@@ -0,0 +1,16 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       la      $2, bar + 0x1234
+       lw      $2, bar + 0x1234
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-relax-0.d b/gas/testsuite/gas/mips/mips16-pcrel-relax-0.d
new file mode 100644 (file)
index 0000000..55d15e1
--- /dev/null
@@ -0,0 +1,16 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 PC-relative relaxation 0
+#as: -32
+
+# Check that PC-relative relaxation does not go into oscillation
+# where the address referred depends on the size of the instruction;
+# cf. RELAX_MIPS16_MARK_LONG_BRANCH.
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> f000 0a08    la      v0,00001008 <foo\+0x8>
+[0-9a-f]+ <[^>]*> e820         jr      ra
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-relax-0.s b/gas/testsuite/gas/mips/mips16-pcrel-relax-0.s
new file mode 100644 (file)
index 0000000..e2bb53f
--- /dev/null
@@ -0,0 +1,23 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+       .set    noreorder
+foo:
+       la      $2, 0f
+       jr      $ra
+        nop
+       .ifdef  align
+       .align  2
+       .endif
+0:
+       .short  0
+       .set    reorder
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-relax-1.d b/gas/testsuite/gas/mips/mips16-pcrel-relax-1.d
new file mode 100644 (file)
index 0000000..1b19d45
--- /dev/null
@@ -0,0 +1,18 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 PC-relative relaxation 1
+#as: -32 --defsym align=1
+#source: mips16-pcrel-relax-0.s
+
+# Check that PC-relative relaxation chooses the short encoding
+# where the address referred is fixed by an alignment directive
+# cf. RELAX_MIPS16_MARK_LONG_BRANCH.
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> 0a02         la      v0,00001008 <foo\+0x8>
+[0-9a-f]+ <[^>]*> e820         jr      ra
+[0-9a-f]+ <[^>]*> 6500         nop
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-relax-2.d b/gas/testsuite/gas/mips/mips16-pcrel-relax-2.d
new file mode 100644 (file)
index 0000000..6c3b4fe
--- /dev/null
@@ -0,0 +1,16 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 PC-relative relaxation 2
+#as: -32
+
+# Check that PC-relative relaxation does not go into oscillation
+# where the address referred depends on the size of the instruction;
+# cf. RELAX_MIPS16_MARK_LONG_BRANCH.
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> f000 0a08    la      v0,00001008 <foo\+0x8>
+[0-9a-f]+ <[^>]*> e820         jr      ra
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-relax-2.s b/gas/testsuite/gas/mips/mips16-pcrel-relax-2.s
new file mode 100644 (file)
index 0000000..ed74cc7
--- /dev/null
@@ -0,0 +1,23 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+       .set    noreorder
+foo:
+       la      $2, .L0
+       jr      $ra
+        nop
+       .ifdef  align
+       .align  2
+       .endif
+.L0 = .
+       .short  0
+       .set    reorder
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-relax-3.d b/gas/testsuite/gas/mips/mips16-pcrel-relax-3.d
new file mode 100644 (file)
index 0000000..2d0c6ca
--- /dev/null
@@ -0,0 +1,18 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 PC-relative relaxation 3
+#as: -32 --defsym align=1
+#source: mips16-pcrel-relax-2.s
+
+# Check that PC-relative relaxation chooses the short encoding
+# where the address referred is fixed by an alignment directive
+# cf. RELAX_MIPS16_MARK_LONG_BRANCH.
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> 0a02         la      v0,00001008 <foo\+0x8>
+[0-9a-f]+ <[^>]*> e820         jr      ra
+[0-9a-f]+ <[^>]*> 6500         nop
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-0.d b/gas/testsuite/gas/mips/mips16-pcrel-reloc-0.d
new file mode 100644 (file)
index 0000000..beb69cf
--- /dev/null
@@ -0,0 +1,13 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 PC-relative relocation 0
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> 0a08         la      v0,00001020 <bar>
+[0-9a-f]+ <[^>]*> b208         lw      v0,00001020 <bar>
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-0.s b/gas/testsuite/gas/mips/mips16-pcrel-reloc-0.s
new file mode 100644 (file)
index 0000000..c07ccee
--- /dev/null
@@ -0,0 +1,25 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       la      $2, bar
+       lw      $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .type   bar, @object
+bar:
+       .long   0
+       .size   bar, . - bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-1.d b/gas/testsuite/gas/mips/mips16-pcrel-reloc-1.d
new file mode 100644 (file)
index 0000000..6ac3ce3
--- /dev/null
@@ -0,0 +1,13 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 PC-relative relocation 1
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+       \.\.\.
+[0-9a-f]+ <[^>]*> f7ff 0a00    la      v0,00001000 <bar>
+[0-9a-f]+ <[^>]*> f7df b21c    lw      v0,00001000 <bar>
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-1.s b/gas/testsuite/gas/mips/mips16-pcrel-reloc-1.s
new file mode 100644 (file)
index 0000000..07238e5
--- /dev/null
@@ -0,0 +1,25 @@
+       .text
+
+       .space  0x1000
+
+       .type   bar, @object
+bar:
+       .long   0
+       .size   bar, . - bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .ent    foo
+       .set    mips16
+foo:
+       la      $2, bar
+       lw      $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-2.d b/gas/testsuite/gas/mips/mips16-pcrel-reloc-2.d
new file mode 100644 (file)
index 0000000..73674ef
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 PC-relative relocation 2
+#as: -32
+#error-output: mips16-pcrel-reloc-2.l
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-2.l b/gas/testsuite/gas/mips/mips16-pcrel-reloc-2.l
new file mode 100644 (file)
index 0000000..9bc4850
--- /dev/null
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*:9: Error: unsupported relocation
+.*:10: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-2.s b/gas/testsuite/gas/mips/mips16-pcrel-reloc-2.s
new file mode 100644 (file)
index 0000000..ab012e2
--- /dev/null
@@ -0,0 +1,26 @@
+       .text
+       .globl  bar
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       la      $2, bar
+       lw      $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .type   bar, @object
+bar:
+       .long   0
+       .size   bar, . - bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-3.d b/gas/testsuite/gas/mips/mips16-pcrel-reloc-3.d
new file mode 100644 (file)
index 0000000..c5c92fa
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 PC-relative relocation 3
+#as: -32
+#error-output: mips16-pcrel-reloc-3.l
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-3.l b/gas/testsuite/gas/mips/mips16-pcrel-reloc-3.l
new file mode 100644 (file)
index 0000000..2e42978
--- /dev/null
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*:8: Error: unsupported relocation
+.*:9: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-3.s b/gas/testsuite/gas/mips/mips16-pcrel-reloc-3.s
new file mode 100644 (file)
index 0000000..85aaa43
--- /dev/null
@@ -0,0 +1,16 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       la      $2, bar
+       lw      $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-4.d b/gas/testsuite/gas/mips/mips16-pcrel-reloc-4.d
new file mode 100644 (file)
index 0000000..265b151
--- /dev/null
@@ -0,0 +1,13 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 PC-relative relocation 4
+#as: -32 -mips3
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+[0-9a-f]+ <[^>]*> fe48         dla     v0,00001020 <bar>
+[0-9a-f]+ <[^>]*> fc44         ld      v0,00001020 <bar>
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-4.s b/gas/testsuite/gas/mips/mips16-pcrel-reloc-4.s
new file mode 100644 (file)
index 0000000..33b2ee8
--- /dev/null
@@ -0,0 +1,25 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       dla     $2, bar
+       ld      $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .type   bar, @object
+bar:
+       .long   0
+       .size   bar, . - bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-5.d b/gas/testsuite/gas/mips/mips16-pcrel-reloc-5.d
new file mode 100644 (file)
index 0000000..9ca3302
--- /dev/null
@@ -0,0 +1,13 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS16 PC-relative relocation 5
+#as: -32 -mips3
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+       \.\.\.
+       \.\.\.
+[0-9a-f]+ <[^>]*> f7ff fe40    dla     v0,00001000 <bar>
+[0-9a-f]+ <[^>]*> f7ff fc40    ld      v0,00001000 <bar>
+[0-9a-f]+ <[^>]*> 6500         nop
+       \.\.\.
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-5.s b/gas/testsuite/gas/mips/mips16-pcrel-reloc-5.s
new file mode 100644 (file)
index 0000000..76c9cf4
--- /dev/null
@@ -0,0 +1,25 @@
+       .text
+
+       .space  0x1000
+
+       .type   bar, @object
+bar:
+       .long   0
+       .size   bar, . - bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .ent    foo
+       .set    mips16
+foo:
+       dla     $2, bar
+       ld      $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-6.d b/gas/testsuite/gas/mips/mips16-pcrel-reloc-6.d
new file mode 100644 (file)
index 0000000..a77cd9e
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 PC-relative relocation 6
+#as: -32 -mips3
+#error-output: mips16-pcrel-reloc-6.l
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-6.l b/gas/testsuite/gas/mips/mips16-pcrel-reloc-6.l
new file mode 100644 (file)
index 0000000..9bc4850
--- /dev/null
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*:9: Error: unsupported relocation
+.*:10: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-6.s b/gas/testsuite/gas/mips/mips16-pcrel-reloc-6.s
new file mode 100644 (file)
index 0000000..0bca180
--- /dev/null
@@ -0,0 +1,26 @@
+       .text
+       .globl  bar
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       dla     $2, bar
+       ld      $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
+
+       .type   bar, @object
+bar:
+       .long   0
+       .size   bar, . - bar
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-7.d b/gas/testsuite/gas/mips/mips16-pcrel-reloc-7.d
new file mode 100644 (file)
index 0000000..5f86e33
--- /dev/null
@@ -0,0 +1,3 @@
+#name: MIPS16 PC-relative relocation 7
+#as: -32 -mips3
+#error-output: mips16-pcrel-reloc-7.l
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-7.l b/gas/testsuite/gas/mips/mips16-pcrel-reloc-7.l
new file mode 100644 (file)
index 0000000..2e42978
--- /dev/null
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*:8: Error: unsupported relocation
+.*:9: Error: unsupported relocation
diff --git a/gas/testsuite/gas/mips/mips16-pcrel-reloc-7.s b/gas/testsuite/gas/mips/mips16-pcrel-reloc-7.s
new file mode 100644 (file)
index 0000000..a53d777
--- /dev/null
@@ -0,0 +1,16 @@
+       .text
+
+       .space  0x1000
+
+       .ent    foo
+       .set    mips16
+foo:
+       dla     $2, bar
+       ld      $2, bar
+       nop
+       .set    nomips16
+       .end    foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+       .align  4, 0
+       .space  16
index 49949b40a3a57a590bf44dfe10f9beb8e0dbf1d6..db28d8dc4614a6a05dfcd46a19977d9e5c5f97f7 100644 (file)
@@ -2,14 +2,10 @@
 #name: MIPS relaxed macro with branch swapping
 #as: -32
 #source: relax-swap3.s
+#error-output: mips16@relax-swap3.l
 
-.*: +file format .*mips.*
-
-Disassembly of section \.text:
-[0-9a-f]+ <[^>]*> 0a00         la      v0,[0-9a-f]+ <[^>]*>
-[0-9a-f]+ <[^>]*> eb00         jr      v1
-[0-9a-f]+ <[^>]*> 6500         nop
-[0-9a-f]+ <[^>]*> f7ff 0a1c    la      v0,[0-9a-f]+ <[^>]*>
-[0-9a-f]+ <[^>]*> 2300         beqz    v1,[0-9a-f]+ <[^>]*>
-       \.\.\.
-#pass
+# This test used to cover the MIPS16 LA macro, but ceased to work when a
+# regression in MIPS16 relocation processing has been corrected, because
+# we have no external relocation available to represent the expression.
+# It is left in place to trigger if we ever get R_MIPS16_PC16 relocation
+# support.
diff --git a/gas/testsuite/gas/mips/mips16@relax-swap3.l b/gas/testsuite/gas/mips/mips16@relax-swap3.l
new file mode 100644 (file)
index 0000000..ca06e99
--- /dev/null
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*:5: Error: unsupported relocation
+.*:8: Error: unsupported relocation