From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Cc: "H.J. Lu" <hjl.tools@gmail.com>
Subject: [PATCH 2/2] x86-64: REX.W overrides DATA_PREFIX
Date: Fri, 22 Sep 2023 09:52:28 +0200 [thread overview]
Message-ID: <25b9c9f6-8762-5cff-39fa-8153a4d9c754@suse.com> (raw)
In-Reply-To: <e503162e-b4ce-8106-eb83-db781e100553@suse.com>
REX.W needs to be respected when immediate size and relocation type are
determined.
---
Looks like similar issues exist in displacement processing, but that'll
want to be dealt with separately.
--- 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, offs
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
prev parent reply other threads:[~2023-09-22 7:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-22 7:50 [PATCH 0/2] x86-64: immediate insn operand fixes Jan Beulich
2023-09-22 7:52 ` [PATCH 1/2] x86-64: fix suffix-less PUSH of symbol address Jan Beulich
2023-09-22 7:52 ` Jan Beulich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25b9c9f6-8762-5cff-39fa-8153a4d9c754@suse.com \
--to=jbeulich@suse.com \
--cc=binutils@sourceware.org \
--cc=hjl.tools@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).