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] MIPS/GAS: Sanitize `.option picX' pseudo-op


	gas/
	* config/tc-mips.c (s_option): Sanitize `.option picX' 
	pseudo-op.
	* testsuite/gas/mips/option-pic-1.d: New test.
	* testsuite/gas/mips/option-pic-2.l: New list test.
	* testsuite/gas/mips/option-pic-1.s: New test source.
	* testsuite/gas/mips/option-pic-2.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new tests.
---

 I have committed this change.

  Maciej

binutils-mips-gas-option-pic-numeric.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c	2016-04-09 21:03:13.397351613 +0100
+++ binutils/gas/config/tc-mips.c	2016-04-09 21:03:55.308434773 +0100
@@ -15472,7 +15472,7 @@ s_option (int x ATTRIBUTE_UNUSED)
     {
       /* FIXME: What does this mean?  */
     }
-  else if (strncmp (opt, "pic", 3) == 0)
+  else if (strncmp (opt, "pic", 3) == 0 && ISDIGIT (opt[3]) && opt[4] == '\0')
     {
       int i;
 
Index: binutils/gas/testsuite/gas/mips/mips.exp
===================================================================
--- binutils.orig/gas/testsuite/gas/mips/mips.exp	2016-04-09 21:03:23.181398375 +0100
+++ binutils/gas/testsuite/gas/mips/mips.exp	2016-04-09 21:04:09.893219931 +0100
@@ -1488,6 +1488,9 @@ if { [istarget mips*-*-vxworks*] } {
 
     run_dump_test "li-d"
 
+    run_dump_test "option-pic-1"
+    run_list_test "option-pic-2" "" \
+	"MIPS invalid PIC option"
     run_list_test "option-pic-vxworks-1" "-mvxworks-pic" \
 	"MIPS invalid PIC option in VxWorks PIC"
     run_list_test "option-pic-vxworks-2" "-mvxworks-pic" \
Index: binutils/gas/testsuite/gas/mips/option-pic-1.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/option-pic-1.d	2016-04-09 21:04:09.920397790 +0100
@@ -0,0 +1,18 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#name: MIPS PIC option
+#as: -32
+
+.*: +file format .*mips.*
+
+Disassembly of section \.text:
+[0-9a-f]+ <[^>]*> 8f820000 	lw	v0,0\(gp\)
+[ 	]*[0-9a-f]+: R_MIPS_GOT16	bar
+[0-9a-f]+ <[^>]*> 3c020000 	lui	v0,0x0
+[ 	]*[0-9a-f]+: R_MIPS_HI16	bar
+[0-9a-f]+ <[^>]*> 24420000 	addiu	v0,v0,0
+[ 	]*[0-9a-f]+: R_MIPS_LO16	bar
+[0-9a-f]+ <[^>]*> 8f820000 	lw	v0,0\(gp\)
+[ 	]*[0-9a-f]+: R_MIPS_GOT16	bar
+[0-9a-f]+ <[^>]*> 03e00008 	jr	ra
+[0-9a-f]+ <[^>]*> 00000000 	nop
+	\.\.\.
Index: binutils/gas/testsuite/gas/mips/option-pic-1.s
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/option-pic-1.s	2016-04-09 21:04:09.930470780 +0100
@@ -0,0 +1,16 @@
+	.abicalls
+	.text
+	.globl	foo
+	.ent	foo
+foo:
+	la	$2, bar
+	.option	pic0		# Switch off!
+	la	$2, bar
+	.option	pic2		# Switch on!
+	la	$2, bar
+	jr	$ra
+	.end	foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+	.align	4, 0
+	.space	16
Index: binutils/gas/testsuite/gas/mips/option-pic-2.l
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/option-pic-2.l	2016-04-09 21:04:09.948715932 +0100
@@ -0,0 +1,4 @@
+.*: Assembler messages:
+.*:2: Warning: unrecognized option "picfoo"
+.*:3: Warning: unrecognized option "pic0foo"
+.*:4: Error: junk at end of line, first unrecognized character is `f'
Index: binutils/gas/testsuite/gas/mips/option-pic-2.s
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ binutils/gas/testsuite/gas/mips/option-pic-2.s	2016-04-09 21:04:10.002146152 +0100
@@ -0,0 +1,4 @@
+	.abicalls
+	.option	picfoo
+	.option	pic0foo
+	.option	pic0 foo


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