[v2,3/6] bfd/ELF: fold BFD_RELOC_<arch>_GOTPC*

Message ID 42c253d7-9c0c-4945-8da8-b5e45da39be0@suse.com
State New
Headers
Series bfd: another little bit of reloc enum cleanup |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Jan Beulich March 27, 2026, 9:55 a.m. UTC
  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.
---
v2: Re-base over changes earlier in the series. Introduce
    BFD_RELOC_64_GOT_PCREL to correct the S/390 change (and then used
    for x86-64 as well).
  

Comments

Jens Remus March 30, 2026, 4:13 p.m. UTC | #1
On 3/27/2026 10:55 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.

Thank you, Jan!  The s390 64-bit (s390x) changes look good to me.

> ---
> v2: Re-base over changes earlier in the series. Introduce
>     BFD_RELOC_64_GOT_PCREL to correct the S/390 change (and then used
>     for x86-64 as well).

Thanks!

> --- a/bfd/bfd-in2.h
> +++ b/bfd/bfd-in2.h
> @@ -3303,6 +3303,7 @@ enum bfd_reloc_code_real
>    BFD_RELOC_16_SECIDX,
>  
>    /* For ELF.  */
> +  BFD_RELOC_64_GOT_PCREL,
>    BFD_RELOC_32_GOT_PCREL,
>    BFD_RELOC_16_GOT_PCREL,
>    BFD_RELOC_8_GOT_PCREL,

> @@ -5374,9 +5369,6 @@ enum bfd_reloc_code_real
>    /* 12 bit GOT offset.  */
>    BFD_RELOC_390_GOT12,
>  
> -  /* 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];
>      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_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
> @@ -1078,6 +1078,7 @@ static const char *const bfd_reloc_code_
>    "BFD_RELOC_8_PCREL",
>    "BFD_RELOC_32_SECREL",
>    "BFD_RELOC_16_SECIDX",
> +  "BFD_RELOC_64_GOT_PCREL",
>    "BFD_RELOC_32_GOT_PCREL",
>    "BFD_RELOC_16_GOT_PCREL",
>    "BFD_RELOC_8_GOT_PCREL",

> @@ -2382,7 +2377,6 @@ static const char *const bfd_reloc_code_
>    "BFD_RELOC_RX_RELAX",
>    "BFD_RELOC_390_12",
>    "BFD_RELOC_390_GOT12",
> -  "BFD_RELOC_390_GOTPC",
>    "BFD_RELOC_390_GOT16",
>    "BFD_RELOC_390_GOT32",
>    "BFD_RELOC_390_PC12DBL",

> --- a/bfd/reloc.c
> +++ b/bfd/reloc.c
> @@ -1429,6 +1429,8 @@ ENUMDOC
>    Section relative relocations.  Some targets need this for DWARF2.
>  
>  ENUM
> +  BFD_RELOC_64_GOT_PCREL
> +ENUMX
>    BFD_RELOC_32_GOT_PCREL
>  ENUMX
>    BFD_RELOC_16_GOT_PCREL

> @@ -4909,10 +4899,6 @@ ENUM
>  ENUMDOC
>    12 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,8 @@ 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_64_GOT_PCREL:
>      case BFD_RELOC_390_GOT16:
>      case BFD_RELOC_390_GOTPCDBL:
>      case BFD_RELOC_390_GOT64:
> @@ -2838,10 +2839,11 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UN
>    code = fixp->fx_r_type;
>    if (GOT_symbol && fixp->fx_addsy == GOT_symbol)
>      {
> -      if (   (s390_arch_size == 32 && code == BFD_RELOC_32_PCREL)
> -	  || (s390_arch_size == 64 && code == BFD_RELOC_64_PCREL))
> -	code = BFD_RELOC_390_GOTPC;
> -      if (code == BFD_RELOC_390_PC32DBL)
> +      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;
>      }
>  
Regards,
Jens
  

Patch

--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -3303,6 +3303,7 @@  enum bfd_reloc_code_real
   BFD_RELOC_16_SECIDX,
 
   /* For ELF.  */
