public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] x86-64: REX.W overrides DATA_PREFIX
@ 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=f79d55e124fb0b0c41ebc0ca679370170c964659

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

    x86-64: REX.W overrides DATA_PREFIX
    
    REX.W needs to be respected when immediate size and relocation type are
    determined.

Diff:
---
 gas/config/tc-i386.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 2e3154cb59f..aec4f211faa 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -6212,7 +6212,8 @@ optimize_imm (void)
 	    break;
 	  }
     }
-  else if ((flag_code == CODE_16BIT) ^ (i.prefix[DATA_PREFIX] != 0))
+  else if ((flag_code == CODE_16BIT)
+	    ^ (i.prefix[DATA_PREFIX] != 0 && !(i.prefix[REX_PREFIX] & REX_W)))
     guess_suffix = WORD_MNEM_SUFFIX;
   else if (flag_code != CODE_64BIT
 	   || (!(i.prefix[REX_PREFIX] & REX_W)
@@ -8186,7 +8187,8 @@ update_imm (unsigned int j)
 	       || operand_type_equal (&overlap, &imm16_32)
 	       || operand_type_equal (&overlap, &imm16_32s))
 	{
-	  if ((flag_code == CODE_16BIT) ^ (i.prefix[DATA_PREFIX] != 0))
+	  if ((flag_code == CODE_16BIT)
+	      ^ (i.prefix[DATA_PREFIX] != 0 && !(i.prefix[REX_PREFIX] & REX_W)))
 	    overlap = imm16;
 	  else
 	    overlap = imm32s;
@@ -10426,6 +10428,7 @@ output_imm (fragS *insn_start_frag, offsetT insn_start_off)
 	      if (i.types[n].bitfield.imm32s
 		  && (i.suffix == QWORD_MNEM_SUFFIX
 		      || (!i.suffix && i.tm.opcode_modifier.no_lsuf)
+		      || (i.prefix[REX_PREFIX] & REX_W)
 		      || dot_insn ()))
 		sign = 1;
 	      else

^ 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: REX.W overrides DATA_PREFIX 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).