public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: [PATCH] i386: Allow GOT32 relocations against ABS symbols
Date: Tue, 8 Feb 2022 05:20:35 -0800	[thread overview]
Message-ID: <CAMe9rOr=7FOB4MAZC3AzPwqKjRmg2d550pAhFyd4iLirNT09fw@mail.gmail.com> (raw)
In-Reply-To: <272c580b-7428-3cc6-9a21-e9aa802eeb90@suse.com>

On Tue, Feb 8, 2022 at 5:11 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 08.02.2022 14:02, H.J. Lu wrote:
> > On Tue, Feb 8, 2022 at 12:37 AM Jan Beulich <jbeulich@suse.com> wrote:
> >>
> >> On 08.02.2022 01:03, H.J. Lu via Binutils wrote:
> >>> GOT32 relocations are allowed since absolute value + addend is stored in
> >>> the GOT slot.
> >>
> >> Before permitting this and with you specifically mentioning addends
> >> here, I think it needs to be clarified what ...
> >>
> >>> --- /dev/null
> >>> +++ b/ld/testsuite/ld-i386/pr28870.s
> >>> @@ -0,0 +1,6 @@
> >>> +     .text
> >>> +     .globl _start
> >>> +_start:
> >>> +     addl    foo@GOT(%ebx), %eax
> >>> +     cmpl    $0, foo@GOT(%ebx)
> >>> +foo = 2
> >>
> >> ... missing (here) variants thereof actually mean (and whether the use
> >> of addends actually works as intended):
> >>
> >>         mov     $v@got+3, %eax                          # bogus, meaningless operand
> >>         mov     $(v+3)@got, %eax                        # wrong (gets treated same as above)
> >>
> >> Comments are my own, preliminary judgement.
> >
> > GOT relocations should only be used as @got or @got(%reg).
> > Other variants are undefined.
>
> Which raises two questions:
>
> 1) Why did you say "absolute value + addend is stored in the GOT slot" in
> the description? Where would an addend come from if it can't be specified
> in the assembly source?

addend came from GOTPCREL relocation.   There is no addend for
GOT32.

> 2) Why isn't the assembler at least warning about such undefined uses?

A warning is useful.

-- 
H.J.

      reply	other threads:[~2022-02-08 13:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08  0:03 H.J. Lu
2022-02-08  8:37 ` Jan Beulich
2022-02-08 13:02   ` H.J. Lu
2022-02-08 13:10     ` Jan Beulich
2022-02-08 13:20       ` H.J. Lu [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='CAMe9rOr=7FOB4MAZC3AzPwqKjRmg2d550pAhFyd4iLirNT09fw@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.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).