[09/14] bfd/ELF: fold BFD_RELOC_<arch>_IRELATIVE

Message ID 57fad9b6-7300-46ec-858f-c6b233dc91a7@suse.com
State New
Headers
Series bfd: a little bit of reloc enum cleanup |

Commit Message

Jan Beulich Nov. 28, 2025, 11:37 a.m. UTC
  There's no need to have a separate reloc per arch; just like for other
more or less generic ones a single one will (mostly) do. Arm64, C-Sky, and
KVX - sadly - are exceptions.
---
Arm64, C-Sky, and KVX, explicitly and/or implicitly, do math on their
enumerators. While for the former two a testsuite run pointed out the need
to retain their relocs, for KVX I spotted this only by going through all
the comments. Imo really all three should have build-time checks in place
to make sure ordering assumptions aren't broken.
  

Patch

--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -3333,6 +3333,7 @@  enum bfd_reloc_code_real
   BFD_RELOC_HI16_PLTOFF,
   BFD_RELOC_HI16_S_PLTOFF,
   BFD_RELOC_8_PLTOFF,
+  BFD_RELOC_IRELATIVE,
 
   /* Size relocations.  */
   BFD_RELOC_SIZE32,
@@ -3417,7 +3418,6 @@  enum bfd_reloc_code_real
   BFD_RELOC_SPARC_GOTDATA_OP_LOX10,
   BFD_RELOC_SPARC_GOTDATA_OP,
   BFD_RELOC_SPARC_JMP_IREL,
-  BFD_RELOC_SPARC_IRELATIVE,
 
   /* I think these are specific to SPARC a.out (e.g., Sun 4).  */
   BFD_RELOC_SPARC_BASE13,
@@ -3874,7 +3874,6 @@  enum bfd_reloc_code_real
   BFD_RELOC_386_TLS_GOTDESC,
   BFD_RELOC_386_TLS_DESC_CALL,
   BFD_RELOC_386_TLS_DESC,
-  BFD_RELOC_386_IRELATIVE,
   BFD_RELOC_386_GOT32X,
 
   /* x86-64/elf relocations.  */
@@ -3902,7 +3901,6 @@  enum bfd_reloc_code_real
   BFD_RELOC_X86_64_GOTPC32_TLSDESC,
   BFD_RELOC_X86_64_TLSDESC_CALL,
   BFD_RELOC_X86_64_TLSDESC,
-  BFD_RELOC_X86_64_IRELATIVE,
   BFD_RELOC_X86_64_PC32_BND,
   BFD_RELOC_X86_64_PLT32_BND,
   BFD_RELOC_X86_64_GOTPCRELX,
@@ -4271,9 +4269,6 @@  enum bfd_reloc_code_real
   /* Annotation of BX instructions.  */
   BFD_RELOC_ARM_V4BX,
 
-  /* ARM support for STT_GNU_IFUNC.  */
-  BFD_RELOC_ARM_IRELATIVE,
-
   /* Thumb1 relocations to support execute-only code.  */
   BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC,
   BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC,
@@ -5616,9 +5611,6 @@  enum bfd_reloc_code_real
   BFD_RELOC_390_GOTPLT20,
   BFD_RELOC_390_TLS_GOTIE20,
 
-  /* STT_GNU_IFUNC relocation.  */
-  BFD_RELOC_390_IRELATIVE,
-
   /* Score relocations.
      Low 16 bit for load/store.  */
   BFD_RELOC_SCORE_GPREL15,
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2043,7 +2043,7 @@  static const struct elf32_arm_reloc_map
     {BFD_RELOC_ARM_TLS_TPOFF32,	     R_ARM_TLS_TPOFF32},
     {BFD_RELOC_ARM_TLS_IE32,	     R_ARM_TLS_IE32},
     {BFD_RELOC_ARM_TLS_LE32,	     R_ARM_TLS_LE32},