+  BFD_RELOC_64_GOT_PCREL,
   BFD_RELOC_32_GOT_PCREL,
   BFD_RELOC_16_GOT_PCREL,
   BFD_RELOC_8_GOT_PCREL,
@@ -3816,7 +3817,6 @@  enum bfd_reloc_code_real
   /* i386/elf relocations.  */
   BFD_RELOC_386_GOT32,
   BFD_RELOC_386_PLT32,
-  BFD_RELOC_386_GOTPC,
   BFD_RELOC_386_TLS_TPOFF,
   BFD_RELOC_386_TLS_IE,
   BFD_RELOC_386_TLS_GOTIE,
@@ -3849,7 +3849,6 @@  enum bfd_reloc_code_real
   BFD_RELOC_X86_64_GOTPC32,
   BFD_RELOC_X86_64_GOT64,
   BFD_RELOC_X86_64_GOTPCREL64,
-  BFD_RELOC_X86_64_GOTPC64,
   BFD_RELOC_X86_64_GOTPLT64,
   BFD_RELOC_X86_64_GOTPC32_TLSDESC,
   BFD_RELOC_X86_64_TLSDESC_CALL,
@@ -4162,7 +4161,6 @@  enum bfd_reloc_code_real
 
   /* Relocations for setting up GOTs and PLTs for shared libraries.  */
   BFD_RELOC_ARM_GOT32,
-  BFD_RELOC_ARM_GOTPC,
   BFD_RELOC_ARM_GOT_PREL,
 
   /* ARM thread-local storage relocations.  */
@@ -4279,7 +4277,6 @@  enum bfd_reloc_code_real
   BFD_RELOC_SH_LABEL,
   BFD_RELOC_SH_LOOP_START,
   BFD_RELOC_SH_LOOP_END,
-  BFD_RELOC_SH_GOTPC,
   BFD_RELOC_SH_COPY64,
   BFD_RELOC_SH_GLOB_DAT64,
   BFD_RELOC_SH_JMP_SLOT64,
@@ -4348,7 +4345,6 @@  enum bfd_reloc_code_real
   BFD_RELOC_ARC_SDA16_ST2,
   BFD_RELOC_ARC_32_PCREL,
   BFD_RELOC_ARC_GOT32,
-  BFD_RELOC_ARC_GOTPC32,
   BFD_RELOC_ARC_GOTPC,
   BFD_RELOC_ARC_S21W_PCREL_PLT,
   BFD_RELOC_ARC_S25H_PCREL_PLT,
@@ -4905,7 +4901,6 @@  enum bfd_reloc_code_real
   BFD_RELOC_V850_CALLT_15_16_OFFSET,
 
   /* DSO relocations.  */
-  BFD_RELOC_V850_32_GOTPCREL,
   BFD_RELOC_V850_16_GOT,
   BFD_RELOC_V850_32_GOT,
   BFD_RELOC_V850_22_PLT_PCREL,
@@ -5374,9 +5369,6 @@  enum bfd_reloc_code_real
   /* 12 bit GOT offset.  */
   BFD_RELOC_390_GOT12,
 
