public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Jan Beulich <jbeulich@suse.com>, Binutils <binutils@sourceware.org>
Subject: Re: [PATCH v5] elf/x86-64: Subtract __ImageBase for R_AMD64_IMAGEBASE
Date: Sat, 6 Mar 2021 10:41:53 +1030	[thread overview]
Message-ID: <20210306001153.GF6042@bubble.grove.modra.org> (raw)
In-Reply-To: <CAMe9rOrK+cR_jJ6L7oKtbT16EKxrmhuxhGWPwDrkszTKWGPJzg@mail.gmail.com>

On Fri, Mar 05, 2021 at 10:26:35AM -0800, H.J. Lu wrote:
> On Fri, Mar 5, 2021 at 5:57 AM Alan Modra <amodra@gmail.com> wrote:
> > This doesn't look like the right place to set up a reference to
> > __executable_start.  Doing so in a new check_relocs in pei-x86_64.c
> > that tests for an ELF output would be better.  I'm not suggesting that
> > you run over relocs looking for R_AMD64_IMAGEBASE, that could be done
> > but seems unnecessary.
> 
> check_relocs is too late.  We need to do it in load_symbols ().  Otherwise,
> __executable_start won't be defined.  I added pex64_link_add_symbols to
> do it.

Ah, I was forgetting that check_relocs now runs much later.  Even so,
I would have thought that the PROVIDE would define the symbol?  The
question is academic, I'm happy with pex64_link_add_symbols.

> Here is the v5 patch.  OK for master?

OK with three further changes.
1) The R_AMD64_IMAGEBASE handling should to be inside the
   output_bfd == NULL block.  It is wrong to apply the image base
   adjustment to the section for relocatable linking.  Doing so would
   effectively change the reloc addend.
2) I worry about the abort, which I think you might hit if trying to
   link PE objects into a pie.  One possible fix would be to change
   the bfd_link_pde in pex64_link_add_symbols to !bfd_link_relocatable.
   That might just be sweeping a problem under the rug, so an
   alternative fix would be to remove the abort and instead return
   with bfd_reloc_dangerous.  Either fix is fine with me.
3) No need to check for bfd_target_elf_flavour in set_output_arch.

-- 
Alan Modra
Australia Development Lab, IBM

  reply	other threads:[~2021-03-06  0:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23 12:15 [PATCH] " H.J. Lu
2021-02-23 13:15 ` Jan Beulich
2021-02-23 13:31   ` H.J. Lu
2021-02-23 14:10     ` Jan Beulich
2021-02-23 14:47       ` H.J. Lu
2021-02-23 15:02         ` Jan Beulich
2021-02-23 15:07           ` H.J. Lu
2021-02-23 15:11             ` Jan Beulich
2021-02-23 17:50               ` [PATCH v2] " H.J. Lu
2021-02-25  2:09                 ` Alan Modra
2021-02-28  2:38                   ` [PATCH v3] " H.J. Lu
2021-03-01 12:19                     ` Alan Modra
2021-03-01 13:44                       ` H.J. Lu
2021-03-04 13:14                         ` Alan Modra
2021-03-04 13:54                           ` [PATCH v4] " H.J. Lu
2021-03-05  5:17                             ` Alan Modra
2021-03-05  5:29                               ` H.J. Lu
2021-03-05 13:57                                 ` Alan Modra
2021-03-05 18:26                                   ` [PATCH v5] " H.J. Lu
2021-03-06  0:11                                     ` Alan Modra [this message]
2021-03-06  1:00                                       ` [PATCH v6] " H.J. Lu
2021-03-07  4:16                                         ` Alan Modra

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=20210306001153.GF6042@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --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).