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] elf/x86-64: Subtract __ImageBase for R_AMD64_IMAGEBASE
Date: Tue, 23 Feb 2021 06:47:49 -0800	[thread overview]
Message-ID: <CAMe9rOoaAYdS6d-aT_a-4muNq7n3pOsmMgv54Yv9gmae9K4m1Q@mail.gmail.com> (raw)
In-Reply-To: <7e855896-7a78-2b57-2b98-b5ced44915b1@suse.com>

On Tue, Feb 23, 2021 at 6:10 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 23.02.2021 14:31, H.J. Lu wrote:
> > On Tue, Feb 23, 2021 at 5:15 AM Jan Beulich <jbeulich@suse.com> wrote:
> >>
> >> On 23.02.2021 13:15, H.J. Lu via Binutils wrote:
> >>> When linking PE/x86-64 inputs to generate ELF executable, we need to
> >>> subtract __ImageBase, aka __executable_start, for R_AMD64_IMAGEBASE
> >>> relocation.
> >>
> >> Do you really mean PE/x86-64, not the respective COFF objects? In the
> >
> > What is the difference?  How should I call object files generated by
> > Microsoft Visual Studio?
>
> The call them COFF themselves, I believe.

I have an impression that Windows relocations are different from regular
COFF relocations.  coff-x86_64.c has COFF_WITH_PE in many places.
My patch is only for Windows/PE:

&& strcmp (abfd->xvec->name, "pe-x86-64") == 0

> >> description this may not matter much, but since there's at least one
> >> code comment also saying so, which may confuse readers, I'd like to
> >> understand this.
> >>
> >> Also, in how far is this x86-64-specific?
> >
> > I don't know.
> >
> >>> --- a/ld/testsuite/ld-x86-64/pe-x86-64-1.od
> >>> +++ b/ld/testsuite/ld-x86-64/pe-x86-64-1.od
> >>> @@ -2,6 +2,7 @@
> >>>  .*: +file format .*
> >>>
> >>>  SYMBOL TABLE:
> >>> +0+400000 g       .text\$mn   0000000000000000 __executable_start
> >>>  0+401000 g       .text\$mn   0000000000000000 getaddr1
> >>>  0+401020 g       .text\$mn   0000000000000000 begin
> >>>  0+403014 g       .bss        0000000000000000 __bss_start
> >>
> >> I don't think this artifical symbol should appear in the symbol
> >
> > This symbol is generated by linker.  It should be harmless.
>
> According to my experience, stray symbols can be confusing or worse.

__executable_start is well defined by linker.

> >> table. I also wonder what the consequences are if a set of linked
> >> object files specifies a symbol of this name.
> >
> > __executable_start is generated by linker.  If __ImageBase is
> > defined to another value, that value will be used as image base.
>
> So if I have an object defining __executable_start, which of the
> two will relocations be resolved against?
>

Your __executable_start will be used.

-- 
H.J.

  reply	other threads:[~2021-02-23 14:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23 12:15 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 [this message]
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
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=CAMe9rOoaAYdS6d-aT_a-4muNq7n3pOsmMgv54Yv9gmae9K4m1Q@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).