From 390c91cfcffe1a0d75b6100d1542cda2544993b3 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sun, 17 Dec 2017 09:40:54 -0800 Subject: [PATCH] x86: Check pseudo prefix without instruction 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 | 9 +++++++++ gas/config/tc-i386.c | 6 ++++++ gas/testsuite/gas/i386/i386.exp | 1 + gas/testsuite/gas/i386/inval-pseudo.l | 11 +++++++++++ gas/testsuite/gas/i386/inval-pseudo.s | 5 +++++ 5 files changed, 32 insertions(+) create mode 100644 gas/testsuite/gas/i386/inval-pseudo.l create mode 100644 gas/testsuite/gas/i386/inval-pseudo.s diff --git a/gas/ChangeLog b/gas/ChangeLog index 3e00c76..a2d95b7 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2017-12-17 H.J. Lu + + 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 * config/tc-i386.c (match_template): Add missing ! to diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 5c71bb6..ae1c523 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -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 (); } diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index 7e102b6..302f91c 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -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 index 0000000..cf344f6 --- /dev/null +++ b/gas/testsuite/gas/i386/inval-pseudo.l @@ -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 index 0000000..a40362b --- /dev/null +++ b/gas/testsuite/gas/i386/inval-pseudo.s @@ -0,0 +1,5 @@ + .text + nop + {disp32} + nop + .p2align 4,0 -- 2.7.4