[05/14] Arm: use BFD_RELOC_32_PLT_PCREL in favor of custom type

Message ID e2b3cacd-347e-40b5-a6ec-fe57a170f398@suse.com
State Committed
Headers
Series bfd: a little bit of reloc enum cleanup |

Commit Message

Jan Beulich Nov. 28, 2025, 11:31 a.m. UTC
  No reason to have a separate type when the generic one has no (other)
meaning for this target.

Doing the adjustments makes obvious that elf32_arm_reloc_map[] had two
identical entries; that duplicate is being removed.
  

Patch

--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -4219,7 +4219,6 @@  enum bfd_reloc_code_real
   BFD_RELOC_ARM_JUMP_SLOT,
   BFD_RELOC_ARM_GLOB_DAT,
   BFD_RELOC_ARM_GOT32,
-  BFD_RELOC_ARM_PLT32,
   BFD_RELOC_ARM_RELATIVE,
   BFD_RELOC_ARM_GOTOFF,
   BFD_RELOC_ARM_GOTPC,
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2023,13 +2023,12 @@  static const struct elf32_arm_reloc_map
     {BFD_RELOC_ARM_GOTPC,	     R_ARM_GOTPC},
     {BFD_RELOC_ARM_GOT_PREL,	     R_ARM_GOT_PREL},
     {BFD_RELOC_ARM_GOT32,	     R_ARM_GOT32},
-    {BFD_RELOC_ARM_PLT32,	     R_ARM_PLT32},
+    {BFD_RELOC_32_PLT_PCREL,	     R_ARM_PLT32},
     {BFD_RELOC_ARM_TARGET1,	     R_ARM_TARGET1},
     {BFD_RELOC_ARM_ROSEGREL32,	     R_ARM_ROSEGREL32},
     {BFD_RELOC_ARM_SBREL32,	     R_ARM_SBREL32},
     {BFD_RELOC_ARM_PREL31,	     R_ARM_PREL31},
     {BFD_RELOC_ARM_TARGET2,	     R_ARM_TARGET2},
-    {BFD_RELOC_ARM_PLT32,	     R_ARM_PLT32},
     {BFD_RELOC_ARM_TLS_GOTDESC,	     R_ARM_TLS_GOTDESC},
     {BFD_RELOC_ARM_TLS_CALL,	     R_ARM_TLS_CALL},
     {BFD_RELOC_ARM_THM_TLS_CALL,     R_ARM_THM_TLS_CALL},
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -1712,7 +1712,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_ARM_JUMP_SLOT",
   "BFD_RELOC_ARM_GLOB_DAT",
   "BFD_RELOC_ARM_GOT32",
-  "BFD_RELOC_ARM_PLT32",
   "BFD_RELOC_ARM_RELATIVE",
   "BFD_RELOC_ARM_GOTOFF",
   "BFD_RELOC_ARM_GOTPC",
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -3040,8 +3040,6 @@  ENUMX
 ENUMX
   BFD_RELOC_ARM_GOT32
 ENUMX
-  BFD_RELOC_ARM_PLT32
-ENUMX
   BFD_RELOC_ARM_RELATIVE
 ENUMX
   BFD_RELOC_ARM_GOTOFF
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -3849,7 +3849,7 @@  s_arm_elf_cons (int nbytes)
 							       reloc);
 	      int size = bfd_get_reloc_size (howto);
 
