aboutsummaryrefslogtreecommitdiff
path: root/gas/testsuite
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2017-10-16 20:45:55 -0700
committerSandra Loosemore <sandra@codesourcery.com>2017-10-16 20:45:55 -0700
commit487958d1e995ab05420f9a8468535b4399602a3f (patch)
tree27fa5129ee50a721b15ab890efa28271ec00f262 /gas/testsuite
parentc191a6875b118fce30e7dc4d9e4bd20eff850270 (diff)
downloadgdb-487958d1e995ab05420f9a8468535b4399602a3f.zip
gdb-487958d1e995ab05420f9a8468535b4399602a3f.tar.gz
gdb-487958d1e995ab05420f9a8468535b4399602a3f.tar.bz2
Fix segfault processing nios2 pseudo-instructions with too few arguments.
2017-10-16 Sandra Loosemore <sandra@codesourcery.com> Henry Wong <henry@stuffedcow.net> gas/ * config/tc-nios2.c (nios2_translate_pseudo_insn): Check for correct number of arguments. (md_assemble): Handle failure of nios2_translate_pseudo_insn. * testsuite/gas/nios2/illegal_pseudoinst.l: New file. * testsuite/gas/nios2/illegal_pseudoinst.s: New file. * testsuite/gas/nios2/nios2.exp: Add illegal_pseudoinst test.
Diffstat (limited to 'gas/testsuite')
-rw-r--r--gas/testsuite/gas/nios2/illegal_pseudoinst.l35
-rw-r--r--gas/testsuite/gas/nios2/illegal_pseudoinst.s45
-rw-r--r--gas/testsuite/gas/nios2/nios2.exp1
3 files changed, 81 insertions, 0 deletions
diff --git a/gas/testsuite/gas/nios2/illegal_pseudoinst.l b/gas/testsuite/gas/nios2/illegal_pseudoinst.l
new file mode 100644
index 0000000..7d4ffdf
--- /dev/null
+++ b/gas/testsuite/gas/nios2/illegal_pseudoinst.l
@@ -0,0 +1,35 @@
+.*illegal_pseudoinst.s: Assembler messages:
+.*illegal_pseudoinst.s:5: Error: missing argument
+.*illegal_pseudoinst.s:6: Error: expecting , near r2
+.*illegal_pseudoinst.s:6: Error: missing argument
+.*illegal_pseudoinst.s:7: Error: missing argument
+.*illegal_pseudoinst.s:8: Error: expecting , near r2
+.*illegal_pseudoinst.s:8: Error: missing argument
+.*illegal_pseudoinst.s:9: Error: missing argument
+.*illegal_pseudoinst.s:10: Error: missing argument
+.*illegal_pseudoinst.s:11: Error: missing argument
+.*illegal_pseudoinst.s:14: Error: missing argument
+.*illegal_pseudoinst.s:15: Error: missing argument
+.*illegal_pseudoinst.s:16: Error: expecting , near r2
+.*illegal_pseudoinst.s:16: Error: missing argument
+.*illegal_pseudoinst.s:17: Error: missing argument
+.*illegal_pseudoinst.s:18: Error: missing argument
+.*illegal_pseudoinst.s:19: Error: missing argument
+.*illegal_pseudoinst.s:22: Error: missing argument
+.*illegal_pseudoinst.s:23: Error: missing argument
+.*illegal_pseudoinst.s:24: Error: missing argument
+.*illegal_pseudoinst.s:25: Error: missing argument
+.*illegal_pseudoinst.s:26: Error: missing argument
+.*illegal_pseudoinst.s:27: Error: missing argument
+.*illegal_pseudoinst.s:28: Error: missing argument
+.*illegal_pseudoinst.s:29: Error: missing argument
+.*illegal_pseudoinst.s:30: Error: missing argument
+.*illegal_pseudoinst.s:31: Error: missing argument
+.*illegal_pseudoinst.s:34: Error: missing argument
+.*illegal_pseudoinst.s:35: Error: missing argument
+.*illegal_pseudoinst.s:36: Error: unknown register
+.*illegal_pseudoinst.s:37: Error: missing argument
+.*illegal_pseudoinst.s:38: Error: missing argument
+.*illegal_pseudoinst.s:41: Error: missing argument
+.*illegal_pseudoinst.s:42: Error: missing argument
+.*illegal_pseudoinst.s:43: Error: missing argument
diff --git a/gas/testsuite/gas/nios2/illegal_pseudoinst.s b/gas/testsuite/gas/nios2/illegal_pseudoinst.s
new file mode 100644
index 0000000..94b48cb
--- /dev/null
+++ b/gas/testsuite/gas/nios2/illegal_pseudoinst.s
@@ -0,0 +1,45 @@
+# Source file used to test missing (and illegal) operands for pseudo-instructions.
+
+foo:
+# nios2_modify_arg
+ cmpgti r2, r3,
+ cmpgtui r2, r2
+ cmplei r2, r3,
+ cmpleui r2, r2
+ cmpgti ,,
+ cmplei ,
+ cmpleui
+
+# nios2_negate_arg
+ subi Lorem ipsum dolor sit amet, consectetur adipiscing elit,
+ subi r2, r2,
+ subi r2, r2
+ subi ,,
+ subi ,
+ subi
+
+# nios2_swap_args
+ bgt r0, r2,
+ bgtu ,,
+ ble , r0,
+ bleu foo,,
+ cmpgt r2, r3,
+ cmpgtu r2,,
+ cmple , r3,
+ cmpleu ,,
+ bgtu ,
+ ble
+
+# nios2_insert_arg
+ movi ,
+ movhi r0,
+ movui ,r2
+ movia ,
+ movi
+
+# nios2_append_arg
+ mov r0,
+ mov ,
+ mov
+
+
diff --git a/gas/testsuite/gas/nios2/nios2.exp b/gas/testsuite/gas/nios2/nios2.exp
index 061d610..e2cd332 100644
--- a/gas/testsuite/gas/nios2/nios2.exp
+++ b/gas/testsuite/gas/nios2/nios2.exp
@@ -22,6 +22,7 @@ if { [istarget nios2-*-*] } {
run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
run_list_test "illegal" ""
+ run_list_test "illegal_pseudoinst" ""
run_list_test "warn_nobreak" ""
run_list_test "warn_noat" ""
run_list_test "movi" ""