[PATCH 6/8] bfd/ELF: fold BFD_RELOC_<arch>_GOTPC*
Jens Remus
jremus@linux.ibm.com
Fri Mar 13 17:30:28 GMT 2026
On 3/13/2026 10:57 AM, Jan Beulich wrote:
> For many of the cases there's no need to have separate relocs per arch;
> just like for other more or less generic ones a single one (per purpose;
> a 64-bit generic one is being introduced) will do. C-Sky - sadly -
> continues to be an exception.
> ---
> Why is it that BFD_RELOC_386_GOTPC (but not BFD_RELOC_X86_64_GOTPC{32,64})
> is among the types checked in TC_FORCE_RELOCATION_LOCAL()? Without that,
> BFD_RELOC_X86_64_GOTPC32 type could also be replaced by
> BFD_RELOC_32_PLT_PCREL, then even simplifying at least one expression.
Likewise to previous patch I am wondering whether this isn't an API-
breaking change.
On s390 the R_390_GOTPC is either 32-bit or 64-bit. That probably needs
to be addressed. So either introduce a BFD_RELOC_64_GOT_PCREL (for s390)
or not make this change for s390 at all. Thoughts?
> --- a/bfd/bfd-in2.h
> +++ b/bfd/bfd-in2.h
> @@ -5377,9 +5372,6 @@ enum bfd_reloc_code_real
> /* 32 bit GOT offset. */
> BFD_RELOC_390_GOT32,
>
> - /* 32 bit PC relative offset to GOT. */
> - BFD_RELOC_390_GOTPC,
> -
> /* 16 bit GOT offset. */
> BFD_RELOC_390_GOT16,
>
> --- a/bfd/elf32-s390.c
> +++ b/bfd/elf32-s390.c
> @@ -213,7 +213,7 @@ elf_s390_reloc_type_lookup (bfd *abfd AT
> return &elf_howto_table[(int) R_390_RELATIVE];
> case BFD_RELOC_32_GOTOFF:
> return &elf_howto_table[(int) R_390_GOTOFF32];
> - case BFD_RELOC_390_GOTPC:
> + case BFD_RELOC_32_GOT_PCREL:
> return &elf_howto_table[(int) R_390_GOTPC];
On s390 32-bit the R_390_GOTPC is a 32-bit PC-relative relocation to the
GOT. So BFD_RELOC_32_GOT_PCREL (implying 32-bit) makes sense.
> case BFD_RELOC_390_GOT16:
> return &elf_howto_table[(int) R_390_GOT16];
> --- a/bfd/elf64-s390.c
> +++ b/bfd/elf64-s390.c
> @@ -227,7 +227,7 @@ elf_s390_reloc_type_lookup (bfd *abfd,
> return &elf_howto_table[(int) R_390_RELATIVE];
> case BFD_RELOC_32_GOTOFF:
> return &elf_howto_table[(int) R_390_GOTOFF32];
> - case BFD_RELOC_390_GOTPC:
> + case BFD_RELOC_32_GOT_PCREL:
> return &elf_howto_table[(int) R_390_GOTPC];
On s390 64-bit the R_390_GOTPC is a 64-bit PC-relative relocation to the
GOT. So BFD_RELOC_32_GOT_PCREL (implying 32-bit) makes not sense.
case BFD_RELOC_64_GOT_PCREL:
return &elf_howto_table[(int) R_390_GOTPC];
> case BFD_RELOC_390_GOT16:
> return &elf_howto_table[(int) R_390_GOT16];
> --- a/bfd/libbfd.h
> +++ b/bfd/libbfd.h
> @@ -2383,7 +2378,6 @@ static const char *const bfd_reloc_code_
> "BFD_RELOC_390_12",
> "BFD_RELOC_390_GOT12",
> "BFD_RELOC_390_GOT32",
> - "BFD_RELOC_390_GOTPC",
> "BFD_RELOC_390_GOT16",
> "BFD_RELOC_390_PC12DBL",
> "BFD_RELOC_390_PLT12DBL",
> --- a/bfd/reloc.c
> +++ b/bfd/reloc.c
ENUM
BFD_RELOC_64_GOT_PCREL
> @@ -4913,10 +4903,6 @@ ENUM
> ENUMDOC
> 32 bit GOT offset.
> ENUM
> - BFD_RELOC_390_GOTPC
> -ENUMDOC
> - 32 bit PC relative offset to GOT.
> -ENUM
> BFD_RELOC_390_GOT16
> ENUMDOC
> 16 bit GOT offset.
> --- a/gas/config/tc-s390.c
> +++ b/gas/config/tc-s390.c
> @@ -2449,7 +2449,7 @@ tc_s390_force_relocation (struct fix *fi
> case BFD_RELOC_390_PLTOFF16:
> case BFD_RELOC_390_PLTOFF32:
> case BFD_RELOC_390_PLTOFF64:
> - case BFD_RELOC_390_GOTPC:
> + case BFD_RELOC_32_GOT_PCREL:
case BFD_RELOC_32_GOT_PCREL:
case BFD_RELOC_64_GOT_PCREL:
> case BFD_RELOC_390_GOT16:
> case BFD_RELOC_390_GOTPCDBL:
> case BFD_RELOC_390_GOT64:
> @@ -2840,7 +2840,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UN
> {
> if ( (s390_arch_size == 32 && code == BFD_RELOC_32_PCREL)
> || (s390_arch_size == 64 && code == BFD_RELOC_64_PCREL))
> - code = BFD_RELOC_390_GOTPC;
> + code = BFD_RELOC_32_GOT_PCREL;
if (s390_arch_size == 32 && code == BFD_RELOC_32_PCREL)
code = BFD_RELOC_32_GOT_PCREL;
else if (s390_arch_size == 64 && code == BFD_RELOC_64_PCREL)
code = BFD_RELOC_64_GOT_PCREL;
else if (code == BFD_RELOC_390_PC32DBL)
code = BFD_RELOC_390_GOTPCDBL;
> if (code == BFD_RELOC_390_PC32DBL)
> code = BFD_RELOC_390_GOTPCDBL;
> }
Thanks and regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
jremus@de.ibm.com / jremus@linux.ibm.com
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Ehningen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
More information about the Binutils
mailing list