This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] 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.
---
binutils-mips16-gas-reloc-unextended.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c	2016-12-13 21:21:28.785849404 +0000
+++ binutils/gas/config/tc-mips.c	2016-12-13 21:43:24.494110085 +0000
@@ -18370,10 +18370,10 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 			    _("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;
@@ -18388,6 +18388,9 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNU
 		 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,
Index: binutils/gas/testsuite/gas/mips/mips.exp
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips.exp	2016-12-13 21:23:16.625125794 +0000
+++ binutils/gas/testsuite/gas/mips/mips.exp	2016-12-13 21:43:24.792652117 +0000
@@ -1298,6 +1298,9 @@ if { [istarget mips*-*-vxworks*] } {
     run_dump_test "mips16-extend"
     run_dump_test "mips16-sprel-swap"
 
+    run_dump_test "mips16-branch-unextended-1"
+    run_dump_test "mips16-branch-unextended-2"
+
     run_dump_test "vxworks1"
     run_dump_test "vxworks1-xgot"
     run_dump_test "vxworks1-el"
Index: binutils/gas/testsuite/gas/mips/mips16-branch-unextended-1.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-branch-unextended-1.d	2016-12-13 21:23:30.189731897 +0000
@@ -0,0 +1,3 @@
+#name: MIPS16 unextended branch instructions with relocation 1
+#as: -32
+#error-output: mips16-branch-unextended.l
Index: binutils/gas/testsuite/gas/mips/mips16-branch-unextended-1.s
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-branch-unextended-1.s	2016-12-13 21:23:30.204943400 +0000
@@ -0,0 +1,8 @@
+	.set	mips16
+	.set	noautoextend
+foo:
+	beqz	$2, baz
+	bnez	$3, baz
+	bteqz	baz
+	btnez	baz
+	b	baz
Index: binutils/gas/testsuite/gas/mips/mips16-branch-unextended-2.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-branch-unextended-2.d	2016-12-13 21:23:30.220028341 +0000
@@ -0,0 +1,3 @@
+#name: MIPS16 unextended branch instructions with relocation 2
+#as: -32
+#error-output: mips16-branch-unextended.l
Index: binutils/gas/testsuite/gas/mips/mips16-branch-unextended-2.s
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-branch-unextended-2.s	2016-12-13 21:23:30.229084575 +0000
@@ -0,0 +1,8 @@
+	.set	mips16
+	.set	autoextend
+foo:
+	beqz.t	$2, baz
+	bnez.t	$3, baz
+	bteqz.t	baz
+	btnez.t	baz
+	b.t	baz
Index: binutils/gas/testsuite/gas/mips/mips16-branch-unextended.l
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/mips16-branch-unextended.l	2016-12-13 21:23:30.246296004 +0000
@@ -0,0 +1,6 @@
+.*: Assembler messages:
+.*:4: Error: invalid unextended operand value
+.*:5: Error: invalid unextended operand value
+.*:6: Error: invalid unextended operand value
+.*:7: Error: invalid unextended operand value
+.*:8: Error: invalid unextended operand value


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]