-    {BFD_RELOC_ARM_IRELATIVE,	     R_ARM_IRELATIVE},
+    {BFD_RELOC_IRELATIVE,	     R_ARM_IRELATIVE},
     {BFD_RELOC_ARM_GOTFUNCDESC,      R_ARM_GOTFUNCDESC},
     {BFD_RELOC_ARM_GOTOFFFUNCDESC,   R_ARM_GOTOFFFUNCDESC},
     {BFD_RELOC_ARM_FUNCDESC,         R_ARM_FUNCDESC},
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -322,8 +322,8 @@  elf_i386_reloc_type_lookup (bfd *abfd,
       TRACE ("BFD_RELOC_386_TLS_DESC");
       return &elf_howto_table[R_386_TLS_DESC - R_386_tls_offset];
 
-    case BFD_RELOC_386_IRELATIVE:
-      TRACE ("BFD_RELOC_386_IRELATIVE");
+    case BFD_RELOC_IRELATIVE:
+      TRACE ("BFD_RELOC_IRELATIVE");
       return &elf_howto_table[R_386_IRELATIVE - R_386_tls_offset];
 
     case BFD_RELOC_386_GOT32X:
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -289,7 +289,7 @@  elf_s390_reloc_type_lookup (bfd *abfd AT
       return &elf_howto_table[(int) R_390_GOTPLT20];
     case BFD_RELOC_390_TLS_GOTIE20:
       return &elf_howto_table[(int) R_390_TLS_GOTIE20];
-    case BFD_RELOC_390_IRELATIVE:
+    case BFD_RELOC_IRELATIVE:
       return &elf_howto_table[(int) R_390_IRELATIVE];
     case BFD_RELOC_VTABLE_INHERIT:
       return &elf32_s390_vtinherit_howto;
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -317,7 +317,7 @@  elf_s390_reloc_type_lookup (bfd *abfd,
       return &elf_howto_table[(int) R_390_GOTPLT20];
     case BFD_RELOC_390_TLS_GOTIE20:
       return &elf_howto_table[(int) R_390_TLS_GOTIE20];
-    case BFD_RELOC_390_IRELATIVE:
+    case BFD_RELOC_IRELATIVE:
       return &elf_howto_table[(int) R_390_IRELATIVE];
     case BFD_RELOC_VTABLE_INHERIT:
       return &elf64_s390_vtinherit_howto;
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -266,7 +266,7 @@  static const struct elf_reloc_map x86_64
   { BFD_RELOC_X86_64_GOTPC32_TLSDESC, R_X86_64_GOTPC32_TLSDESC, },
   { BFD_RELOC_X86_64_TLSDESC_CALL, R_X86_64_TLSDESC_CALL, },
   { BFD_RELOC_X86_64_TLSDESC,	R_X86_64_TLSDESC, },
-  { BFD_RELOC_X86_64_IRELATIVE,	R_X86_64_IRELATIVE, },
+  { BFD_RELOC_IRELATIVE,	R_X86_64_IRELATIVE, },
   { BFD_RELOC_X86_64_PC32_BND,	R_X86_64_PC32_BND, },
   { BFD_RELOC_X86_64_PLT32_BND,	R_X86_64_PLT32_BND, },
   { BFD_RELOC_X86_64_GOTPCRELX, R_X86_64_GOTPCRELX, },
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -567,7 +567,7 @@  _bfd_sparc_elf_reloc_type_lookup (bfd *a
     case BFD_RELOC_SPARC_JMP_IREL:
       return &sparc_jmp_irel_howto;
 
-    case BFD_RELOC_SPARC_IRELATIVE:
+    case BFD_RELOC_IRELATIVE:
       return &sparc_irelative_howto;
 
     case BFD_RELOC_VTABLE_INHERIT:
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -1099,6 +1099,7 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_HI16_PLTOFF",
   "BFD_RELOC_HI16_S_PLTOFF",
   "BFD_RELOC_8_PLTOFF",
+  "BFD_RELOC_IRELATIVE",
   "BFD_RELOC_SIZE32",
   "BFD_RELOC_SIZE64",
   "BFD_RELOC_68K_GLOB_DAT",
@@ -1157,7 +1158,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_SPARC_GOTDATA_OP_LOX10",
   "BFD_RELOC_SPARC_GOTDATA_OP",
   "BFD_RELOC_SPARC_JMP_IREL",
-  "BFD_RELOC_SPARC_IRELATIVE",
   "BFD_RELOC_SPARC_BASE13",
   "BFD_RELOC_SPARC_BASE22",
   "BFD_RELOC_SPARC_10",
@@ -1440,7 +1440,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_386_TLS_GOTDESC",
   "BFD_RELOC_386_TLS_DESC_CALL",
   "BFD_RELOC_386_TLS_DESC",
-  "BFD_RELOC_386_IRELATIVE",
   "BFD_RELOC_386_GOT32X",
   "BFD_RELOC_X86_64_GOT32",
   "BFD_RELOC_X86_64_COPY",
@@ -1466,7 +1465,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_X86_64_GOTPC32_TLSDESC",
   "BFD_RELOC_X86_64_TLSDESC_CALL",
   "BFD_RELOC_X86_64_TLSDESC",
-  "BFD_RELOC_X86_64_IRELATIVE",
   "BFD_RELOC_X86_64_PC32_BND",
   "BFD_RELOC_X86_64_PLT32_BND",
   "BFD_RELOC_X86_64_GOTPCRELX",
@@ -1757,7 +1755,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_ARM_LDC_SB_G1",
   "BFD_RELOC_ARM_LDC_SB_G2",
   "BFD_RELOC_ARM_V4BX",
-  "BFD_RELOC_ARM_IRELATIVE",
   "BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC",
   "BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC",
   "BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC",
@@ -2541,7 +2538,6 @@  static const char *const bfd_reloc_code_
   "BFD_RELOC_390_GOT20",
   "BFD_RELOC_390_GOTPLT20",
   "BFD_RELOC_390_TLS_GOTIE20",
-  "BFD_RELOC_390_IRELATIVE",
   "BFD_RELOC_SCORE_GPREL15",
   "BFD_RELOC_SCORE_DUMMY2",
   "BFD_RELOC_SCORE_JMP",
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -1470,6 +1470,8 @@  ENUMX
   BFD_RELOC_HI16_S_PLTOFF
 ENUMX
   BFD_RELOC_8_PLTOFF
+ENUMX
+  BFD_RELOC_IRELATIVE
 ENUMDOC
   For ELF.
 
@@ -1619,8 +1621,6 @@  ENUMX
   BFD_RELOC_SPARC_GOTDATA_OP
 ENUMX
   BFD_RELOC_SPARC_JMP_IREL
-ENUMX
-  BFD_RELOC_SPARC_IRELATIVE
 ENUMDOC
   SPARC ELF relocations.  There is probably some overlap with other
   relocation types already defined.
@@ -2403,8 +2403,6 @@  ENUMX
 ENUMX
   BFD_RELOC_386_TLS_DESC
 ENUMX
-  BFD_RELOC_386_IRELATIVE
-ENUMX
   BFD_RELOC_386_GOT32X
 ENUMDOC
   i386/elf relocations.
@@ -2458,8 +2456,6 @@  ENUMX
 ENUMX
   BFD_RELOC_X86_64_TLSDESC
 ENUMX
-  BFD_RELOC_X86_64_IRELATIVE
-ENUMX
   BFD_RELOC_X86_64_PC32_BND
 ENUMX
   BFD_RELOC_X86_64_PLT32_BND
@@ -3142,11 +3138,6 @@  ENUMDOC
   Annotation of BX instructions.
 
 ENUM
-  BFD_RELOC_ARM_IRELATIVE
-ENUMDOC
-  ARM support for STT_GNU_IFUNC.
-
-ENUM
   BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC
 ENUMX
   BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC
@@ -5306,11 +5297,6 @@  ENUMDOC
   Long displacement extension.
 
 ENUM
-  BFD_RELOC_390_IRELATIVE
-ENUMDOC
-  STT_GNU_IFUNC relocation.
-
-ENUM
   BFD_RELOC_SCORE_GPREL15
 ENUMDOC
   Score relocations.