bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: objdump Disassembles CLFLUSH Incorrectly


From: Alan Modra
Subject: Re: objdump Disassembles CLFLUSH Incorrectly
Date: Fri, 12 Mar 2004 17:29:04 +1030
User-agent: Mutt/1.4i

On Mon, Mar 08, 2004 at 10:46:15AM -0800, Evandro Menezes wrote:
> Both the i386 and the x86-64 binutils disassemble the
> instruction CLFLUSH, as in the example below:
> 
>     clflush (0)
> 
> As SFENCE:
> 
>     0f ae 3d 00 00 00 00    sfence 0x0
> 
> This issue applies to binutils 2.12.90, 2.13.90 and
> 2.14.90.

Yes, there's even a FIXME in the source about this.  Who was the lazy
so-and-so that did that, I wonder?  Fixed with the following.

opcodes/ChangeLog
        * i386-dis.c (grps): Use clflush by default for 0x0fae/7.
        (OP_E): Twiddle clflush to sfence here.

gas/testsuite/gas/ChangeLog
        * gas/i386/katmai.d: Adjust for clflush change.

Index: opcodes/i386-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/i386-dis.c,v
retrieving revision 1.42
diff -u -p -r1.42 i386-dis.c
--- opcodes/i386-dis.c  18 Jan 2004 23:12:47 -0000      1.42
+++ opcodes/i386-dis.c  12 Mar 2004 06:51:50 -0000
@@ -1426,8 +1426,7 @@ static const struct dis386 grps[][8] = {
     { "(bad)", XX, XX, XX },
     { "lfence", None, XX, XX },
     { "mfence", None, XX, XX },
-    { "sfence", None, XX, XX },
-    /* FIXME: the sfence with memory operand is clflush!  */
+    { "clflush", None, XX, XX },
   },
   /* GRP14 */
   {
@@ -3034,9 +3033,16 @@ OP_E (int bytemode, int sizeflag)
          used_prefixes |= (prefixes & PREFIX_DATA);
          break;
        case 0:
-         if (!(codep[-2] == 0xAE && codep[-1] == 0xF8 /* sfence */)
-             && !(codep[-2] == 0xAE && codep[-1] == 0xF0 /* mfence */)
-             && !(codep[-2] == 0xAE && codep[-1] == 0xe8 /* lfence */))
+         if (codep[-2] == 0xAE && codep[-1] == 0xF8)
+           /* sfence */
+           strcpy (obuf + strlen (obuf) - sizeof ("clflush") + 1, "sfence");
+         else if (codep[-2] == 0xAE && codep[-1] == 0xF0)
+           /* mfence */
+           ;
+         else if (codep[-2] == 0xAE && codep[-1] == 0xe8)
+           /* lfence */
+           ;
+         else
            BadOp ();   /* bad sfence,lea,lds,les,lfs,lgs,lss modrm */
          break;
        default:
Index: gas/testsuite/gas/i386/katmai.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/i386/katmai.d,v
retrieving revision 1.6
diff -u -p -r1.6 katmai.d
--- gas/testsuite/gas/i386/katmai.d     18 Jan 2004 23:13:35 -0000      1.6
+++ gas/testsuite/gas/i386/katmai.d     12 Mar 2004 06:51:50 -0000
@@ -165,7 +165,7 @@ Disassembly of section .text:
  246:  90 [    ]*nop    
  247:  90 [    ]*nop    
  248:  65 [    ]*gs
- 249:  0f [    ]*sfence.*\(bad\).*
+ 249:  0f [    ]*clflush.*\(bad\).*
  24a:  ae [    ]*scas   %es:\(%edi\),%al
  24b:  ff 00 [         ]*incl   \(%eax\)
  24d:  00 00 [         ]*add    %al,\(%eax\)

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre




reply via email to

[Prev in Thread] Current Thread [Next in Thread]