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

Fangrui Song i@maskray.me
Sun Sep 22 17:48:03 GMT 2024


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.


More information about the Binutils mailing list