x86: Check pseudo prefix without instruction
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 17 Dec 2017 17:40:54 +0000 (09:40 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 17 Dec 2017 17:49:11 +0000 (09:49 -0800)
Pseudo prefixes must be used on an instruction.  Issue an error when
pseudo prefix is used without instruction.

PR gas/22623
* gas/config/tc-i386.c (output_insn): Check pseudo prefix
without instruction.
* testsuite/gas/i386/i386.exp: Run inval-pseudo.
* testsuite/gas/i386/inval-pseudo.l: New file.
* testsuite/gas/i386/inval-pseudo.s: Likewise.

gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/i386.exp
gas/testsuite/gas/i386/inval-pseudo.l [new file with mode: 0644]
gas/testsuite/gas/i386/inval-pseudo.s [new file with mode: 0644]

index 3e00c761d0924db73a9455e421e80be93927ba41..a2d95b740b19319657bd39320fb25de1d1fa5e3b 100644 (file)
@@ -1,3 +1,12 @@
+2017-12-17  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/22623
+       * gas/config/tc-i386.c (output_insn): Check pseudo prefix
+       without instruction.
+       * testsuite/gas/i386/i386.exp: Run inval-pseudo.
+       * testsuite/gas/i386/inval-pseudo.l: New file.
+       * testsuite/gas/i386/inval-pseudo.s: Likewise.
+
 2017-12-15  Jan Beulich  <jbeulich@suse.com>
 
        * config/tc-i386.c (match_template): Add missing ! to
index 5c71bb69ff6165f93c355d0c15d0550b7c488b62..ae1c523fd7a6abb944d67a707090736655846c82 100644 (file)
@@ -7258,6 +7258,12 @@ check_prefix:
              break;
            case 1:
              break;
+           case 0:
+             /* Check for pseudo prefixes.  */
+             as_bad_where (insn_start_frag->fr_file,
+                           insn_start_frag->fr_line,
+                            _("pseudo prefix without instruction"));
+             return;
            default:
              abort ();
            }
index 7e102b621efb8cf16ff2dfe431631a4bd7b56905..302f91cc60a3abbc36000ef8a59ea92898c8a205 100644 (file)
@@ -429,6 +429,7 @@ if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]
     run_list_test "notrackbad" "-al"
     run_dump_test "align-1a"
     run_dump_test "align-1b"
+    run_list_test "inval-pseudo" "-al"
 
     # These tests require support for 8 and 16 bit relocs,
     # so we only run them for ELF and COFF targets.
diff --git a/gas/testsuite/gas/i386/inval-pseudo.l b/gas/testsuite/gas/i386/inval-pseudo.l
new file mode 100644 (file)
index 0000000..cf344f6
--- /dev/null
@@ -0,0 +1,11 @@
+.*: Assembler messages:
+.*:3: Error: .*
+GAS LISTING .*
+
+
+[      ]*1[    ]+\.text
+[      ]*2[    ]+\?\?\?\? 90                   nop
+[      ]*3[    ]+\{disp32\}
+[      ]*4[    ]+\?\?\?\? 90                   nop
+[      ]*5[    ]+\?\?\?\? 00000000             \.p2align 4,0
+#...
diff --git a/gas/testsuite/gas/i386/inval-pseudo.s b/gas/testsuite/gas/i386/inval-pseudo.s
new file mode 100644 (file)
index 0000000..a40362b
--- /dev/null
@@ -0,0 +1,5 @@
+       .text
+       nop
+       {disp32}
+       nop
+       .p2align 4,0