[06/14] Arc: use generic BFD_RELOC_... in favor of custom types

Message ID e2fd8a08-fcaf-4963-b904-d2b10ff33558@suse.com
State New
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 separate types when the generic ones have no (other)
meaning for this target.
  

Patch

--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -4412,11 +4412,6 @@  enum bfd_reloc_code_real
   BFD_RELOC_SH_FUNCDESC,
 
   /* ARC relocs.  */
-  BFD_RELOC_ARC_NONE,
-  BFD_RELOC_ARC_8,
-  BFD_RELOC_ARC_16,
-  BFD_RELOC_ARC_24,
-  BFD_RELOC_ARC_32,
   BFD_RELOC_ARC_N8,
   BFD_RELOC_ARC_N16,
   BFD_RELOC_ARC_N24,
@@ -4455,10 +4450,8 @@  enum bfd_reloc_code_real
   BFD_RELOC_ARC_SDA_12,
   BFD_RELOC_ARC_SDA16_ST2,
   BFD_RELOC_ARC_32_PCREL,
-  BFD_RELOC_ARC_PC32,
   BFD_RELOC_ARC_GOT32,
   BFD_RELOC_ARC_GOTPC32,
-  BFD_RELOC_ARC_PLT32,
   BFD_RELOC_ARC_COPY,
   BFD_RELOC_ARC_GLOB_DAT,
   BFD_RELOC_ARC_JMP_SLOT,
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -377,15 +377,18 @@  arc_elf_link_hash_table_create (bfd *abf
 #define ARC_RELOC_HOWTO(TYPE, VALUE, SIZE, BITSIZE, RELOC_FUNCTION, OVERFLOW, FORMULA) \
   { BFD_RELOC_##TYPE, R_##TYPE },
 
+/* Aliases.  */
+#define BFD_RELOC_ARC_NONE	BFD_RELOC_NONE
+#define BFD_RELOC_ARC_8		BFD_RELOC_8
+#define BFD_RELOC_ARC_16	BFD_RELOC_16
+#define BFD_RELOC_ARC_24	BFD_RELOC_24
+#define BFD_RELOC_ARC_32	BFD_RELOC_32
+#define BFD_RELOC_ARC_PC32	BFD_RELOC_32_PCREL
+#define BFD_RELOC_ARC_PLT32	BFD_RELOC_32_PLT_PCREL
+
 static const struct arc_reloc_map arc_reloc_map[] =
 {
 #include "elf/arc-reloc.def"
-
-  {BFD_RELOC_NONE,  R_ARC_NONE},
-  {BFD_RELOC_8,  R_ARC_8},
-  {BFD_RELOC_16, R_ARC_16},
-  {BFD_RELOC_24, R_ARC_24},
-  {BFD_RELOC_32, R_ARC_32},
 };
 
 #undef ARC_RELOC_HOWTO
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -1888,11 +1888,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_SH_GOTOFFFUNCDESC",
   "BFD_RELOC_SH_GOTOFFFUNCDESC20",
   "BFD_RELOC_SH_FUNCDESC",
-  "BFD_RELOC_ARC_NONE",
-  "BFD_RELOC_ARC_8",
-  "BFD_RELOC_ARC_16",
-  "BFD_RELOC_ARC_24",
-  "BFD_RELOC_ARC_32",
   "BFD_RELOC_ARC_N8",
   "BFD_RELOC_ARC_N16",
   "BFD_RELOC_ARC_N24",
@@ -1931,10 +1926,8 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_ARC_SDA_12",
   "BFD_RELOC_ARC_SDA16_ST2",
   "BFD_RELOC_ARC_32_PCREL",
-  "BFD_RELOC_ARC_PC32",
   "BFD_RELOC_ARC_GOT32",
   "BFD_RELOC_ARC_GOTPC32",
-  "BFD_RELOC_ARC_PLT32",
   "BFD_RELOC_ARC_COPY",
   "BFD_RELOC_ARC_GLOB_DAT",
   "BFD_RELOC_ARC_JMP_SLOT",
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -3417,16 +3417,6 @@  ENUMDOC
   Renesas / SuperH SH relocs.  Not all of these appear in object files.
 
 ENUM
-  BFD_RELOC_ARC_NONE
-ENUMX
-  BFD_RELOC_ARC_8
-ENUMX
-  BFD_RELOC_ARC_16
-ENUMX
-  BFD_RELOC_ARC_24
-ENUMX
-  BFD_RELOC_ARC_32
-ENUMX
   BFD_RELOC_ARC_N8
 ENUMX
   BFD_RELOC_ARC_N16
@@ -3503,14 +3493,10 @@  ENUMX
 ENUMX
   BFD_RELOC_ARC_32_PCREL
 ENUMX
-  BFD_RELOC_ARC_PC32
-ENUMX
   BFD_RELOC_ARC_GOT32
 ENUMX
   BFD_RELOC_ARC_GOTPC32
 ENUMX
-  BFD_RELOC_ARC_PLT32
-ENUMX
   BFD_RELOC_ARC_COPY
 ENUMX
   BFD_RELOC_ARC_GLOB_DAT
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -544,9 +544,9 @@  static const struct arc_reloc_op_tag
 {
   DEF (gotoff,  BFD_RELOC_ARC_GOTOFF,		1),
   DEF (gotpc,   BFD_RELOC_ARC_GOTPC32,		0),
-  DEF (plt,	BFD_RELOC_ARC_PLT32,		0),
+  DEF (plt,	BFD_RELOC_32_PLT_PCREL,		0),
   DEF (sda,	DUMMY_RELOC_ARC_ENTRY,		1),
-  DEF (pcl,	BFD_RELOC_ARC_PC32,		1),
+  DEF (pcl,	BFD_RELOC_32_PCREL,		1),
   DEF (tlsgd,   BFD_RELOC_ARC_TLS_GD_GOT,	0),
   DEF (tlsie,   BFD_RELOC_ARC_TLS_IE_GOT,	0),
   DEF (tpoff9,  BFD_RELOC_ARC_TLS_LE_S9,	0),
@@ -1593,7 +1593,7 @@  get_register (symbolS *sym)
 }
 
 /* Return true if a RELOC is generic.  A generic reloc is PC-rel of a
-   simple ME relocation (e.g. RELOC_ARC_32_ME, BFD_RELOC_ARC_PC32.  */
+   simple ME relocation (e.g. RELOC_ARC_32_ME, BFD_RELOC_32_PCREL.  */
 
 static bool
 generic_reloc_p (extended_bfd_reloc_code_real_type reloc)
@@ -2785,7 +2785,7 @@  md_pcrel_from_section (fixS *fixP,
     {
       switch (fixP->fx_r_type)
 	{
-	case BFD_RELOC_ARC_PC32:
+	case BFD_RELOC_32_PCREL:
 	  /* The hardware calculates relative to the start of the
 	     insn, but this relocation is relative to location of the
 	     LIMM, compensate.  The base always needs to be
@@ -2793,7 +2793,7 @@  md_pcrel_from_section (fixS *fixP,
 	     relocation for short instructions.  */
 	  base -= 4;
 	  /* Fall through.  */
-	case BFD_RELOC_ARC_PLT32:
+	case BFD_RELOC_32_PLT_PCREL:
 	case BFD_RELOC_ARC_S25H_PCREL_PLT:
 	case BFD_RELOC_ARC_S21H_PCREL_PLT:
 	case BFD_RELOC_ARC_S25W_PCREL_PLT:
@@ -3001,9 +3001,9 @@  md_apply_fix (fixS *fixP,
 	  fixP->fx_offset += fixP->fx_frag->fr_address;
 	  /* Fall through.  */
 	case BFD_RELOC_32:
-	  fixP->fx_r_type = BFD_RELOC_ARC_PC32;
+	  fixP->fx_r_type = BFD_RELOC_32_PCREL;
 	  /* Fall through.  */
-	case BFD_RELOC_ARC_PC32:
+	case BFD_RELOC_32_PCREL:
 	  /* fixP->fx_offset += fixP->fx_where - fixP->fx_dot_value; */
 	  break;
 	default:
@@ -3101,11 +3101,11 @@  md_apply_fix (fixS *fixP,
 
     case BFD_RELOC_ARC_GOTOFF:
     case BFD_RELOC_ARC_32_ME:
-    case BFD_RELOC_ARC_PC32:
+    case BFD_RELOC_32_PCREL:
       md_number_to_chars_midend (fixpos, value, fixP->fx_size);
       return;
 
-    case BFD_RELOC_ARC_PLT32:
+    case BFD_RELOC_32_PLT_PCREL:
       md_number_to_chars_midend (fixpos, value, fixP->fx_size);
       return;
 
@@ -4216,7 +4216,7 @@  tc_arc_fix_adjustable (fixS *fixP)
   switch (fixP->fx_r_type)
     {
     case BFD_RELOC_ARC_GOTPC32:
-    case BFD_RELOC_ARC_PLT32:
+    case BFD_RELOC_32_PLT_PCREL:
     case BFD_RELOC_ARC_S25H_PCREL_PLT:
     case BFD_RELOC_ARC_S21H_PCREL_PLT:
     case BFD_RELOC_ARC_S25W_PCREL_PLT:
--- a/gas/config/tc-arc.h
+++ b/gas/config/tc-arc.h
@@ -130,7 +130,7 @@  extern const char *arc_target_format;
    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			     \
-       || FIXP->fx_r_type == BFD_RELOC_ARC_PLT32		     \
+       || 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	     \
        || FIXP->fx_r_type == BFD_RELOC_ARC_S21W_PCREL_PLT	     \
--- a/opcodes/arc-opc.c
+++ b/opcodes/arc-opc.c
@@ -2737,7 +2737,7 @@  const struct arc_reloc_equiv_tab arc_rel
   { "plt", 0, { F_NULL }, BFD_RELOC_ARC_S21W_PCREL,
     BFD_RELOC_ARC_S21W_PCREL_PLT },
 
-  { "plt", 0, { F_NULL }, BFD_RELOC_ARC_32_ME, BFD_RELOC_ARC_PLT32 }
+  { "plt", 0, { F_NULL }, BFD_RELOC_ARC_32_ME, BFD_RELOC_32_PLT_PCREL }
 };
 
 const unsigned arc_num_equiv_tab = ARRAY_SIZE (arc_reloc_equiv);