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

Jan Beulich jbeulich@suse.com
Tue Feb 23 13:15:42 GMT 2021


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

> --- 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
table. I also wonder what the consequences are if a set of linked
object files specifies a symbol of this name.

Jan


More information about the Binutils mailing list