[PATCH v2] x86: Turn PLT32 to PC32 only for PC-relative relocations

H.J. Lu hjl.tools@gmail.com
Wed Sep 25 19:01:01 GMT 2024


On Mon, Sep 23, 2024 at 3:43 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Sep 23, 2024 at 1:55 AM Fangrui Song <i@maskray.me> wrote:
> >
> > On Sun, Sep 22, 2024 at 4:05 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > commit 292676c15a615b5a95bede9ee91004d3f7ee7dfd
> > > Author: H.J. Lu <hjl.tools@gmail.com>
> > > Date:   Thu Feb 13 13:44:17 2020 -0800
> > >
> > >     x86: Resolve PLT32 reloc aganst local symbol to section
> > >
> > > resolved PLT32 relocation against local symbol to section and
> > >
> > > commit 2585b7a5ce5830e60a089aa2316a329558902f0c
> > > Author: H.J. Lu <hjl.tools@gmail.com>
> > > Date:   Sun Jul 19 06:51:19 2020 -0700
> > >
> > >     x86: Change PLT32 reloc against section to PC32
> > >
> > > turned PLT32 relocation against section into PC32 relocation.  But these
> > > transformations are valid only for PC-relative relocations.  Add fx_pcrel
> > > check for PC-relative relocations when performing these transformations.
> > >
> > >
> > > --
> > > H.J.
> >
> > The code looks good to me.
> >
> > Perhaps mentioning that  `movq $foo@PLT, %rax` generates the wrong 32
> > instead of PLT32 makes it easier for readers to understand the
> > difference.
> >
> > The new file ld/testsuite/ld-x86-64/pr32196.s could be renamed to
> > plt<something>.s for better discoverability.
>
> Here is the v2 patch I am checking in.  Changes in v2:
>
> 1. Mention  `movq $foo@PLT, %rax` in the commit log.
> 2. Rename the linker test to plt3.s and call foo instead of loading the
> first 8 bytes in foo.
>
> Thanks.
>

I am backporting this to 2.43 branch.


-- 
H.J.


More information about the Binutils mailing list