This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR binutils/16891: Handle prefixes before fwait
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Tue, 10 Jun 2014 11:23:52 -0700
- Subject: Re: [PATCH] PR binutils/16891: Handle prefixes before fwait
- Authentication-results: sourceware.org; auth=none
- References: <20140501164625 dot GA14171 at intel dot com>
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
On Thu, May 01, 2014 at 09:46:25AM -0700, H.J. Lu wrote:
> 0x9b (fwait) is both an instruction and an opcode prefix. When 0x9b is
> treated as an instruction, we need to handle any prefixes before it.
> This patch handles it properly. I checked it in.
>
>
> H.J.
> ---
> gas/testsuite/
>
> PR binutils/16891
> * gas/i386/opcode.s: Add test for fwait with prefix.
> * gas/i386/opcode-intel.d: Updated.
> * gas/i386/opcode-suffix.d: Likewise.
> * gas/i386/opcode.d: Likewise.
>
> opcodes/
>
> PR binutils/16891
> * i386-dis.c (print_insn): Handle prefixes before fwait.
> ---
> gas/testsuite/ChangeLog | 8 ++++++++
> gas/testsuite/gas/i386/opcode-intel.d | 2 ++
> gas/testsuite/gas/i386/opcode-suffix.d | 2 ++
> gas/testsuite/gas/i386/opcode.d | 2 ++
> gas/testsuite/gas/i386/opcode.s | 3 +++
> opcodes/ChangeLog | 5 +++++
> opcodes/i386-dis.c | 8 +++++++-
> 7 files changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
> index 0e07606..c36c632 100644
> --- a/opcodes/i386-dis.c
> +++ b/opcodes/i386-dis.c
> @@ -12548,8 +12548,14 @@ print_insn (bfd_vma pc, disassemble_info *info)
> if (((prefixes & PREFIX_FWAIT)
> && ((*codep < 0xd8) || (*codep > 0xdf))))
> {
> + /* Handle prefixes before fwait. */
> + for (i = 0;
> + i < (int) ARRAY_SIZE (all_prefixes) && all_prefixes[i];
> + i++)
> + (*info->fprintf_func) (info->stream, "%s ",
> + prefix_name (all_prefixes[i], sizeflag));
> (*info->fprintf_func) (info->stream, "fwait");
> - return 1;
> + return i + 1;
> }
>
This may print prefixes after FWAIT. I checked in this patch to prevent
it.
H.J.
--
commit d9949a367352c66b7d90ca32bdbd5cac38c14b53
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Jun 10 11:16:41 2014 -0700
Only print prefixes before fwait
gas/testsuite/
* gas/i386/prefix.s: Add another fwait test.
* gas/i386/prefix.d: Updated.
opcodes/
* i386-dis.c (fwait_prefix): New.
(ckprefix): Set fwait_prefix.
(print_insn): Properly print prefixes before fwait.
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 768c26b..43a37e3 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ * gas/i386/prefix.s: Add another fwait test.
+ * gas/i386/prefix.d: Updated.
+
2014-06-09 Nick Clifton <nickc@redhat.com>
* gas/msp430/msp430x.d: Update to match revised assembler output.
diff --git a/gas/testsuite/gas/i386/prefix.d b/gas/testsuite/gas/i386/prefix.d
index d9f0ae2..a334ab8 100644
--- a/gas/testsuite/gas/i386/prefix.d
+++ b/gas/testsuite/gas/i386/prefix.d
@@ -12,6 +12,8 @@ Disassembly of section .text:
[ ]*[a-f0-9]+: 9b 67 df e0 addr16 fstsw %ax
[ ]*[a-f0-9]+: 36 67 66 f3 a7 repz cmpsw %es:\(%di\),%ss:\(%si\)
[ ]*[a-f0-9]+: 26 9b es fwait
+[ ]*[a-f0-9]+: 9b fwait
+[ ]*[a-f0-9]+: 65 c7 05 00 00 00 00 00 00 00 00 movl \$0x0,%gs:0x0
[ ]*[a-f0-9]+: 66 f2 0f 38 17 data16 \(bad\)
[ ]*[a-f0-9]+: f2 66 0f 54 repnz \(bad\)
[ ]*[a-f0-9]+: f2 0f 54 repnz \(bad\)
diff --git a/gas/testsuite/gas/i386/prefix.s b/gas/testsuite/gas/i386/prefix.s
index 07020ea..9f90afa 100644
--- a/gas/testsuite/gas/i386/prefix.s
+++ b/gas/testsuite/gas/i386/prefix.s
@@ -4,6 +4,9 @@
es fwait
+ fwait
+ movl $0,%gs:fpu_owner_task
+
.byte 0x66
.byte 0xf2
.byte 0x0f
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 6e3d6c9..581e5db 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ * i386-dis.c (fwait_prefix): New.
+ (ckprefix): Set fwait_prefix.
+ (print_insn): Properly print prefixes before fwait.
+
2014-06-07 Alan Modra <amodra@gmail.com>
* ppc-opc.c (UISIGNOPT): Define and use with cmpli.
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 3c48428..24406f3 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -2883,6 +2883,7 @@ static int last_data_prefix;
static int last_addr_prefix;
static int last_rex_prefix;
static int last_seg_prefix;
+static int fwait_prefix;
/* The PREFIX_REPZ/PREFIX_REPNZ/PREFIX_DATA prefix is mandatory. */
static int mandatory_prefix;
/* The active segment register prefix. */
@@ -11631,6 +11632,7 @@ ckprefix (void)
last_addr_prefix = -1;
last_rex_prefix = -1;
last_seg_prefix = -1;
+ fwait_prefix = -1;
active_seg_prefix = 0;
for (i = 0; i < (int) ARRAY_SIZE (all_prefixes); i++)
all_prefixes[i] = 0;
@@ -11720,6 +11722,7 @@ ckprefix (void)
/* fwait is really an instruction. If there are prefixes
before the fwait, they belong to the fwait, *not* to the
following instruction. */
+ fwait_prefix = i;
if (prefixes || rex)
{
prefixes |= PREFIX_FWAIT;
@@ -12569,8 +12572,7 @@ print_insn (bfd_vma pc, disassemble_info *info)
&& ((*codep < 0xd8) || (*codep > 0xdf))))
{
/* Handle prefixes before fwait. */
- for (i = 0;
- i < (int) ARRAY_SIZE (all_prefixes) && all_prefixes[i];
+ for (i = 0; i < fwait_prefix && all_prefixes[i];
i++)
(*info->fprintf_func) (info->stream, "%s ",
prefix_name (all_prefixes[i], sizeflag));