public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: [PATCH] x86: Update register operand check for AddrPrefixOpReg
Date: Fri, 2 Oct 2020 14:18:12 +0200	[thread overview]
Message-ID: <9a0a50db-cfdb-233c-b837-ab6c329f831a@suse.com> (raw)
In-Reply-To: <CAMe9rOrKS4n6GjPO4nrga0xncRTb43i9j+v7kXzmiCUmMi7wiA@mail.gmail.com>

On 02.10.2020 13:33, H.J. Lu wrote:
> On Thu, Oct 1, 2020 at 11:58 PM Jan Beulich <jbeulich@suse.com> wrote:
>> On 01.10.2020 17:08, H.J. Lu wrote:
>>> GNU assembler accommodates other usages.  But it must work with GCC.
>>
>> We agree on this. What you don't want to accept is that gcc also
>> needs to emit correct code for gas to consume.
>>
>>> In this case, it needs to check the register operand for the address size prefix
>>> when the memory operand is (%rip).
>>
>> And we again agree on the checking aspect. What we disagree on is
>> what to do if the check finds a discrepancy. Without your recent
>> change, the checking you talk about did already happen. And the
>> assembler correctly diagnosed it. The assembler may not _ever_
>> guess upon what the programmer meant, when finding an ambiguity
>> (exceptions to this rule may be warranted for backwards
>> compatibility in very rare cases, but this clearly doesn't apply
>> here). We've had this discussion before in different contexts,
>> and I have to admit I'm struggling with how you drive things in
>> this regard. If there was a way for gcc to indicate "I've done my
>> best, but please fix it up for me", I could accept there being
>> such a (non-default) mode. I wouldn't like it very much, but I
>> could live with it. But for hand-written code (be it entire .s
>> files or inline assembly) inconsistencies and ambiguities need to
>> be diagnosed by default.
>>
>> Note in particular that your change isn't even limited to x32
>> mode, where one _might_ view the adjustment as benign.
> 
> The address size prefix isn't limited to x32.   For RIP-relative
> addressing, GCC always uses (%rip).

But the issue at hand is limited to x32, and the conversion you're
doing is also only half-way safe for x32.

>  The assembler will never
> guess correctly what the assembly code is trying to do in all
> cases.

Hence it shouldn't guess. It should tell the programmer to change
the code so guessing isn't needed.

>  In this particular case, the assembler needs to look
> at the register operand to extract the address size prefix.

And how does it know _that's_ the part which is correct (as per
the programmer's intentions), and not the other operand?

Jan

  reply	other threads:[~2020-10-02 12:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-30 23:30 [PATCH] x86: Check register operand " H.J. Lu
2020-10-01  8:22 ` Jan Beulich
2020-10-01 11:35   ` H.J. Lu
2020-10-01 13:07     ` [PATCH] x86: Update register operand check " H.J. Lu
2020-10-01 13:23       ` Jan Beulich
2020-10-01 13:44         ` H.J. Lu
2020-10-01 14:57           ` Jan Beulich
2020-10-01 15:08             ` H.J. Lu
2020-10-02  6:58               ` Jan Beulich
2020-10-02 11:33                 ` H.J. Lu
2020-10-02 12:18                   ` Jan Beulich [this message]
2020-10-02 12:27                     ` H.J. Lu
2020-10-07 18:17                       ` H.J. Lu

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=9a0a50db-cfdb-233c-b837-ab6c329f831a@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).