public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] x86-64: fix suffix-less PUSH of symbol address
@ 2023-09-27  8:54 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-09-27  8:54 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fb1c10585ead9acc8d9f9d24ab093cbe5e962257

commit fb1c10585ead9acc8d9f9d24ab093cbe5e962257
Author: Jan Beulich <jbeulich@suse.com>
Date:   Wed Sep 27 10:53:38 2023 +0200

    x86-64: fix suffix-less PUSH of symbol address
    
    PR gas/30856
    
    In 5cc007751cdb ("x86: further adjust extend-to-32bit-address
    conditions") I neglected the case of PUSH, which is the only insn
    allowing (proper) symbol addresses to be used as immediates (not
    displacements, like CALL/JMP) in the absence of any register operands.
    Since it defaults to 64-bit operand size, guessing an L suffix is wrong
    there.

Diff:
---
 gas/config/tc-i386.c             | 7 ++++++-
 gas/testsuite/gas/i386/immed64.d | 6 ++++++
 gas/testsuite/gas/i386/immed64.s | 6 ++++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index cec9a02be52..2e3154cb59f 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -6214,7 +6214,12 @@ optimize_imm (void)
     }
   else if ((flag_code == CODE_16BIT) ^ (i.prefix[DATA_PREFIX] != 0))
     guess_suffix = WORD_MNEM_SUFFIX;
-  else if (flag_code != CODE_64BIT || !(i.prefix[REX_PREFIX] & REX_W))
+  else if (flag_code != CODE_64BIT
+	   || (!(i.prefix[REX_PREFIX] & REX_W)
+	       /* A more generic (but also more involved) way of dealing
+		  with the special case(s) would be to go look for
+		  DefaultSize attributes on any of the templates.  */
+	       && current_templates->start->mnem_off != MN_push))
     guess_suffix = LONG_MNEM_SUFFIX;
 
   for (op = i.operands; --op >= 0;)
diff --git a/gas/testsuite/gas/i386/immed64.d b/gas/testsuite/gas/i386/immed64.d
index 35492a5a458..a83ab2c6e1e 100644
--- a/gas/testsuite/gas/i386/immed64.d
+++ b/gas/testsuite/gas/i386/immed64.d
@@ -24,6 +24,12 @@ Disassembly of section \.text:
 [ 	]*[0-9a-fA-F]+:[ 	]+48 b8 04 00 00 00 00 00 00 00[ 	]+movabsq? +\$0x4,%rax
 [ 	]*[0-9a-fA-F]+:[ 	]+48 b8 08 00 00 00 00 00 00 00[ 	]+movabsq? +\$0x8,%rax
 [ 	]*[0-9a-fA-F]+:[ 	]+48 b8 00 00 00 00 00 00 00 00[ 	]+movabsq? +\$0x0,%rax
+[ 	]*[0-9a-fA-F]+:[ 	]+6a 04[ 	]+pushq? +\$0x4
+[ 	]*[0-9a-fA-F]+:[ 	]+68 08 00 00 00[ 	]+pushq? +\$0x8
+[ 	]*[0-9a-fA-F]+:[ 	]+66 6a 04[ 	]+pushw +\$0x4
+[ 	]*[0-9a-fA-F]+:[ 	]+66 68 08 00[ 	]+pushw +\$0x8
+[ 	]*[0-9a-fA-F]+:[ 	]+6a 04[ 	]+pushq? +\$0x4
+[ 	]*[0-9a-fA-F]+:[ 	]+68 08 00 00 00[ 	]+pushq? +\$0x8
 [ 	]*[0-9a-fA-F]+:[ 	]+04 04[ 	]+addb? +\$0x4,%al
 [ 	]*[0-9a-fA-F]+:[ 	]+04 08[ 	]+addb? +\$0x8,%al
 [ 	]*[0-9a-fA-F]+:[ 	]+04 00[ 	]+addb? +\$0x0,%al
diff --git a/gas/testsuite/gas/i386/immed64.s b/gas/testsuite/gas/i386/immed64.s
index 265b41924e8..21c30ec4860 100644
--- a/gas/testsuite/gas/i386/immed64.s
+++ b/gas/testsuite/gas/i386/immed64.s
@@ -19,6 +19,12 @@ _start:
 	movabsq	$early, %rax
 	movabsq	$late, %rax
 	movabsq	$xtrn, %rax
+	pushq	$early
+	pushq	$late
+	pushw	$early
+	pushw	$late
+	push	$early
+	push	$late
 	addb	$early, %al
 	addb	$late, %al
 	addb	$xtrn, %al

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-27  8:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27  8:54 [binutils-gdb] x86-64: fix suffix-less PUSH of symbol address Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).