-	      if (reloc == BFD_RELOC_ARM_PLT32)
+	      if (reloc == BFD_RELOC_32_PLT_PCREL)
 		{
 		  as_bad (_("(plt) is only valid on branch targets"));
 		  reloc = BFD_RELOC_UNUSED;
@@ -9304,11 +9304,11 @@  encode_branch (int default_reloc)
 {
   if (inst.operands[0].hasreloc)
     {
-      constraint (inst.operands[0].imm != BFD_RELOC_ARM_PLT32
+      constraint (inst.operands[0].imm != BFD_RELOC_32_PLT_PCREL
 		  && inst.operands[0].imm != BFD_RELOC_ARM_TLS_CALL,
 		  _("the only valid suffixes here are '(plt)' and '(tlscall)'"));
-      inst.relocs[0].type = inst.operands[0].imm == BFD_RELOC_ARM_PLT32
-	? BFD_RELOC_ARM_PLT32
+      inst.relocs[0].type = inst.operands[0].imm == BFD_RELOC_32_PLT_PCREL
+	? BFD_RELOC_32_PLT_PCREL
 	: thumb_mode ? BFD_RELOC_ARM_THM_TLS_CALL : BFD_RELOC_ARM_TLS_CALL;
     }
   else
@@ -12019,7 +12019,7 @@  do_t_branch23 (void)
      the branch encoding is now needed to deal with TLSCALL relocs.
      So if we see a PLT reloc now, put it back to how it used to be to
      keep the preexisting behaviour.  */
-  if (inst.relocs[0].type == BFD_RELOC_ARM_PLT32)
+  if (inst.relocs[0].type == BFD_RELOC_32_PLT_PCREL)
     inst.relocs[0].type = BFD_RELOC_THUMB_PCREL_BRANCH23;
 
 #if defined(OBJ_COFF)
@@ -23899,7 +23899,7 @@  static struct reloc_entry reloc_names[]
 {
   { "got",     BFD_RELOC_ARM_GOT32   },	 { "GOT",     BFD_RELOC_ARM_GOT32   },
   { "gotoff",  BFD_RELOC_ARM_GOTOFF  },	 { "GOTOFF",  BFD_RELOC_ARM_GOTOFF  },
-  { "plt",     BFD_RELOC_ARM_PLT32   },	 { "PLT",     BFD_RELOC_ARM_PLT32   },
+  { "plt",     BFD_RELOC_32_PLT_PCREL},	 { "PLT",     BFD_RELOC_32_PLT_PCREL},
   { "target1", BFD_RELOC_ARM_TARGET1 },	 { "TARGET1", BFD_RELOC_ARM_TARGET1 },
   { "target2", BFD_RELOC_ARM_TARGET2 },	 { "TARGET2", BFD_RELOC_ARM_TARGET2 },
   { "sbrel",   BFD_RELOC_ARM_SBREL32 },	 { "SBREL",   BFD_RELOC_ARM_SBREL32 },
@@ -27245,7 +27245,7 @@  md_pcrel_from_section (fixS * fixP, segT
 
     case BFD_RELOC_ARM_PCREL_BRANCH:
     case BFD_RELOC_ARM_PCREL_JUMP:
-    case BFD_RELOC_ARM_PLT32:
+    case BFD_RELOC_32_PLT_PCREL:
 #ifdef TE_WINCE
       /* When handling fixups immediately, because we have already
 	 discovered the value of a symbol, or the address of the frag involved
@@ -28197,7 +28197,7 @@  md_apply_fix (fixS *	fixP,
 	}
       /* Fall through.  */
 
-    case BFD_RELOC_ARM_PLT32:
+    case BFD_RELOC_32_PLT_PCREL:
 #endif
     case BFD_RELOC_ARM_PCREL_BRANCH:
       temp = 3;
@@ -29419,7 +29419,7 @@  tc_gen_reloc (asection *section, fixS *f
     case BFD_RELOC_ARM_GOT32:
     case BFD_RELOC_ARM_GOTOFF:
     case BFD_RELOC_ARM_GOT_PREL:
-    case BFD_RELOC_ARM_PLT32:
+    case BFD_RELOC_32_PLT_PCREL:
     case BFD_RELOC_ARM_TARGET1:
     case BFD_RELOC_ARM_ROSEGREL32:
     case BFD_RELOC_ARM_SBREL32:
@@ -29748,7 +29748,7 @@  arm_fix_adjustable (fixS * fixP)
     return false;
 
   /* Don't allow symbols to be discarded on GOT related relocs.	 */
-  if (fixP->fx_r_type == BFD_RELOC_ARM_PLT32
+  if (fixP->fx_r_type == BFD_RELOC_32_PLT_PCREL
       || fixP->fx_r_type == BFD_RELOC_ARM_GOT32
       || fixP->fx_r_type == BFD_RELOC_ARM_GOTOFF
       || fixP->fx_r_type == BFD_RELOC_ARM_TLS_GD32
@@ -30062,7 +30062,7 @@  md_begin (void)
     {
       struct reloc_entry * entry = reloc_names + i;
 
-      if (arm_is_eabi() && entry->reloc == BFD_RELOC_ARM_PLT32)
+      if (arm_is_eabi() && entry->reloc == BFD_RELOC_32_PLT_PCREL)
 	/* This makes encode_branch() use the EABI versions of this relocation.  */
 	entry->reloc = BFD_RELOC_UNUSED;