[PATCH v2 2/6] bfd/s390+sh: don't abuse BFD_RELOC_32_GOT_PCREL
Jens Remus
jremus@linux.ibm.com
Mon Mar 30 16:11:11 GMT 2026
On 3/27/2026 10:52 AM, Jan Beulich wrote:
> Neither R_390_GOT32 nor R_SH_GOT32 are PC-relative relocations, so don't
> use a generic PC-relative enumerator for them. Doing so gets in the way
> of properly using that enumerator.
Thank you, Jan! The s390 64-bit (s390x) changes look good to me.
> ---
> v2: Move BFD_RELOC_390_GOT32 down a little.
Thanks!
> --- a/bfd/bfd-in2.h
> +++ b/bfd/bfd-in2.h
> @@ -5379,6 +5380,9 @@ enum bfd_reloc_code_real
> /* 16 bit GOT offset. */
> BFD_RELOC_390_GOT16,
>
> + /* 32 bit GOT offset. */
> + BFD_RELOC_390_GOT32,
> +
> /* PC relative 12 bit shifted by 1. */
> BFD_RELOC_390_PC12DBL,
>
> --- a/bfd/elf32-s390.c
> +++ b/bfd/elf32-s390.c
> @@ -199,7 +199,7 @@ elf_s390_reloc_type_lookup (bfd *abfd AT
> return &elf_howto_table[(int) R_390_PC32];
> case BFD_RELOC_390_GOT12:
> return &elf_howto_table[(int) R_390_GOT12];
> - case BFD_RELOC_32_GOT_PCREL:
> + case BFD_RELOC_390_GOT32:
> return &elf_howto_table[(int) R_390_GOT32];
> case BFD_RELOC_32_PLT_PCREL:
> return &elf_howto_table[(int) R_390_PLT32];
> --- a/bfd/elf64-s390.c
> +++ b/bfd/elf64-s390.c
> @@ -213,7 +213,7 @@ elf_s390_reloc_type_lookup (bfd *abfd,
> return &elf_howto_table[(int) R_390_PC32];
> case BFD_RELOC_390_GOT12:
> return &elf_howto_table[(int) R_390_GOT12];
> - case BFD_RELOC_32_GOT_PCREL:
> + case BFD_RELOC_390_GOT32:
> return &elf_howto_table[(int) R_390_GOT32];
> case BFD_RELOC_32_PLT_PCREL:
> return &elf_howto_table[(int) R_390_PLT32];
> --- a/bfd/libbfd.h
> +++ b/bfd/libbfd.h
> @@ -2383,6 +2384,7 @@ static const char *const bfd_reloc_code_
> "BFD_RELOC_390_GOT12",
> "BFD_RELOC_390_GOTPC",
> "BFD_RELOC_390_GOT16",
> + "BFD_RELOC_390_GOT32",
> "BFD_RELOC_390_PC12DBL",
> "BFD_RELOC_390_PLT12DBL",
> "BFD_RELOC_390_PC16DBL",
> --- a/bfd/reloc.c
> +++ b/bfd/reloc.c
> @@ -4915,6 +4917,10 @@ ENUM
> ENUMDOC
> 16 bit GOT offset.
> ENUM
> + BFD_RELOC_390_GOT32
> +ENUMDOC
> + 32 bit GOT offset.
> +ENUM
> BFD_RELOC_390_PC12DBL
> ENUMDOC
> PC relative 12 bit shifted by 1.
> --- a/gas/config/tc-s390.c
> +++ b/gas/config/tc-s390.c
> @@ -1107,7 +1107,7 @@ s390_lit_suffix (char **str_p, expressio
> if (nbytes == 2)
> reloc = BFD_RELOC_390_GOT16;
> else if (nbytes == 4)
> - reloc = BFD_RELOC_32_GOT_PCREL;
> + reloc = BFD_RELOC_390_GOT32;
> else if (nbytes == 8)
> reloc = BFD_RELOC_390_GOT64;
> }
> @@ -1271,7 +1271,7 @@ s390_elf_cons (int nbytes /* 1=.byte, 2=
> static bfd_reloc_code_real_type tab4[] =
> {
> BFD_RELOC_UNUSED, /* ELF_SUFFIX_NONE */
> - BFD_RELOC_32_GOT_PCREL, /* ELF_SUFFIX_GOT */
> + BFD_RELOC_390_GOT32, /* ELF_SUFFIX_GOT */
> BFD_RELOC_32_PLT_PCREL, /* ELF_SUFFIX_PLT */
> BFD_RELOC_UNUSED, /* ELF_SUFFIX_GOTENT */
> BFD_RELOC_32_GOTOFF, /* ELF_SUFFIX_GOTOFF */
> @@ -2396,7 +2396,7 @@ tc_s390_fix_adjustable (fixS *fixP)
> || fixP->fx_r_type == BFD_RELOC_390_GOT12
> || fixP->fx_r_type == BFD_RELOC_390_GOT20
> || fixP->fx_r_type == BFD_RELOC_390_GOT16
> - || fixP->fx_r_type == BFD_RELOC_32_GOT_PCREL
> + || fixP->fx_r_type == BFD_RELOC_390_GOT32
> || fixP->fx_r_type == BFD_RELOC_390_GOT64
> || fixP->fx_r_type == BFD_RELOC_390_GOTENT
> || fixP->fx_r_type == BFD_RELOC_390_GOTPLT12
> @@ -2443,7 +2443,7 @@ tc_s390_force_relocation (struct fix *fi
> {
> case BFD_RELOC_390_GOT12:
> case BFD_RELOC_390_GOT20:
> - case BFD_RELOC_32_GOT_PCREL:
> + case BFD_RELOC_390_GOT32:
> case BFD_RELOC_32_GOTOFF:
> case BFD_RELOC_64_GOTOFF:
> case BFD_RELOC_390_PLTOFF16:
> @@ -2728,7 +2728,7 @@ md_apply_fix (fixS *fixP, valueT *valP,
> if (fixP->fx_done)
> md_number_to_chars (where, value, 4);
> break;
> - case BFD_RELOC_32_GOT_PCREL:
> + case BFD_RELOC_390_GOT32:
> case BFD_RELOC_390_PLTOFF32:
> case BFD_RELOC_32_PLT_PCREL:
> case BFD_RELOC_390_GOTPLT32:
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