[PATCH 4/8] bfd/ELF: fold BFD_RELOC_<arch>_GOTOFF*

Jens Remus jremus@linux.ibm.com
Fri Mar 13 16:10:43 GMT 2026


On 3/13/2026 10:54 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. Arm64, C-Sky, and
> KVX - sadly - continue to be exceptions.

Hello Jan, hopefully you don't mind my perhaps newbie question:

Isn't the removal of e.g. BFD_RELOC_390_GOTOFF64 breaking the existing
external BFD API?  At least all of these relocations are documented in
the BFD documentation:
https://sourceware.org/binutils/docs/bfd.html#index-BFD_005fRELOC_005f390_005fGOTOFF64

Technically the following s390 64-bit (s390x) changes look good to me.

> --- a/bfd/bfd-in2.h
> +++ b/bfd/bfd-in2.h
> @@ -3306,6 +3306,7 @@ enum bfd_reloc_code_real
>    BFD_RELOC_32_GOT_PCREL,
>    BFD_RELOC_16_GOT_PCREL,
>    BFD_RELOC_8_GOT_PCREL,
> +  BFD_RELOC_64_GOTOFF,
>    BFD_RELOC_32_GOTOFF,
>    BFD_RELOC_16_GOTOFF,
>    BFD_RELOC_LO16_GOTOFF,

> @@ -5427,9 +5412,6 @@ enum bfd_reloc_code_real
>    /* 32 bit rel. offset to GOT entry.  */
>    BFD_RELOC_390_GOTENT,
>  
> -  /* 64 bit offset to GOT.  */
> -  BFD_RELOC_390_GOTOFF64,
> -
>    /* 12-bit offset to symbol-entry within GOT, with PLT handling.  */
>    BFD_RELOC_390_GOTPLT12,
>  

> --- a/bfd/elf64-s390.c
> +++ b/bfd/elf64-s390.c
> @@ -263,7 +263,7 @@ elf_s390_reloc_type_lookup (bfd *abfd,
>        return &elf_howto_table[(int) R_390_GOTENT];
>      case BFD_RELOC_16_GOTOFF:
>        return &elf_howto_table[(int) R_390_GOTOFF16];
> -    case BFD_RELOC_390_GOTOFF64:
> +    case BFD_RELOC_64_GOTOFF:
>        return &elf_howto_table[(int) R_390_GOTOFF64];
>      case BFD_RELOC_390_GOTPLT12:
>        return &elf_howto_table[(int) R_390_GOTPLT12];

> --- a/bfd/libbfd.h
> +++ b/bfd/libbfd.h
> @@ -1081,6 +1081,7 @@ static const char *const bfd_reloc_code_
>    "BFD_RELOC_32_GOT_PCREL",
>    "BFD_RELOC_16_GOT_PCREL",
>    "BFD_RELOC_8_GOT_PCREL",
> +  "BFD_RELOC_64_GOTOFF",
>    "BFD_RELOC_32_GOTOFF",
>    "BFD_RELOC_16_GOTOFF",
>    "BFD_RELOC_LO16_GOTOFF",

> @@ -2409,7 +2394,6 @@ static const char *const bfd_reloc_code_
>    "BFD_RELOC_390_GOTPCDBL",
>    "BFD_RELOC_390_GOT64",
>    "BFD_RELOC_390_GOTENT",
> -  "BFD_RELOC_390_GOTOFF64",
>    "BFD_RELOC_390_GOTPLT12",
>    "BFD_RELOC_390_GOTPLT16",
>    "BFD_RELOC_390_GOTPLT32",

> --- a/bfd/reloc.c
> +++ b/bfd/reloc.c
> @@ -1435,6 +1435,8 @@ ENUMX
>  ENUMX
>    BFD_RELOC_8_GOT_PCREL
>  ENUMX
> +  BFD_RELOC_64_GOTOFF
> +ENUMX
>    BFD_RELOC_32_GOTOFF
>  ENUMX
>    BFD_RELOC_16_GOTOFF

> @@ -4989,10 +4959,6 @@ ENUM
>  ENUMDOC
>    32 bit rel. offset to GOT entry.
>  ENUM
> -  BFD_RELOC_390_GOTOFF64
> -ENUMDOC
> -  64 bit offset to GOT.
> -ENUM
>    BFD_RELOC_390_GOTPLT12
>  ENUMDOC
>    12-bit offset to symbol-entry within GOT, with PLT handling.

> --- a/gas/config/tc-s390.c
> +++ b/gas/config/tc-s390.c
> @@ -1294,7 +1294,7 @@ s390_elf_cons (int nbytes /* 1=.byte, 2=
>  		  BFD_RELOC_390_GOT64,		/* ELF_SUFFIX_GOT  */
>  		  BFD_RELOC_64_PLT_PCREL,	/* ELF_SUFFIX_PLT  */
>  		  BFD_RELOC_UNUSED,		/* ELF_SUFFIX_GOTENT  */
> -		  BFD_RELOC_390_GOTOFF64,	/* ELF_SUFFIX_GOTOFF  */
> +		  BFD_RELOC_64_GOTOFF,		/* ELF_SUFFIX_GOTOFF  */
>  		  BFD_RELOC_390_GOTPLT64,	/* ELF_SUFFIX_GOTPLT  */
>  		  BFD_RELOC_390_PLTOFF64,	/* ELF_SUFFIX_PLTOFF  */
>  		  BFD_RELOC_390_TLS_GD64,	/* ELF_SUFFIX_TLS_GD  */
> @@ -2383,7 +2383,7 @@ tc_s390_fix_adjustable (fixS *fixP)
>    /* adjust_reloc_syms doesn't know about the GOT.  */
>    if (   fixP->fx_r_type == BFD_RELOC_16_GOTOFF
>        || fixP->fx_r_type == BFD_RELOC_32_GOTOFF
> -      || fixP->fx_r_type == BFD_RELOC_390_GOTOFF64
> +      || fixP->fx_r_type == BFD_RELOC_64_GOTOFF
>        || fixP->fx_r_type == BFD_RELOC_390_PLTOFF16
>        || fixP->fx_r_type == BFD_RELOC_390_PLTOFF32
>        || fixP->fx_r_type == BFD_RELOC_390_PLTOFF64
> @@ -2445,7 +2445,7 @@ tc_s390_force_relocation (struct fix *fi
>      case BFD_RELOC_390_GOT20:
>      case BFD_RELOC_32_GOT_PCREL:
>      case BFD_RELOC_32_GOTOFF:
> -    case BFD_RELOC_390_GOTOFF64:
> +    case BFD_RELOC_64_GOTOFF:
>      case BFD_RELOC_390_PLTOFF16:
>      case BFD_RELOC_390_PLTOFF32:
>      case BFD_RELOC_390_PLTOFF64:
> @@ -2750,7 +2750,7 @@ md_apply_fix (fixS *fixP, valueT *valP,
>  	    md_number_to_chars (where, value, sizeof (int));
>  	  break;
>  
> -	case BFD_RELOC_390_GOTOFF64:
> +	case BFD_RELOC_64_GOTOFF:
>  	  if (fixP->fx_done)
>  	    md_number_to_chars (where, value, 8);
>  	  break;
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