From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7754 invoked by alias); 6 Aug 2012 19:53:55 -0000 Received: (qmail 7741 invoked by uid 22791); 6 Aug 2012 19:53:50 -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-qc0-f169.google.com (HELO mail-qc0-f169.google.com) (209.85.216.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Aug 2012 19:53:34 +0000 Received: by qcsd16 with SMTP id d16so2275584qcs.0 for ; Mon, 06 Aug 2012 12:53:33 -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=XFK7PaOkSExpKlieD1eS7Tc9vzE8WfuhKsDbKhHAdy0=; b=FlE2SmVFJFBD/OCi5pw0E9draldw/isLsev5YeUQyShkWkXfKKFfzoPLKInEtQpXUN bF50ub+1WKzkXCabJuRyRDv62OwiWUDRpWOT1Q7vfjhI4OrdkvP9+AheqPi570OYSuhD VnE3yhIuxu5Pw7VJK2jBskZmNA61BtLqdu32GrxgYJForJkfsUNp/LjfS++vsU03oF8P qIyMJeLAvioLf7WHUQ3kA8bPNpUds2yVRIwBFzjW40TAkCIb60GDlla4+ShcEA6kfjbY waASwvtXVEFtI9OFO/+ceX1o0Y4MV/l+b0U6LQXEBV4dAitoh8IGeHiFC4A0xSxCVcRP Y5UQ== Received: by 10.229.136.144 with SMTP id r16mr5974947qct.14.1344282813362; Mon, 06 Aug 2012 12:53:33 -0700 (PDT) Received: by 10.229.136.144 with SMTP id r16mr5974938qct.14.1344282813136; Mon, 06 Aug 2012 12:53:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.164.206 with HTTP; Mon, 6 Aug 2012 12:53:12 -0700 (PDT) In-Reply-To: References: From: Roland McGrath Date: Mon, 06 Aug 2012 20:02: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: ALoCoQnzP8zuuEOzi/tq6V5Yli9AjEr+JjauX/j9ApdLH/vuUGRpZMMFPzWdV8LUC5jwgT8Xb3yVRQ/fIoTkM5OvfS+kNabjRL7Iyf2K3bCTBm6+pFazTQf2OotFLhctiQ1BpBkZFj2GQ9sercZ+PWXWQ7S1whdY2nQVZkhC9r85tvhCuMKfSNzvieUCIosBib7NahYkitzv 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/msg00102.txt.bz2 Thanks for that pointer. I followed that hint to do a few more similar changes and managed to get to where all the "66 48 ..." cases in x86-64-stack.s produce "data32 rex.W ...". Here's the final change including all that. There are no other 'make check' regressions on x86_64-linux-gnu. The disassembler code is so hairy that I can't be sure I haven't broken some other case for which there is no test coverage. But you might know it enough better that you can be more confident than I am. Ok for trunk? Thanks, Roland gas/testsuite/ 2012-08-06 Roland McGrath * 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-06 Roland McGrath Victor Khimenko H.J. Lu * i386-dis.c (OP_sI): In b_T_mode and v_mode, REX_W trumps DFLAG. (putop): For 'T', 'U', and 'V', treat REX_W like DFLAG. (intel_operand_size): For stack_v_mode, treat REX_W like DFLAG. (OP_E_register): Likewise. (OP_REG): For low 8 whole registers, treat REX_W like 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..fbcada2 100644 --- a/gas/testsuite/gas/i386/ilp32/x86-64-stack-intel.d +++ b/gas/testsuite/gas/i386/ilp32/x86-64-stack-intel.d @@ -10,41 +10,51 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 50 push rax [ ]*[a-f0-9]+: 66 50 push ax [ ]*[a-f0-9]+: 48 50 rex.W push rax -[ ]*[a-f0-9]+: 66 48 50 data32 push rax +[ ]*[a-f0-9]+: 66 48 50 data32 rex.W push rax [ ]*[a-f0-9]+: 58 pop rax [ ]*[a-f0-9]+: 66 58 pop ax [ ]*[a-f0-9]+: 48 58 rex.W pop rax -[ ]*[a-f0-9]+: 66 48 58 data32 pop rax +[ ]*[a-f0-9]+: 66 48 58 data32 rex.W pop rax [ ]*[a-f0-9]+: 8f c0 pop rax [ ]*[a-f0-9]+: 66 8f c0 pop ax [ ]*[a-f0-9]+: 48 8f c0 rex.W pop rax -[ ]*[a-f0-9]+: 66 48 8f c0 data32 pop rax +[ ]*[a-f0-9]+: 66 48 8f c0 data32 rex.W pop rax [ ]*[a-f0-9]+: 8f 00 pop QWORD PTR \[rax\] [ ]*[a-f0-9]+: 66 8f 00 pop WORD PTR \[rax\] [ ]*[a-f0-9]+: 48 8f 00 rex.W pop QWORD PTR \[rax\] -[ ]*[a-f0-9]+: 66 48 8f 00 data32 pop QWORD PTR \[rax\] +[ ]*[a-f0-9]+: 66 48 8f 00 data32 rex.W pop QWORD PTR \[rax\] [ ]*[a-f0-9]+: ff d0 call rax [ ]*[a-f0-9]+: 66 ff d0 call ax [ ]*[a-f0-9]+: 48 ff d0 rex.W call rax -[ ]*[a-f0-9]+: 66 48 ff d0 data32 call rax +[ ]*[a-f0-9]+: 66 48 ff d0 data32 rex.W call rax [ ]*[a-f0-9]+: ff 10 call QWORD PTR \[rax\] [ ]*[a-f0-9]+: 66 ff 10 call WORD PTR \[rax\] [ ]*[a-f0-9]+: 48 ff 10 rex.W call QWORD PTR \[rax\] -[ ]*[a-f0-9]+: 66 48 ff 10 data32 call QWORD PTR \[rax\] +[ ]*[a-f0-9]+: 66 48 ff 10 data32 rex.W call QWORD PTR \[rax\] [ ]*[a-f0-9]+: ff e0 jmp rax [ ]*[a-f0-9]+: 66 ff e0 jmp ax [ ]*[a-f0-9]+: 48 ff e0 rex.W jmp rax -[ ]*[a-f0-9]+: 66 48 ff e0 data32 jmp rax +[ ]*[a-f0-9]+: 66 48 ff e0 data32 rex.W jmp rax [ ]*[a-f0-9]+: ff 20 jmp QWORD PTR \[rax\] [ ]*[a-f0-9]+: 66 ff 20 jmp WORD PTR \[rax\] [ ]*[a-f0-9]+: 48 ff 20 rex.W jmp QWORD PTR \[rax\] -[ ]*[a-f0-9]+: 66 48 ff 20 data32 jmp QWORD PTR \[rax\] +[ ]*[a-f0-9]+: 66 48 ff 20 data32 rex.W jmp QWORD PTR \[rax\] [ ]*[a-f0-9]+: ff f0 push rax [ ]*[a-f0-9]+: 66 ff f0 push ax [ ]*[a-f0-9]+: 48 ff f0 rex.W push rax -[ ]*[a-f0-9]+: 66 48 ff f0 data32 push rax +[ ]*[a-f0-9]+: 66 48 ff f0 data32 rex.W push rax [ ]*[a-f0-9]+: ff 30 push QWORD PTR \[rax\] [ ]*[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]+: 66 48 ff 30 data32 rex.W 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..dd2f3da 100644 --- a/gas/testsuite/gas/i386/ilp32/x86-64-stack-suffix.d +++ b/gas/testsuite/gas/i386/ilp32/x86-64-stack-suffix.d @@ -10,41 +10,51 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 50 pushq %rax [ ]*[a-f0-9]+: 66 50 pushw %ax [ ]*[a-f0-9]+: 48 50 rex.W pushq %rax -[ ]*[a-f0-9]+: 66 48 50 data32 pushq %rax +[ ]*[a-f0-9]+: 66 48 50 data32 rex.W pushq %rax [ ]*[a-f0-9]+: 58 popq %rax [ ]*[a-f0-9]+: 66 58 popw %ax [ ]*[a-f0-9]+: 48 58 rex.W popq %rax -[ ]*[a-f0-9]+: 66 48 58 data32 popq %rax +[ ]*[a-f0-9]+: 66 48 58 data32 rex.W popq %rax [ ]*[a-f0-9]+: 8f c0 popq %rax [ ]*[a-f0-9]+: 66 8f c0 popw %ax [ ]*[a-f0-9]+: 48 8f c0 rex.W popq %rax -[ ]*[a-f0-9]+: 66 48 8f c0 data32 popq %rax +[ ]*[a-f0-9]+: 66 48 8f c0 data32 rex.W popq %rax [ ]*[a-f0-9]+: 8f 00 popq \(%rax\) [ ]*[a-f0-9]+: 66 8f 00 popw \(%rax\) [ ]*[a-f0-9]+: 48 8f 00 rex.W popq \(%rax\) -[ ]*[a-f0-9]+: 66 48 8f 00 data32 popq \(%rax\) +[ ]*[a-f0-9]+: 66 48 8f 00 data32 rex.W popq \(%rax\) [ ]*[a-f0-9]+: ff d0 callq \*%rax [ ]*[a-f0-9]+: 66 ff d0 callw \*%ax [ ]*[a-f0-9]+: 48 ff d0 rex.W callq \*%rax -[ ]*[a-f0-9]+: 66 48 ff d0 data32 callq \*%rax +[ ]*[a-f0-9]+: 66 48 ff d0 data32 rex.W callq \*%rax [ ]*[a-f0-9]+: ff 10 callq \*\(%rax\) [ ]*[a-f0-9]+: 66 ff 10 callw \*\(%rax\) [ ]*[a-f0-9]+: 48 ff 10 rex.W callq \*\(%rax\) -[ ]*[a-f0-9]+: 66 48 ff 10 data32 callq \*\(%rax\) +[ ]*[a-f0-9]+: 66 48 ff 10 data32 rex.W callq \*\(%rax\) [ ]*[a-f0-9]+: ff e0 jmpq \*%rax [ ]*[a-f0-9]+: 66 ff e0 jmpw \*%ax [ ]*[a-f0-9]+: 48 ff e0 rex.W jmpq \*%rax -[ ]*[a-f0-9]+: 66 48 ff e0 data32 jmpq \*%rax +[ ]*[a-f0-9]+: 66 48 ff e0 data32 rex.W jmpq \*%rax [ ]*[a-f0-9]+: ff 20 jmpq \*\(%rax\) [ ]*[a-f0-9]+: 66 ff 20 jmpw \*\(%rax\) [ ]*[a-f0-9]+: 48 ff 20 rex.W jmpq \*\(%rax\) -[ ]*[a-f0-9]+: 66 48 ff 20 data32 jmpq \*\(%rax\) +[ ]*[a-f0-9]+: 66 48 ff 20 data32 rex.W jmpq \*\(%rax\) [ ]*[a-f0-9]+: ff f0 pushq %rax [ ]*[a-f0-9]+: 66 ff f0 pushw %ax [ ]*[a-f0-9]+: 48 ff f0 rex.W pushq %rax -[ ]*[a-f0-9]+: 66 48 ff f0 data32 pushq %rax +[ ]*[a-f0-9]+: 66 48 ff f0 data32 rex.W pushq %rax [ ]*[a-f0-9]+: ff 30 pushq \(%rax\) [ ]*[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]+: 66 48 ff 30 data32 rex.W 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 rex.W 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 rex.W 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..9f4553a 100644 --- a/gas/testsuite/gas/i386/ilp32/x86-64-stack.d +++ b/gas/testsuite/gas/i386/ilp32/x86-64-stack.d @@ -10,41 +10,51 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 50 push %rax [ ]*[a-f0-9]+: 66 50 push %ax [ ]*[a-f0-9]+: 48 50 rex.W push %rax -[ ]*[a-f0-9]+: 66 48 50 data32 push %rax +[ ]*[a-f0-9]+: 66 48 50 data32 rex.W push %rax [ ]*[a-f0-9]+: 58 pop %rax [ ]*[a-f0-9]+: 66 58 pop %ax [ ]*[a-f0-9]+: 48 58 rex.W pop %rax -[ ]*[a-f0-9]+: 66 48 58 data32 pop %rax +[ ]*[a-f0-9]+: 66 48 58 data32 rex.W pop %rax [ ]*[a-f0-9]+: 8f c0 pop %rax [ ]*[a-f0-9]+: 66 8f c0 pop %ax [ ]*[a-f0-9]+: 48 8f c0 rex.W pop %rax -[ ]*[a-f0-9]+: 66 48 8f c0 data32 pop %rax +[ ]*[a-f0-9]+: 66 48 8f c0 data32 rex.W pop %rax [ ]*[a-f0-9]+: 8f 00 popq \(%rax\) [ ]*[a-f0-9]+: 66 8f 00 popw \(%rax\) [ ]*[a-f0-9]+: 48 8f 00 rex.W popq \(%rax\) -[ ]*[a-f0-9]+: 66 48 8f 00 data32 popq \(%rax\) +[ ]*[a-f0-9]+: 66 48 8f 00 data32 rex.W popq \(%rax\) [ ]*[a-f0-9]+: ff d0 callq \*%rax [ ]*[a-f0-9]+: 66 ff d0 callw \*%ax [ ]*[a-f0-9]+: 48 ff d0 rex.W callq \*%rax -[ ]*[a-f0-9]+: 66 48 ff d0 data32 callq \*%rax +[ ]*[a-f0-9]+: 66 48 ff d0 data32 rex.W callq \*%rax [ ]*[a-f0-9]+: ff 10 callq \*\(%rax\) [ ]*[a-f0-9]+: 66 ff 10 callw \*\(%rax\) [ ]*[a-f0-9]+: 48 ff 10 rex.W callq \*\(%rax\) -[ ]*[a-f0-9]+: 66 48 ff 10 data32 callq \*\(%rax\) +[ ]*[a-f0-9]+: 66 48 ff 10 data32 rex.W callq \*\(%rax\) [ ]*[a-f0-9]+: ff e0 jmpq \*%rax [ ]*[a-f0-9]+: 66 ff e0 jmpw \*%ax [ ]*[a-f0-9]+: 48 ff e0 rex.W jmpq \*%rax -[ ]*[a-f0-9]+: 66 48 ff e0 data32 jmpq \*%rax +[ ]*[a-f0-9]+: 66 48 ff e0 data32 rex.W jmpq \*%rax [ ]*[a-f0-9]+: ff 20 jmpq \*\(%rax\) [ ]*[a-f0-9]+: 66 ff 20 jmpw \*\(%rax\) [ ]*[a-f0-9]+: 48 ff 20 rex.W jmpq \*\(%rax\) -[ ]*[a-f0-9]+: 66 48 ff 20 data32 jmpq \*\(%rax\) +[ ]*[a-f0-9]+: 66 48 ff 20 data32 rex.W jmpq \*\(%rax\) [ ]*[a-f0-9]+: ff f0 push %rax [ ]*[a-f0-9]+: 66 ff f0 push %ax [ ]*[a-f0-9]+: 48 ff f0 rex.W push %rax -[ ]*[a-f0-9]+: 66 48 ff f0 data32 push %rax +[ ]*[a-f0-9]+: 66 48 ff f0 data32 rex.W push %rax [ ]*[a-f0-9]+: ff 30 pushq \(%rax\) [ ]*[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]+: 66 48 ff 30 data32 rex.W 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 rex.W 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 rex.W 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..cb9ee89 100644 --- a/gas/testsuite/gas/i386/x86-64-stack-intel.d +++ b/gas/testsuite/gas/i386/x86-64-stack-intel.d @@ -10,41 +10,51 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 50 push rax [ ]*[a-f0-9]+: 66 50 push ax [ ]*[a-f0-9]+: 48 50 rex.W push rax -[ ]*[a-f0-9]+: 66 48 50 data32 push rax +[ ]*[a-f0-9]+: 66 48 50 data32 rex.W push rax [ ]*[a-f0-9]+: 58 pop rax [ ]*[a-f0-9]+: 66 58 pop ax [ ]*[a-f0-9]+: 48 58 rex.W pop rax -[ ]*[a-f0-9]+: 66 48 58 data32 pop rax +[ ]*[a-f0-9]+: 66 48 58 data32 rex.W pop rax [ ]*[a-f0-9]+: 8f c0 pop rax [ ]*[a-f0-9]+: 66 8f c0 pop ax [ ]*[a-f0-9]+: 48 8f c0 rex.W pop rax -[ ]*[a-f0-9]+: 66 48 8f c0 data32 pop rax +[ ]*[a-f0-9]+: 66 48 8f c0 data32 rex.W pop rax [ ]*[a-f0-9]+: 8f 00 pop QWORD PTR \[rax\] [ ]*[a-f0-9]+: 66 8f 00 pop WORD PTR \[rax\] [ ]*[a-f0-9]+: 48 8f 00 rex.W pop QWORD PTR \[rax\] -[ ]*[a-f0-9]+: 66 48 8f 00 data32 pop QWORD PTR \[rax\] +[ ]*[a-f0-9]+: 66 48 8f 00 data32 rex.W pop QWORD PTR \[rax\] [ ]*[a-f0-9]+: ff d0 call rax [ ]*[a-f0-9]+: 66 ff d0 call ax [ ]*[a-f0-9]+: 48 ff d0 rex.W call rax -[ ]*[a-f0-9]+: 66 48 ff d0 data32 call rax +[ ]*[a-f0-9]+: 66 48 ff d0 data32 rex.W call rax [ ]*[a-f0-9]+: ff 10 call QWORD PTR \[rax\] [ ]*[a-f0-9]+: 66 ff 10 call WORD PTR \[rax\] [ ]*[a-f0-9]+: 48 ff 10 rex.W call QWORD PTR \[rax\] -[ ]*[a-f0-9]+: 66 48 ff 10 data32 call QWORD PTR \[rax\] +[ ]*[a-f0-9]+: 66 48 ff 10 data32 rex.W call QWORD PTR \[rax\] [ ]*[a-f0-9]+: ff e0 jmp rax [ ]*[a-f0-9]+: 66 ff e0 jmp ax [ ]*[a-f0-9]+: 48 ff e0 rex.W jmp rax -[ ]*[a-f0-9]+: 66 48 ff e0 data32 jmp rax +[ ]*[a-f0-9]+: 66 48 ff e0 data32 rex.W jmp rax [ ]*[a-f0-9]+: ff 20 jmp QWORD PTR \[rax\] [ ]*[a-f0-9]+: 66 ff 20 jmp WORD PTR \[rax\] [ ]*[a-f0-9]+: 48 ff 20 rex.W jmp QWORD PTR \[rax\] -[ ]*[a-f0-9]+: 66 48 ff 20 data32 jmp QWORD PTR \[rax\] +[ ]*[a-f0-9]+: 66 48 ff 20 data32 rex.W jmp QWORD PTR \[rax\] [ ]*[a-f0-9]+: ff f0 push rax [ ]*[a-f0-9]+: 66 ff f0 push ax [ ]*[a-f0-9]+: 48 ff f0 rex.W push rax -[ ]*[a-f0-9]+: 66 48 ff f0 data32 push rax +[ ]*[a-f0-9]+: 66 48 ff f0 data32 rex.W push rax [ ]*[a-f0-9]+: ff 30 push QWORD PTR \[rax\] [ ]*[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]+: 66 48 ff 30 data32 rex.W 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..a0b94d0 100644 --- a/gas/testsuite/gas/i386/x86-64-stack-suffix.d +++ b/gas/testsuite/gas/i386/x86-64-stack-suffix.d @@ -10,41 +10,51 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 50 pushq %rax [ ]*[a-f0-9]+: 66 50 pushw %ax [ ]*[a-f0-9]+: 48 50 rex.W pushq %rax -[ ]*[a-f0-9]+: 66 48 50 data32 pushq %rax +[ ]*[a-f0-9]+: 66 48 50 data32 rex.W pushq %rax [ ]*[a-f0-9]+: 58 popq %rax [ ]*[a-f0-9]+: 66 58 popw %ax [ ]*[a-f0-9]+: 48 58 rex.W popq %rax -[ ]*[a-f0-9]+: 66 48 58 data32 popq %rax +[ ]*[a-f0-9]+: 66 48 58 data32 rex.W popq %rax [ ]*[a-f0-9]+: 8f c0 popq %rax [ ]*[a-f0-9]+: 66 8f c0 popw %ax [ ]*[a-f0-9]+: 48 8f c0 rex.W popq %rax -[ ]*[a-f0-9]+: 66 48 8f c0 data32 popq %rax +[ ]*[a-f0-9]+: 66 48 8f c0 data32 rex.W popq %rax [ ]*[a-f0-9]+: 8f 00 popq \(%rax\) [ ]*[a-f0-9]+: 66 8f 00 popw \(%rax\) [ ]*[a-f0-9]+: 48 8f 00 rex.W popq \(%rax\) -[ ]*[a-f0-9]+: 66 48 8f 00 data32 popq \(%rax\) +[ ]*[a-f0-9]+: 66 48 8f 00 data32 rex.W popq \(%rax\) [ ]*[a-f0-9]+: ff d0 callq \*%rax [ ]*[a-f0-9]+: 66 ff d0 callw \*%ax [ ]*[a-f0-9]+: 48 ff d0 rex.W callq \*%rax -[ ]*[a-f0-9]+: 66 48 ff d0 data32 callq \*%rax +[ ]*[a-f0-9]+: 66 48 ff d0 data32 rex.W callq \*%rax [ ]*[a-f0-9]+: ff 10 callq \*\(%rax\) [ ]*[a-f0-9]+: 66 ff 10 callw \*\(%rax\) [ ]*[a-f0-9]+: 48 ff 10 rex.W callq \*\(%rax\) -[ ]*[a-f0-9]+: 66 48 ff 10 data32 callq \*\(%rax\) +[ ]*[a-f0-9]+: 66 48 ff 10 data32 rex.W callq \*\(%rax\) [ ]*[a-f0-9]+: ff e0 jmpq \*%rax [ ]*[a-f0-9]+: 66 ff e0 jmpw \*%ax [ ]*[a-f0-9]+: 48 ff e0 rex.W jmpq \*%rax -[ ]*[a-f0-9]+: 66 48 ff e0 data32 jmpq \*%rax +[ ]*[a-f0-9]+: 66 48 ff e0 data32 rex.W jmpq \*%rax [ ]*[a-f0-9]+: ff 20 jmpq \*\(%rax\) [ ]*[a-f0-9]+: 66 ff 20 jmpw \*\(%rax\) [ ]*[a-f0-9]+: 48 ff 20 rex.W jmpq \*\(%rax\) -[ ]*[a-f0-9]+: 66 48 ff 20 data32 jmpq \*\(%rax\) +[ ]*[a-f0-9]+: 66 48 ff 20 data32 rex.W jmpq \*\(%rax\) [ ]*[a-f0-9]+: ff f0 pushq %rax [ ]*[a-f0-9]+: 66 ff f0 pushw %ax [ ]*[a-f0-9]+: 48 ff f0 rex.W pushq %rax -[ ]*[a-f0-9]+: 66 48 ff f0 data32 pushq %rax +[ ]*[a-f0-9]+: 66 48 ff f0 data32 rex.W pushq %rax [ ]*[a-f0-9]+: ff 30 pushq \(%rax\) [ ]*[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]+: 66 48 ff 30 data32 rex.W 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 rex.W 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 rex.W 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..76f7151 100644 --- a/gas/testsuite/gas/i386/x86-64-stack.d +++ b/gas/testsuite/gas/i386/x86-64-stack.d @@ -9,41 +9,51 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 50 push %rax [ ]*[a-f0-9]+: 66 50 push %ax [ ]*[a-f0-9]+: 48 50 rex.W push %rax -[ ]*[a-f0-9]+: 66 48 50 data32 push %rax +[ ]*[a-f0-9]+: 66 48 50 data32 rex.W push %rax [ ]*[a-f0-9]+: 58 pop %rax [ ]*[a-f0-9]+: 66 58 pop %ax [ ]*[a-f0-9]+: 48 58 rex.W pop %rax -[ ]*[a-f0-9]+: 66 48 58 data32 pop %rax +[ ]*[a-f0-9]+: 66 48 58 data32 rex.W pop %rax [ ]*[a-f0-9]+: 8f c0 pop %rax [ ]*[a-f0-9]+: 66 8f c0 pop %ax [ ]*[a-f0-9]+: 48 8f c0 rex.W pop %rax -[ ]*[a-f0-9]+: 66 48 8f c0 data32 pop %rax +[ ]*[a-f0-9]+: 66 48 8f c0 data32 rex.W pop %rax [ ]*[a-f0-9]+: 8f 00 popq \(%rax\) [ ]*[a-f0-9]+: 66 8f 00 popw \(%rax\) [ ]*[a-f0-9]+: 48 8f 00 rex.W popq \(%rax\) -[ ]*[a-f0-9]+: 66 48 8f 00 data32 popq \(%rax\) +[ ]*[a-f0-9]+: 66 48 8f 00 data32 rex.W popq \(%rax\) [ ]*[a-f0-9]+: ff d0 callq \*%rax [ ]*[a-f0-9]+: 66 ff d0 callw \*%ax [ ]*[a-f0-9]+: 48 ff d0 rex.W callq \*%rax -[ ]*[a-f0-9]+: 66 48 ff d0 data32 callq \*%rax +[ ]*[a-f0-9]+: 66 48 ff d0 data32 rex.W callq \*%rax [ ]*[a-f0-9]+: ff 10 callq \*\(%rax\) [ ]*[a-f0-9]+: 66 ff 10 callw \*\(%rax\) [ ]*[a-f0-9]+: 48 ff 10 rex.W callq \*\(%rax\) -[ ]*[a-f0-9]+: 66 48 ff 10 data32 callq \*\(%rax\) +[ ]*[a-f0-9]+: 66 48 ff 10 data32 rex.W callq \*\(%rax\) [ ]*[a-f0-9]+: ff e0 jmpq \*%rax [ ]*[a-f0-9]+: 66 ff e0 jmpw \*%ax [ ]*[a-f0-9]+: 48 ff e0 rex.W jmpq \*%rax -[ ]*[a-f0-9]+: 66 48 ff e0 data32 jmpq \*%rax +[ ]*[a-f0-9]+: 66 48 ff e0 data32 rex.W jmpq \*%rax [ ]*[a-f0-9]+: ff 20 jmpq \*\(%rax\) [ ]*[a-f0-9]+: 66 ff 20 jmpw \*\(%rax\) [ ]*[a-f0-9]+: 48 ff 20 rex.W jmpq \*\(%rax\) -[ ]*[a-f0-9]+: 66 48 ff 20 data32 jmpq \*\(%rax\) +[ ]*[a-f0-9]+: 66 48 ff 20 data32 rex.W jmpq \*\(%rax\) [ ]*[a-f0-9]+: ff f0 push %rax [ ]*[a-f0-9]+: 66 ff f0 push %ax [ ]*[a-f0-9]+: 48 ff f0 rex.W push %rax -[ ]*[a-f0-9]+: 66 48 ff f0 data32 push %rax +[ ]*[a-f0-9]+: 66 48 ff f0 data32 rex.W push %rax [ ]*[a-f0-9]+: ff 30 pushq \(%rax\) [ ]*[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]+: 66 48 ff 30 data32 rex.W 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 rex.W 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 rex.W 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..43d7ac3 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. @@ -12275,7 +12275,7 @@ case_L: case 'T': if (!intel_syntax && address_mode == mode_64bit - && (sizeflag & DFLAG)) + && ((sizeflag & DFLAG) || (rex & REX_W))) { *obufp++ = 'q'; break; @@ -12313,7 +12313,8 @@ case_L: case 'U': if (intel_syntax) break; - if (address_mode == mode_64bit && (sizeflag & DFLAG)) + if (address_mode == mode_64bit + && ((sizeflag & DFLAG) || (rex & REX_W))) { if (modrm.mod != 3 || (sizeflag & SUFFIX_ALWAYS)) *obufp++ = 'q'; @@ -12385,7 +12386,8 @@ case_Q: { if (intel_syntax) break; - if (address_mode == mode_64bit && (sizeflag & DFLAG)) + if (address_mode == mode_64bit + && ((sizeflag & DFLAG) || (rex & REX_W))) { if (sizeflag & SUFFIX_ALWAYS) *obufp++ = 'q'; @@ -12721,7 +12723,7 @@ intel_operand_size (int bytemode, int sizeflag) oappend ("WORD PTR "); break; case stack_v_mode: - if (address_mode == mode_64bit && (sizeflag & DFLAG)) + if (address_mode == mode_64bit && ((sizeflag & DFLAG) || (rex & REX_W))) { oappend ("QWORD PTR "); break; @@ -12998,7 +13000,7 @@ OP_E_register (int bytemode, int sizeflag) names = address_mode == mode_64bit ? names64 : names32; break; case stack_v_mode: - if (address_mode == mode_64bit && (sizeflag & DFLAG)) + if (address_mode == mode_64bit && ((sizeflag & DFLAG) || (rex & REX_W))) { names = names64; break; @@ -13495,7 +13497,8 @@ OP_REG (int code, int sizeflag) break; case rAX_reg: case rCX_reg: case rDX_reg: case rBX_reg: case rSP_reg: case rBP_reg: case rSI_reg: case rDI_reg: - if (address_mode == mode_64bit && (sizeflag & DFLAG)) + if (address_mode == mode_64bit + && ((sizeflag & DFLAG) || (rex & REX_W))) { s = names64[code - rAX_reg + add]; break; @@ -13710,9 +13713,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 +13734,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 ();