On Tue, Nov 5, 2024 at 4:58 PM Brian Gerst <brgerst@gmail.com> wrote:
>
> Clang may produce R_X86_64_REX_GOTPCRELX relocations when redefining the
> stack protector location. Treat them as another type of PC-relative
> relocation.
>
> Signed-off-by: Brian Gerst <brgerst@gmail.com>
> ---
> arch/x86/tools/relocs.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
> index 6afe2e5e9102..7d7fc7f0a250 100644
> --- a/arch/x86/tools/relocs.c
> +++ b/arch/x86/tools/relocs.c
> @@ -32,6 +32,11 @@ static struct relocs relocs32;
> static struct relocs relocs32neg;
> static struct relocs relocs64;
> # define FMT PRIu64
> +
> +#ifndef R_X86_64_REX_GOTPCRELX
> +#define R_X86_64_REX_GOTPCRELX 42
> +#endif
The next patch (7/16) introduces the above definition to
arch/x86/include/asm/elf.h. If you swap patches 6 and 7 in the series,
you won't have to introduce the above conditional definition.
Uros.
> +
> #else
> # define FMT PRIu32
> #endif
> @@ -226,6 +231,7 @@ static const char *rel_type(unsigned type)
> REL_TYPE(R_X86_64_PC16),
> REL_TYPE(R_X86_64_8),
> REL_TYPE(R_X86_64_PC8),
> + REL_TYPE(R_X86_64_REX_GOTPCRELX),
> #else
> REL_TYPE(R_386_NONE),
> REL_TYPE(R_386_32),
> @@ -860,6 +866,7 @@ static int do_reloc64(struct section *sec, Elf_Rel *rel, ElfW(Sym) *sym,
>
> case R_X86_64_PC32:
> case R_X86_64_PLT32:
> + case R_X86_64_REX_GOTPCRELX:
> /*
> * PC relative relocations don't need to be adjusted unless
> * referencing a percpu symbol.
> --
> 2.47.0
>