[PATCH] elf/x86-64: Subtract __ImageBase for R_AMD64_IMAGEBASE

H.J. Lu hjl.tools@gmail.com
Tue Feb 23 13:31:28 GMT 2021


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?

> 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.

> 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.


-- 
H.J.


More information about the Binutils mailing list