From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11201 invoked by alias); 3 Aug 2012 23:00:38 -0000 Received: (qmail 11163 invoked by uid 22791); 3 Aug 2012 23:00:32 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_XF,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-qa0-f48.google.com (HELO mail-qa0-f48.google.com) (209.85.216.48) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Aug 2012 23:00:03 +0000 Received: by qadz32 with SMTP id z32so2959052qad.0 for ; Fri, 03 Aug 2012 16:00:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:x-system-of-record:x-gm-message-state; bh=RbDwUhfvOX+RL+75Unufq1oG4Z+Do4X6GStYMnRQta0=; b=Ok4GO3V0pyT/hcMPnHqwWJ+naV3WZ+recjHCXlDyYSoPeaF7ve5iefqrFexFuJhdlI w9Xz9P8jHm40pSjbPZ3ueHPgwbU50tMePr0ewjw/gtFnO6E6IUt4CmHqjXCSR1uM6f3z Som/JxMiCHR6k0Ku0Ml1D9kx/zXwP8axtYOJ0DE6C3oXaaXwf5H2r0wCtrUel9X5odu2 pb0jEPg98Hx3F6XnJOOEgdnFHGP/zGgU2UxdPZyIdjPDSIRNW1gdJFVQNVKX/NVGJ+cI UndfRY5+W2+Tqf3Ba5XbIJRtAyEivE+Xn6IE+X8IGaAmnHcbO+/hlepc/9+7hnd6QOjc 2oDw== Received: by 10.224.191.74 with SMTP id dl10mr5550881qab.14.1344034802718; Fri, 03 Aug 2012 16:00:02 -0700 (PDT) Received: by 10.224.191.74 with SMTP id dl10mr5550860qab.14.1344034802417; Fri, 03 Aug 2012 16:00:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.164.206 with HTTP; Fri, 3 Aug 2012 15:59:42 -0700 (PDT) In-Reply-To: References: From: Roland McGrath Date: Fri, 03 Aug 2012 23:24:00 -0000 Message-ID: Subject: Re: [RFC PATCH] Fix decoding of superfluous data32 prefix before superfluous rex.W prefix before push. To: "H.J. Lu" Cc: Victor Khimenko , binutils@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true X-Gm-Message-State: ALoCoQnEa6H/HV12uZRF6sEuHxqW/Sa35leTZp+PxoU2lefJLK+PamB86d5AShUlziVdwpq2coa6zL0737+ze6eIiBxOpsBcUZZL8oMnYUeyDhqdb0Of4ETH7EbJ6dVCM5g2CWPqkUwNc2ieDNodK31vP7bu9d1vIMZgpOqgJIV2CFWSxtHBbxaN3ziQYopkHs/JLiuEKg5G Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00081.txt.bz2 I noticed that since you used #pass in the .d files, one could add more cases to the end of x86-64-stack.s and not notice if one failed to update all the .d files appropriately. So I added a nop at the end, to make sure that's matched last. What I was hoping is that you could tell me how to change: 0: 66 48 6a ff data32 pushq $0xffffffffffffffff 4: 66 48 68 01 02 03 04 data32 pushq $0x4030201 into: 0: 66 48 6a ff data32 rex.W pushq $0xffffffffffffffff 4: 66 48 68 01 02 03 04 data32 rex.W pushq $0x4030201 i.e., recognize that the rex.W prefix was not used, as it already does when there is no data32 prefix before it. Do you have an idea to fix that? Here's what I have now. But I'd really prefer not to commit it like this if we can make it show the unused rex.W prefix instead. Thanks, Roland gas/testsuite/ * gas/i386/x86-64-stack.s: Add cases for push immediate. * gas/testsuite/gas/i386/ilp32/x86-64-stack-intel.d: Updated. * gas/testsuite/gas/i386/ilp32/x86-64-stack-suffix.d: Updated. * gas/testsuite/gas/i386/ilp32/x86-64-stack.d: Updated. * gas/testsuite/gas/i386/x86-64-stack-intel.d: Updated. * gas/testsuite/gas/i386/x86-64-stack-suffix.d: Updated. * gas/testsuite/gas/i386/x86-64-stack.d: Updated. opcodes/ 2012-08-03 Roland McGrath Victor Khimenko * i386-dis.c (OP_sI): In b_T_mode and v_mode, REX_W trumps DFLAG. diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-stack-intel.d b/gas/testsuite/gas/i386/ilp32/x86-64-stack-intel.d index 7092a42..a5692c9 100644 --- a/gas/testsuite/gas/i386/ilp32/x86-64-stack-intel.d +++ b/gas/testsuite/gas/i386/ilp32/x86-64-stack-intel.d @@ -47,4 +47,14 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 66 ff 30 push WORD PTR \[rax\] [ ]*[a-f0-9]+: 48 ff 30 rex.W push QWORD PTR \[rax\] [ ]*[a-f0-9]+: 66 48 ff 30 data32 push QWORD PTR \[rax\] +[ ]*[a-f0-9]+: 6a ff push 0xffffffffffffffff +[ ]*[a-f0-9]+: 66 6a ff pushw 0xffff +[ ]*[a-f0-9]+: 48 6a ff rex.W push 0xffffffffffffffff +[ ]*[a-f0-9]+: 66 48 6a ff data32 rex.W push 0xffffffffffffffff +[ ]*[a-f0-9]+: 68 01 02 03 04 push 0x4030201 +[ ]*[a-f0-9]+: 66 68 01 02 pushw 0x201 +[ ]*[a-f0-9]+: 03 04 48 add eax,DWORD PTR \[rax\+rcx\*2\] +[ ]*[a-f0-9]+: 68 01 02 03 04 push 0x4030201 +[ ]*[a-f0-9]+: 66 48 68 01 02 03 04 data32 rex.W push 0x4030201 +[ ]*[a-f0-9]+: 90 nop #pass diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-stack-suffix.d b/gas/testsuite/gas/i386/ilp32/x86-64-stack-suffix.d index 45101dd..ecc8c75 100644 --- a/gas/testsuite/gas/i386/ilp32/x86-64-stack-suffix.d +++ b/gas/testsuite/gas/i386/ilp32/x86-64-stack-suffix.d @@ -47,4 +47,14 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 66 ff 30 pushw \(%rax\) [ ]*[a-f0-9]+: 48 ff 30 rex.W pushq \(%rax\) [ ]*[a-f0-9]+: 66 48 ff 30 data32 pushq \(%rax\) +[ ]*[a-f0-9]+: 6a ff pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 66 6a ff pushw \$0xffff +[ ]*[a-f0-9]+: 48 6a ff rex.W pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 66 48 6a ff data32 pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 68 01 02 03 04 pushq \$0x4030201 +[ ]*[a-f0-9]+: 66 68 01 02 pushw \$0x201 +[ ]*[a-f0-9]+: 03 04 48 addl \(%rax,%rcx,2\),%eax +[ ]*[a-f0-9]+: 68 01 02 03 04 pushq \$0x4030201 +[ ]*[a-f0-9]+: 66 48 68 01 02 03 04 data32 pushq \$0x4030201 +[ ]*[a-f0-9]+: 90 nop #pass diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-stack.d b/gas/testsuite/gas/i386/ilp32/x86-64-stack.d index 4976597..67b89f4 100644 --- a/gas/testsuite/gas/i386/ilp32/x86-64-stack.d +++ b/gas/testsuite/gas/i386/ilp32/x86-64-stack.d @@ -47,4 +47,14 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 66 ff 30 pushw \(%rax\) [ ]*[a-f0-9]+: 48 ff 30 rex.W pushq \(%rax\) [ ]*[a-f0-9]+: 66 48 ff 30 data32 pushq \(%rax\) +[ ]*[a-f0-9]+: 6a ff pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 66 6a ff pushw \$0xffff +[ ]*[a-f0-9]+: 48 6a ff rex.W pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 66 48 6a ff data32 pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 68 01 02 03 04 pushq \$0x4030201 +[ ]*[a-f0-9]+: 66 68 01 02 pushw \$0x201 +[ ]*[a-f0-9]+: 03 04 48 add \(%rax,%rcx,2\),%eax +[ ]*[a-f0-9]+: 68 01 02 03 04 pushq \$0x4030201 +[ ]*[a-f0-9]+: 66 48 68 01 02 03 04 data32 pushq \$0x4030201 +[ ]*[a-f0-9]+: 90 nop #pass diff --git a/gas/testsuite/gas/i386/x86-64-stack-intel.d b/gas/testsuite/gas/i386/x86-64-stack-intel.d index 4c54af7..cbe4880 100644 --- a/gas/testsuite/gas/i386/x86-64-stack-intel.d +++ b/gas/testsuite/gas/i386/x86-64-stack-intel.d @@ -47,4 +47,14 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 66 ff 30 push WORD PTR \[rax\] [ ]*[a-f0-9]+: 48 ff 30 rex.W push QWORD PTR \[rax\] [ ]*[a-f0-9]+: 66 48 ff 30 data32 push QWORD PTR \[rax\] +[ ]*[a-f0-9]+: 6a ff push 0xffffffffffffffff +[ ]*[a-f0-9]+: 66 6a ff pushw 0xffff +[ ]*[a-f0-9]+: 48 6a ff rex.W push 0xffffffffffffffff +[ ]*[a-f0-9]+: 66 48 6a ff data32 rex.W push 0xffffffffffffffff +[ ]*[a-f0-9]+: 68 01 02 03 04 push 0x4030201 +[ ]*[a-f0-9]+: 66 68 01 02 pushw 0x201 +[ ]*[a-f0-9]+: 03 04 48 add eax,DWORD PTR \[rax\+rcx\*2\] +[ ]*[a-f0-9]+: 68 01 02 03 04 push 0x4030201 +[ ]*[a-f0-9]+: 66 48 68 01 02 03 04 data32 rex.W push 0x4030201 +[ ]*[a-f0-9]+: 90 nop #pass diff --git a/gas/testsuite/gas/i386/x86-64-stack-suffix.d b/gas/testsuite/gas/i386/x86-64-stack-suffix.d index 07bf79b..fc9b1ff 100644 --- a/gas/testsuite/gas/i386/x86-64-stack-suffix.d +++ b/gas/testsuite/gas/i386/x86-64-stack-suffix.d @@ -47,4 +47,14 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 66 ff 30 pushw \(%rax\) [ ]*[a-f0-9]+: 48 ff 30 rex.W pushq \(%rax\) [ ]*[a-f0-9]+: 66 48 ff 30 data32 pushq \(%rax\) +[ ]*[a-f0-9]+: 6a ff pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 66 6a ff pushw \$0xffff +[ ]*[a-f0-9]+: 48 6a ff rex.W pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 66 48 6a ff data32 pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 68 01 02 03 04 pushq \$0x4030201 +[ ]*[a-f0-9]+: 66 68 01 02 pushw \$0x201 +[ ]*[a-f0-9]+: 03 04 48 addl \(%rax,%rcx,2\),%eax +[ ]*[a-f0-9]+: 68 01 02 03 04 pushq \$0x4030201 +[ ]*[a-f0-9]+: 66 48 68 01 02 03 04 data32 pushq \$0x4030201 +[ ]*[a-f0-9]+: 90 nop #pass diff --git a/gas/testsuite/gas/i386/x86-64-stack.d b/gas/testsuite/gas/i386/x86-64-stack.d index 0ab339d..899eff0 100644 --- a/gas/testsuite/gas/i386/x86-64-stack.d +++ b/gas/testsuite/gas/i386/x86-64-stack.d @@ -46,4 +46,14 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 66 ff 30 pushw \(%rax\) [ ]*[a-f0-9]+: 48 ff 30 rex.W pushq \(%rax\) [ ]*[a-f0-9]+: 66 48 ff 30 data32 pushq \(%rax\) +[ ]*[a-f0-9]+: 6a ff pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 66 6a ff pushw \$0xffff +[ ]*[a-f0-9]+: 48 6a ff rex.W pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 66 48 6a ff data32 pushq \$0xffffffffffffffff +[ ]*[a-f0-9]+: 68 01 02 03 04 pushq \$0x4030201 +[ ]*[a-f0-9]+: 66 68 01 02 pushw \$0x201 +[ ]*[a-f0-9]+: 03 04 48 add \(%rax,%rcx,2\),%eax +[ ]*[a-f0-9]+: 68 01 02 03 04 pushq \$0x4030201 +[ ]*[a-f0-9]+: 66 48 68 01 02 03 04 data32 pushq \$0x4030201 +[ ]*[a-f0-9]+: 90 nop #pass diff --git a/gas/testsuite/gas/i386/x86-64-stack.s b/gas/testsuite/gas/i386/x86-64-stack.s index d114887..2da658b 100644 --- a/gas/testsuite/gas/i386/x86-64-stack.s +++ b/gas/testsuite/gas/i386/x86-64-stack.s @@ -22,3 +22,13 @@ _start: try 0xff, 0xf0 try 0xff, 0x30 + + # push with a 1-byte immediate + try 0x6a, 0xff + + # push with a 4-byte immediate + try 0x68, 0x01, 0x02, 0x03, 0x04 + + # This is just to synchronize the disassembly. + # Any new cases must come before this line! + nop diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 685e968..c207e06 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -1,6 +1,6 @@ /* Print i386 instructions for GDB, the GNU debugger. Copyright 1988, 1989, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This file is part of the GNU opcodes library. @@ -13710,9 +13710,10 @@ OP_sI (int bytemode, int sizeflag) if (bytemode == b_T_mode) { if (address_mode != mode_64bit - || !(sizeflag & DFLAG)) + || !((sizeflag & DFLAG) || (rex & REX_W))) { - if (sizeflag & DFLAG) + /* The operand-size prefix is overridden by a REX prefix. */ + if ((sizeflag & DFLAG) || (rex & REX_W)) op &= 0xffffffff; else op &= 0xffff; @@ -13730,7 +13731,8 @@ OP_sI (int bytemode, int sizeflag) } break; case v_mode: - if (sizeflag & DFLAG) + /* The operand-size prefix is overridden by a REX prefix. */ + if ((sizeflag & DFLAG) || (rex & REX_W)) op = get32s (); else op = get16 ();