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

H.J. Lu hjl.tools@gmail.com
Tue Feb 23 17:50:20 GMT 2021


On Tue, Feb 23, 2021 at 7:11 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 23.02.2021 16:07, H.J. Lu wrote:
> > On Tue, Feb 23, 2021 at 7:02 AM Jan Beulich <jbeulich@suse.com> wrote:
> >>
> >> On 23.02.2021 15:47, H.J. Lu wrote:
> >>> 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.
> >>
> >> Right - there are differences.
> >>
> >>> My patch is only for Windows/PE:
> >>>
> >>> && strcmp (abfd->xvec->name, "pe-x86-64") == 0
> >>
> >> That's (imo) bfd-internal naming that's not helpful to understand what
> >> it really is that talk is about. Comments would hence likely benefit
> >> from naming things like they are called commonly.
> >
> > Will "Windows x86-64 relocatable inputs" be better?
>
> I think so, yes. Of course I continue to be puzzled by the x86-64
> special casing here. The concept of image base and image base
> relative relocations is architecture independent afaik.

If there is such a testcase, we can update it.

> Jan

Here is the updated patch.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-elf-x86-64-Subtract-__ImageBase-for-R_AMD64_IMAGE.patch
Type: text/x-patch
Size: 21028 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20210223/c703d037/attachment-0001.bin>


More information about the Binutils mailing list