diff options
author | Jan Beulich <jbeulich@novell.com> | 2018-07-11 10:23:48 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2018-07-11 10:23:48 +0200 |
commit | 76d3a78a498e814fa1fea713091849cba7896f7a (patch) | |
tree | 6ba0d4405525d1c09495a663e89b8f858351d702 | |
parent | c7df3df443db7b1840735c86a38e00243a2902f7 (diff) | |
download | gdb-76d3a78a498e814fa1fea713091849cba7896f7a.zip gdb-76d3a78a498e814fa1fea713091849cba7896f7a.tar.gz gdb-76d3a78a498e814fa1fea713091849cba7896f7a.tar.bz2 |
x86: fix "REP RET" with -madd-bnd-prefix
Just like any other branches, RET should gain a BND prefix also when
already prefixed in source by REP.
-rw-r--r-- | gas/ChangeLog | 13 | ||||
-rw-r--r-- | gas/config/tc-i386.c | 14 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/mpx-add-bnd-prefix.d | 7 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/mpx-add-bnd-prefix.e | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/mpx-add-bnd-prefix.s | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.d | 7 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.e | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.s | 3 |
8 files changed, 45 insertions, 8 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index d49fc11..6de7a61 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,16 @@ +2018-07-11 Jan Beulich <jbeulich@suse.com> + + * config/tc-i386.c (md_assemble): Also replace an already + present REP prefix. + * testsuite/gas/i386/mpx-add-bnd-prefix.s, + testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.s: Test RET with + all REP flavors. + * testsuite/gas/i386/mpx-add-bnd-prefix.d, + testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.d: Adjust + expectations. + * testsuite/gas/i386/mpx-add-bnd-prefix.e, + testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.e: New. + 2018-07-09 Jeff Law <law@redhat.com> * testsuite/nds32/ji-jr.d: Fix name tag. diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 2d20f1c..a7b8400 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -4112,10 +4112,16 @@ md_assemble (char *line) } /* Insert BND prefix. */ - if (add_bnd_prefix - && i.tm.opcode_modifier.bndprefixok - && !i.prefix[BND_PREFIX]) - add_prefix (BND_PREFIX_OPCODE); + if (add_bnd_prefix && i.tm.opcode_modifier.bndprefixok) + { + if (!i.prefix[BND_PREFIX]) + add_prefix (BND_PREFIX_OPCODE); + else if (i.prefix[BND_PREFIX] != BND_PREFIX_OPCODE) + { + as_warn (_("replacing `rep'/`repe' prefix by `bnd'")); + i.prefix[BND_PREFIX] = BND_PREFIX_OPCODE; + } + } /* Check string instruction segment overrides. */ if (i.tm.opcode_modifier.isstring && i.mem_operands != 0) diff --git a/gas/testsuite/gas/i386/mpx-add-bnd-prefix.d b/gas/testsuite/gas/i386/mpx-add-bnd-prefix.d index 571f0da..30f6502 100644 --- a/gas/testsuite/gas/i386/mpx-add-bnd-prefix.d +++ b/gas/testsuite/gas/i386/mpx-add-bnd-prefix.d @@ -1,4 +1,5 @@ #as: -madd-bnd-prefix +#stderr: mpx-add-bnd-prefix.e #objdump: -drw #name: Check -madd-bnd-prefix @@ -18,7 +19,9 @@ Disassembly of section .text: 0+14 <foo>: [ ]*[a-f0-9]+: f2 c3 bnd ret [ ]*[a-f0-9]+: f2 c3 bnd ret -[ ]*[a-f0-9]+: f2 e8 f6 ff ff ff bnd call 14 <foo> +[ ]*[a-f0-9]+: f2 c3 bnd ret +[ ]*[a-f0-9]+: f2 c3 bnd ret +[ ]*[a-f0-9]+: f2 e8 f2 ff ff ff bnd call 14 <foo> [ ]*[a-f0-9]+: 01 c3 add %eax,%ebx -[ ]*[a-f0-9]+: e2 f2 loop 14 <foo> +[ ]*[a-f0-9]+: e2 ee loop 14 <foo> #pass diff --git a/gas/testsuite/gas/i386/mpx-add-bnd-prefix.e b/gas/testsuite/gas/i386/mpx-add-bnd-prefix.e new file mode 100644 index 0000000..4e99ad0 --- /dev/null +++ b/gas/testsuite/gas/i386/mpx-add-bnd-prefix.e @@ -0,0 +1,3 @@ +.*: Assembler messages: +.*:12: Warning: .*rep.*bnd.* +.*:13: Warning: .*rep.*bnd.* diff --git a/gas/testsuite/gas/i386/mpx-add-bnd-prefix.s b/gas/testsuite/gas/i386/mpx-add-bnd-prefix.s index 638dafa..a75faa7 100644 --- a/gas/testsuite/gas/i386/mpx-add-bnd-prefix.s +++ b/gas/testsuite/gas/i386/mpx-add-bnd-prefix.s @@ -8,6 +8,9 @@ jmp *(%ebx) ret foo: + # Use of REP/REPE prefix - converted to BND with warning + rep ret + repe ret # Use of REPNE prefix - we shouldn't get any error repne ret # BND prefix already exists - we shouldn't get any error here diff --git a/gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.d b/gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.d index cef644f..139faae 100644 --- a/gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.d +++ b/gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.d @@ -1,4 +1,5 @@ #as: -madd-bnd-prefix +#stderr: x86-64-mpx-add-bnd-prefix.e #objdump: -drw #name: Check -madd-bnd-prefix (x86-64) @@ -18,7 +19,9 @@ Disassembly of section .text: 0+14 <foo>: [ ]*[a-f0-9]+: f2 c3 bnd retq [ ]*[a-f0-9]+: f2 c3 bnd retq -[ ]*[a-f0-9]+: f2 e8 f6 ff ff ff bnd callq 14 <foo> +[ ]*[a-f0-9]+: f2 c3 bnd retq +[ ]*[a-f0-9]+: f2 c3 bnd retq +[ ]*[a-f0-9]+: f2 e8 f2 ff ff ff bnd callq 14 <foo> [ ]*[a-f0-9]+: 48 01 c3 add %rax,%rbx -[ ]*[a-f0-9]+: e2 f1 loop 14 <foo> +[ ]*[a-f0-9]+: e2 ed loop 14 <foo> #pass diff --git a/gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.e b/gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.e new file mode 100644 index 0000000..4e99ad0 --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.e @@ -0,0 +1,3 @@ +.*: Assembler messages: +.*:12: Warning: .*rep.*bnd.* +.*:13: Warning: .*rep.*bnd.* diff --git a/gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.s b/gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.s index f9a900c..c1be9ef 100644 --- a/gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.s +++ b/gas/testsuite/gas/i386/x86-64-mpx-add-bnd-prefix.s @@ -8,6 +8,9 @@ jmp *(%rbx) ret foo: + # Use of REP/REPE prefix - converted to BND with warning + rep ret + repe ret # Use of REPNE prefix - we shouldn't get any error repne ret # BND prefix already exists - we shouldn't get any error here |