-  /* 32 bit PC relative offset to GOT.  */
-  BFD_RELOC_390_GOTPC,
-
   /* 16 bit GOT offset.  */
   BFD_RELOC_390_GOT16,
 
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -386,6 +386,7 @@  arc_elf_link_hash_table_create (bfd *abf
 #define BFD_RELOC_ARC_PC32	BFD_RELOC_32_PCREL
 #define BFD_RELOC_ARC_PLT32	BFD_RELOC_32_PLT_PCREL
 #define BFD_RELOC_ARC_GOTOFF	BFD_RELOC_32_GOTOFF
+#define BFD_RELOC_ARC_GOTPC32	BFD_RELOC_32_GOT_PCREL
 #define BFD_RELOC_ARC_COPY	BFD_RELOC_COPY
 #define BFD_RELOC_ARC_GLOB_DAT	BFD_RELOC_GLOB_DAT
 #define BFD_RELOC_ARC_JMP_SLOT	BFD_RELOC_JMP_SLOT
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2020,7 +2020,7 @@  static const struct elf32_arm_reloc_map
     {BFD_RELOC_JMP_SLOT,	     R_ARM_JUMP_SLOT},
     {BFD_RELOC_RELATIVE,	     R_ARM_RELATIVE},
     {BFD_RELOC_32_GOTOFF,	     R_ARM_GOTOFF32},
-    {BFD_RELOC_ARM_GOTPC,	     R_ARM_GOTPC},
+    {BFD_RELOC_32_GOT_PCREL,	     R_ARM_GOTPC},
     {BFD_RELOC_ARM_GOT_PREL,	     R_ARM_GOT_PREL},
     {BFD_RELOC_ARM_GOT32,	     R_ARM_GOT32},
     {BFD_RELOC_32_PLT_PCREL,	     R_ARM_PLT32},
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -237,7 +237,7 @@  elf_i386_reloc_type_lookup (bfd *abfd,
       TRACE ("BFD_RELOC_32_GOTOFF");
       return &elf_howto_table[R_386_GOTOFF];
 
-    case BFD_RELOC_386_GOTPC:
+    case BFD_RELOC_32_GOT_PCREL:
       TRACE ("BFD_RELOC_386_GOTPC");
       return &elf_howto_table[R_386_GOTPC];
 
--- 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];
     case BFD_RELOC_390_GOT16:
       return &elf_howto_table[(int) R_390_GOT16];
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -360,7 +360,7 @@  static const struct elf_reloc_map sh_rel
   { BFD_RELOC_JMP_SLOT, R_SH_JMP_SLOT },
   { BFD_RELOC_RELATIVE, R_SH_RELATIVE },
   { BFD_RELOC_32_GOTOFF, R_SH_GOTOFF },
-  { BFD_RELOC_SH_GOTPC, R_SH_GOTPC },
+  { BFD_RELOC_32_GOT_PCREL, R_SH_GOTPC },
   { BFD_RELOC_SH_GOTPLT32, R_SH_GOTPLT32 },
   { BFD_RELOC_SH_GOT20, R_SH_GOT20 },
   { BFD_RELOC_SH_GOTOFF20, R_SH_GOTOFF20 },
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -1731,7 +1731,7 @@  static const struct v850_elf_reloc_map v
   { BFD_RELOC_V850_16_S1,		   R_V850_16_S1			 },
   { BFD_RELOC_V850_LO16_S1,		   R_V850_LO16_S1		 },
   { BFD_RELOC_V850_CALLT_15_16_OFFSET,	   R_V850_CALLT_15_16_OFFSET	 },
-  { BFD_RELOC_V850_32_GOTPCREL,		   R_V850_32_GOTPCREL		 },
+  { BFD_RELOC_32_GOT_PCREL,		   R_V850_32_GOTPCREL		 },
   { BFD_RELOC_V850_16_GOT,		   R_V850_16_GOT		 },
   { BFD_RELOC_V850_32_GOT,		   R_V850_32_GOT		 },
   { BFD_RELOC_V850_22_PLT_PCREL,	   R_V850_22_PLT		 },
--- 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_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
@@ -1078,6 +1078,7 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_8_PCREL",
   "BFD_RELOC_32_SECREL",
   "BFD_RELOC_16_SECIDX",
+  "BFD_RELOC_64_GOT_PCREL",
   "BFD_RELOC_32_GOT_PCREL",
   "BFD_RELOC_16_GOT_PCREL",
   "BFD_RELOC_8_GOT_PCREL",
@@ -1407,7 +1408,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_MN10300_TLS_TPOFF",
   "BFD_RELOC_386_GOT32",
   "BFD_RELOC_386_PLT32",
-  "BFD_RELOC_386_GOTPC",
   "BFD_RELOC_386_TLS_TPOFF",
   "BFD_RELOC_386_TLS_IE",
   "BFD_RELOC_386_TLS_GOTIE",
@@ -1438,7 +1438,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_X86_64_GOTPC32",
   "BFD_RELOC_X86_64_GOT64",
   "BFD_RELOC_X86_64_GOTPCREL64",
-  "BFD_RELOC_X86_64_GOTPC64",
   "BFD_RELOC_X86_64_GOTPLT64",
   "BFD_RELOC_X86_64_GOTPC32_TLSDESC",
   "BFD_RELOC_X86_64_TLSDESC_CALL",
@@ -1680,7 +1679,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_ARM_TLS_LDM32_FDPIC",
   "BFD_RELOC_ARM_TLS_IE32_FDPIC",
   "BFD_RELOC_ARM_GOT32",
-  "BFD_RELOC_ARM_GOTPC",
   "BFD_RELOC_ARM_GOT_PREL",
   "BFD_RELOC_ARM_TLS_GD32",
   "BFD_RELOC_ARM_TLS_LDO32",
@@ -1784,7 +1782,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_SH_LABEL",
   "BFD_RELOC_SH_LOOP_START",
   "BFD_RELOC_SH_LOOP_END",
-  "BFD_RELOC_SH_GOTPC",
   "BFD_RELOC_SH_COPY64",
   "BFD_RELOC_SH_GLOB_DAT64",
   "BFD_RELOC_SH_JMP_SLOT64",
@@ -1851,7 +1848,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_ARC_SDA16_ST2",
   "BFD_RELOC_ARC_32_PCREL",
   "BFD_RELOC_ARC_GOT32",
-  "BFD_RELOC_ARC_GOTPC32",
   "BFD_RELOC_ARC_GOTPC",
   "BFD_RELOC_ARC_S21W_PCREL_PLT",
   "BFD_RELOC_ARC_S25H_PCREL_PLT",
@@ -2110,7 +2106,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_V850_16_S1",
   "BFD_RELOC_V850_LO16_S1",
   "BFD_RELOC_V850_CALLT_15_16_OFFSET",
-  "BFD_RELOC_V850_32_GOTPCREL",
   "BFD_RELOC_V850_16_GOT",
   "BFD_RELOC_V850_32_GOT",
   "BFD_RELOC_V850_22_PLT_PCREL",
@@ -2382,7 +2377,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_RX_RELAX",
   "BFD_RELOC_390_12",
   "BFD_RELOC_390_GOT12",
-  "BFD_RELOC_390_GOTPC",
   "BFD_RELOC_390_GOT16",
   "BFD_RELOC_390_GOT32",
   "BFD_RELOC_390_PC12DBL",
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -1429,6 +1429,8 @@  ENUMDOC
   Section relative relocations.  Some targets need this for DWARF2.
 
 ENUM
+  BFD_RELOC_64_GOT_PCREL
+ENUMX
   BFD_RELOC_32_GOT_PCREL
 ENUMX
   BFD_RELOC_16_GOT_PCREL
@@ -2320,8 +2322,6 @@  ENUM
 ENUMX
   BFD_RELOC_386_PLT32
 ENUMX
-  BFD_RELOC_386_GOTPC
-ENUMX
   BFD_RELOC_386_TLS_TPOFF
 ENUMX
   BFD_RELOC_386_TLS_IE
@@ -2385,8 +2385,6 @@  ENUMX
 ENUMX
   BFD_RELOC_X86_64_GOTPCREL64
 ENUMX
-  BFD_RELOC_X86_64_GOTPC64
-ENUMX
   BFD_RELOC_X86_64_GOTPLT64
 ENUMX
   BFD_RELOC_X86_64_GOTPC32_TLSDESC
@@ -2959,8 +2957,6 @@  ENUMDOC
 ENUM
   BFD_RELOC_ARM_GOT32
 ENUMX
-  BFD_RELOC_ARM_GOTPC
-ENUMX
   BFD_RELOC_ARM_GOT_PREL
 ENUMDOC
   Relocations for setting up GOTs and PLTs for shared libraries.
@@ -3186,8 +3182,6 @@  ENUMX
 ENUMX
   BFD_RELOC_SH_LOOP_END
 ENUMX
-  BFD_RELOC_SH_GOTPC
-ENUMX
   BFD_RELOC_SH_COPY64
 ENUMX
   BFD_RELOC_SH_GLOB_DAT64
@@ -3323,8 +3317,6 @@  ENUMX
 ENUMX
   BFD_RELOC_ARC_GOT32
 ENUMX
-  BFD_RELOC_ARC_GOTPC32
-ENUMX
   BFD_RELOC_ARC_GOTPC
 ENUMX
   BFD_RELOC_ARC_S21W_PCREL_PLT
@@ -4150,8 +4142,6 @@  ENUM
 ENUMDOC
   This is a 16 bit offset from the call table base pointer.
 ENUM
-  BFD_RELOC_V850_32_GOTPCREL
-ENUMX
   BFD_RELOC_V850_16_GOT
 ENUMX
   BFD_RELOC_V850_32_GOT
@@ -4909,10 +4899,6 @@  ENUM
 ENUMDOC
   12 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-arc.c
+++ b/gas/config/tc-arc.c
@@ -543,7 +543,7 @@  static const struct arc_reloc_op_tag
   arc_reloc_op[] =
 {
   DEF (gotoff,  BFD_RELOC_32_GOTOFF,		1),
-  DEF (gotpc,   BFD_RELOC_ARC_GOTPC32,		0),
+  DEF (gotpc,   BFD_RELOC_32_GOT_PCREL,		0),
   DEF (plt,	BFD_RELOC_32_PLT_PCREL,		0),
   DEF (sda,	DUMMY_RELOC_ARC_ENTRY,		1),
   DEF (pcl,	BFD_RELOC_32_PCREL,		1),
@@ -3087,7 +3087,7 @@  md_apply_fix (fixS *fixP,
       md_number_to_chars (fixpos, value, fixP->fx_size);
       return;
 
-    case BFD_RELOC_ARC_GOTPC32:
+    case BFD_RELOC_32_GOT_PCREL:
       /* I cannot fix an GOTPC relocation because I need to relax it
 	 from ld rx,[pcl,@sym@gotpc] to add rx,pcl,@sym@gotpc.  */
       as_bad (_("Unsupported operation on reloc"));
@@ -3260,7 +3260,7 @@  tc_gen_reloc (asection *section ATTRIBUT
 
   /* if we have something like add gp, pcl,
      _GLOBAL_OFFSET_TABLE_@gotpc.  */
-  if (code == BFD_RELOC_ARC_GOTPC32
+  if (code == BFD_RELOC_32_GOT_PCREL
       && GOT_symbol
       && fixP->fx_addsy == GOT_symbol)
     code = BFD_RELOC_ARC_GOTPC;
@@ -4215,7 +4215,7 @@  tc_arc_fix_adjustable (fixS *fixP)
   /* Adjust_reloc_syms doesn't know about the GOT.  */
   switch (fixP->fx_r_type)
     {
-    case BFD_RELOC_ARC_GOTPC32:
+    case BFD_RELOC_32_GOT_PCREL:
     case BFD_RELOC_32_PLT_PCREL:
     case BFD_RELOC_ARC_S25H_PCREL_PLT:
     case BFD_RELOC_ARC_S21H_PCREL_PLT:
--- a/gas/config/tc-arc.h
+++ b/gas/config/tc-arc.h
@@ -129,7 +129,7 @@  extern const char *arc_target_format;
    relocations.  Check also that fx_addsy is not NULL, in order to
    make sure that the fixup refers to some sort of label.  */
 #define TC_VALIDATE_FIX(FIXP,SEG,SKIP)				     \
-  if ((FIXP->fx_r_type == BFD_RELOC_ARC_GOTPC32			     \
+  if ((FIXP->fx_r_type == BFD_RELOC_32_GOT_PCREL		     \
        || FIXP->fx_r_type == BFD_RELOC_32_PLT_PCREL		     \
        || FIXP->fx_r_type == BFD_RELOC_ARC_S25W_PCREL_PLT	     \
        || FIXP->fx_r_type == BFD_RELOC_ARC_S25H_PCREL_PLT	     \
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -29554,7 +29554,7 @@  tc_gen_reloc (asection *section, fixS *f
       && GOT_symbol
       && fixp->fx_addsy == GOT_symbol)
     {
-      code = BFD_RELOC_ARM_GOTPC;
+      code = BFD_RELOC_32_GOT_PCREL;
       reloc->addend = fixp->fx_offset = reloc->address;
     }
 #endif
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -3971,7 +3971,7 @@  _reloc (unsigned int size,
 	  case BFD_RELOC_X86_64_GOT32:
 	    return BFD_RELOC_X86_64_GOT64;
 	  case BFD_RELOC_X86_64_GOTPC32:
-	    other = BFD_RELOC_X86_64_GOTPC64;
+	    other = BFD_RELOC_64_GOT_PCREL;
 	    break;
 	  case BFD_RELOC_X86_64_GOTPCREL:
 	    other = BFD_RELOC_X86_64_GOTPCREL64;
@@ -13079,13 +13079,13 @@  output_disp (fragS *insn_start_frag, off
 		{
 		  if (!object_64bit)
 		    {
-		      reloc_type = BFD_RELOC_386_GOTPC;
+		      reloc_type = BFD_RELOC_32_GOT_PCREL;
 		      i.has_gotpc_tls_reloc = true;
 		      i.op[n].disps->X_add_number +=
 			encoding_length (insn_start_frag, insn_start_off, p);
 		    }
 		  else if (reloc_type == BFD_RELOC_64)
-		    reloc_type = BFD_RELOC_X86_64_GOTPC64;
+		    reloc_type = BFD_RELOC_64_GOT_PCREL;
 		  else
 		    /* Don't do the adjustment for x86-64, as there
 		       the pcrel addressing is relative to the _next_
@@ -13313,11 +13313,11 @@  output_imm (fragS *insn_start_frag, offs
 			      == O_subtract))))
 		{
 		  if (!object_64bit)
-		    reloc_type = BFD_RELOC_386_GOTPC;
+		    reloc_type = BFD_RELOC_32_GOT_PCREL;
 		  else if (size == 4)
 		    reloc_type = BFD_RELOC_X86_64_GOTPC32;
 		  else if (size == 8)
-		    reloc_type = BFD_RELOC_X86_64_GOTPC64;
+		    reloc_type = BFD_RELOC_64_GOT_PCREL;
 		  i.has_gotpc_tls_reloc = true;
 		  i.op[n].imms->X_add_number +=
 		    encoding_length (insn_start_frag, insn_start_off, p);
@@ -18525,7 +18525,7 @@  tc_gen_reloc (asection *section ATTRIBUT
     case BFD_RELOC_386_GOT32:
     case BFD_RELOC_386_GOT32X:
     case BFD_RELOC_32_GOTOFF:
-    case BFD_RELOC_386_GOTPC:
+    case BFD_RELOC_32_GOT_PCREL:
     case BFD_RELOC_386_TLS_GD:
     case BFD_RELOC_386_TLS_LDM:
     case BFD_RELOC_386_TLS_LDO_32:
@@ -18550,7 +18550,7 @@  tc_gen_reloc (asection *section ATTRIBUT
     case BFD_RELOC_X86_64_GOTPC32:
     case BFD_RELOC_X86_64_GOT64:
     case BFD_RELOC_X86_64_GOTPCREL64:
-    case BFD_RELOC_X86_64_GOTPC64:
+    case BFD_RELOC_64_GOT_PCREL:
     case BFD_RELOC_X86_64_GOTPLT64:
     case BFD_RELOC_64_PLTOFF:
     case BFD_RELOC_X86_64_GOTPC32_TLSDESC:
@@ -18622,7 +18622,7 @@  tc_gen_reloc (asection *section ATTRIBUT
       && fixp->fx_addsy == GOT_symbol)
     {
       if (!object_64bit)
-	code = BFD_RELOC_386_GOTPC;
+	code = BFD_RELOC_32_GOT_PCREL;
       else
 	code = BFD_RELOC_X86_64_GOTPC32;
     }
@@ -18630,7 +18630,7 @@  tc_gen_reloc (asection *section ATTRIBUT
       && GOT_symbol
       && fixp->fx_addsy == GOT_symbol)
     {
-      code = BFD_RELOC_X86_64_GOTPC64;
+      code = BFD_RELOC_64_GOT_PCREL;
     }
 
   rel = notes_alloc (sizeof (arelent));
@@ -18664,7 +18664,7 @@  tc_gen_reloc (asection *section ATTRIBUT
 	  case BFD_RELOC_64_GOTOFF:
 	  case BFD_RELOC_X86_64_GOT64:
 	  case BFD_RELOC_X86_64_GOTPCREL64:
-	  case BFD_RELOC_X86_64_GOTPC64:
+	  case BFD_RELOC_64_GOT_PCREL:
 	  case BFD_RELOC_X86_64_GOTPLT64:
 	  case BFD_RELOC_64_PLTOFF:
 	    as_bad_where (fixp->fx_file, fixp->fx_line,
--- a/gas/config/tc-i386.h
+++ b/gas/config/tc-i386.h
@@ -164,7 +164,7 @@  extern int tc_i386_fix_adjustable (struc
 #define TC_FORCE_RELOCATION_LOCAL(FIX)				\
   (GENERIC_FORCE_RELOCATION_LOCAL (FIX)				\
    || (FIX)->fx_r_type == BFD_RELOC_386_PLT32			\
-   || (FIX)->fx_r_type == BFD_RELOC_386_GOTPC			\
+   || (FIX)->fx_r_type == BFD_RELOC_32_GOT_PCREL		\
    || (FIX)->fx_r_type == BFD_RELOC_X86_64_GOTPCREL		\
    || (FIX)->fx_r_type == BFD_RELOC_X86_64_GOTPCRELX		\
    || (FIX)->fx_r_type == BFD_RELOC_X86_64_REX_GOTPCRELX	\
--- a/gas/config/tc-s390.c
+++ b/gas/config/tc-s390.c
@@ -2449,7 +2449,8 @@  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_64_GOT_PCREL:
     case BFD_RELOC_390_GOT16:
     case BFD_RELOC_390_GOTPCDBL:
     case BFD_RELOC_390_GOT64:
@@ -2838,10 +2839,11 @@  tc_gen_reloc (asection *seg ATTRIBUTE_UN
   code = fixp->fx_r_type;
   if (GOT_symbol && fixp->fx_addsy == GOT_symbol)
     {
-      if (   (s390_arch_size == 32 && code == BFD_RELOC_32_PCREL)
-	  || (s390_arch_size == 64 && code == BFD_RELOC_64_PCREL))
-	code = BFD_RELOC_390_GOTPC;
-      if (code == BFD_RELOC_390_PC32DBL)
+      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;
     }
 
--- a/gas/config/tc-sh.c
+++ b/gas/config/tc-sh.c
@@ -320,7 +320,7 @@  sh_check_fixup (expressionS *main_exp, b
     {
       if (exp->X_add_symbol && exp->X_add_symbol == GOT_symbol)
 	{
-	  *r_type_p = BFD_RELOC_SH_GOTPC;
+	  *r_type_p = BFD_RELOC_32_GOT_PCREL;
 	  return 0;
 	}
       exp = symbol_get_value_expression (exp->X_add_symbol);
@@ -3315,7 +3315,7 @@  sh_fix_adjustable (fixS *fixP)
   if (fixP->fx_r_type == BFD_RELOC_32_PLT_PCREL
       || fixP->fx_r_type == BFD_RELOC_SH_GOT32
       || fixP->fx_r_type == BFD_RELOC_SH_GOT20
-      || fixP->fx_r_type == BFD_RELOC_SH_GOTPC
+      || fixP->fx_r_type == BFD_RELOC_32_GOT_PCREL
       || fixP->fx_r_type == BFD_RELOC_SH_GOTFUNCDESC
       || fixP->fx_r_type == BFD_RELOC_SH_GOTFUNCDESC20
       || fixP->fx_r_type == BFD_RELOC_SH_GOTOFFFUNCDESC
@@ -3644,7 +3644,7 @@  md_apply_fix (fixS *fixP, valueT *valP,
       apply_full_field_fix (fixP, buf, val, 4);
       break;
 
-    case BFD_RELOC_SH_GOTPC:
+    case BFD_RELOC_32_GOT_PCREL:
       /* This is tough to explain.  We end up with this one if we have
          operands that look like "_GLOBAL_OFFSET_TABLE_+[.-.L284]".
          The goal here is to obtain the absolute address of the GOT,
--- a/gas/config/tc-sh.h
+++ b/gas/config/tc-sh.h
@@ -181,7 +181,7 @@  extern void sh_elf_final_processing (voi
    when used at runtime implies that we should add the address of the
    GOT to the specified location, and as a result we have simplified
    the expression into something we can use.  */
-#define TC_RELOC_GLOBAL_OFFSET_TABLE BFD_RELOC_SH_GOTPC
+#define TC_RELOC_GLOBAL_OFFSET_TABLE BFD_RELOC_32_GOT_PCREL
 
 #define tc_fix_adjustable(FIX) sh_fix_adjustable(FIX)
 extern bool sh_fix_adjustable (struct fix *);
@@ -203,7 +203,7 @@  extern bool sh_fix_adjustable (struct fi
   (GENERIC_FORCE_RELOCATION_LOCAL (FIX)			\
    || (FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL	\
    || (FIX)->fx_r_type == BFD_RELOC_SH_GOT32		\
-   || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC)
+   || (FIX)->fx_r_type == BFD_RELOC_32_GOT_PCREL)
 
 #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG)		\
   ((!md_register_arithmetic && (SEG) == reg_section)	\
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -259,7 +259,7 @@  static const struct elf_reloc_map x86_64
   { BFD_RELOC_X86_64_GOTPC32,	R_X86_64_GOTPC32, },
   { BFD_RELOC_X86_64_GOT64,	R_X86_64_GOT64, },
   { BFD_RELOC_X86_64_GOTPCREL64,R_X86_64_GOTPCREL64, },
-  { BFD_RELOC_X86_64_GOTPC64,	R_X86_64_GOTPC64, },
+  { BFD_RELOC_64_GOT_PCREL,	R_X86_64_GOTPC64, },
   { BFD_RELOC_X86_64_GOTPLT64,	R_X86_64_GOTPLT64, },
   { BFD_RELOC_64_PLTOFF,	R_X86_64_PLTOFF64, },
   { BFD_RELOC_SIZE32,		R_X86_64_SIZE32, },