[PATCH] elf/x86-64: Subtract __ImageBase for R_AMD64_IMAGEBASE
Jan Beulich
jbeulich@suse.com
Tue Feb 23 14:10:13 GMT 2021
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.
>> 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.
>> 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?
Jan
More information about the Binutils
mailing list