[binutils-gdb] Arc: use generic BFD_RELOC_... in favor of custom types

Jan Beulich jbeulich@sourceware.org
Mon Dec 15 09:51:36 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c955476e7e77d121f0a04e6e97bdbe5b188a478a

commit c955476e7e77d121f0a04e6e97bdbe5b188a478a
Author: Jan Beulich <jbeulich@suse.com>
Date:   Mon Dec 15 10:48:26 2025 +0100

    Arc: use generic BFD_RELOC_... in favor of custom types
    
    No reason to have separate types when the generic ones have no (other)
    meaning for this target.

Diff:
---
 bfd/bfd-in2.h       |  7 -------
 bfd/elf32-arc.c     | 15 +++++++++------
 bfd/libbfd.h        |  7 -------
 bfd/reloc.c         | 14 --------------
 gas/config/tc-arc.c | 20 ++++++++++----------
 gas/config/tc-arc.h |  2 +-
 opcodes/arc-opc.c   |  2 +-
 7 files changed, 21 insertions(+), 46 deletions(-)

diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 35f8c1ee096..caad47a4a62 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -4402,11 +4402,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,
@@ -4445,10 +4440,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,
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index c1a9fb699a4..3ba299bd00e 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -377,15 +377,18 @@ arc_elf_link_hash_table_create (bfd *abfd)
 #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
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 1196041c47b..91cdee7fc4a 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -1888,11 +1888,6 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
   "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_real_names[] = { "@@uninitialized@@",
   "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",
diff --git a/bfd/reloc.c b/bfd/reloc.c
index af21596aba4..18f53e38255 100644
--- 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
@@ -3502,14 +3492,10 @@ ENUMX
   BFD_RELOC_ARC_SDA16_ST2
 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
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index d5dee067ab0..2a324bfaab3 100644
--- 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:
diff --git a/gas/config/tc-arc.h b/gas/config/tc-arc.h
index 0ab2eb95cad..d3cd3cb67ac 100644
--- 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	     \
diff --git a/opcodes/arc-opc.c b/opcodes/arc-opc.c
index 7aa26189c66..e9ea1b46b75 100644
--- a/opcodes/arc-opc.c
+++ b/opcodes/arc-opc.c
@@ -2737,7 +2737,7 @@ const struct arc_reloc_equiv_tab arc_reloc_equiv[] =
   { "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);


More information about the Binutils-cvs mailing list