]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd/s390+sh: don't abuse BFD_RELOC_32_GOT_PCREL
authorJan Beulich <jbeulich@suse.com>
Thu, 9 Apr 2026 06:36:55 +0000 (08:36 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 9 Apr 2026 06:36:55 +0000 (08:36 +0200)
Neither R_390_GOT32 nor R_SH_GOT32 are PC-relative relocations, so don't
use a generic PC-relative enumerator for them. Doing so gets in the way
of properly using that enumerator.

bfd/bfd-in2.h
bfd/elf32-s390.c
bfd/elf32-sh.c
bfd/elf64-s390.c
bfd/libbfd.h
bfd/reloc.c
gas/config/tc-s390.c
gas/config/tc-sh.c
gas/config/tc-sh.h

index 7313dd12370a6ba8d8a68a85154896c63d0ebe9f..914f1b435a8dc5c89bbca6fe8a466b604de5978d 100644 (file)
@@ -4339,6 +4339,7 @@ enum bfd_reloc_code_real
   BFD_RELOC_SH_RELATIVE64,
   BFD_RELOC_SH_GOT10BY4,
   BFD_RELOC_SH_GOT10BY8,
+  BFD_RELOC_SH_GOT32,
   BFD_RELOC_SH_GOTPLT10BY4,
   BFD_RELOC_SH_GOTPLT10BY8,
   BFD_RELOC_SH_GOTPLT32,
@@ -5432,6 +5433,9 @@ enum bfd_reloc_code_real
   /* 16 bit GOT offset.  */
   BFD_RELOC_390_GOT16,
 
+  /* 32 bit GOT offset.  */
+  BFD_RELOC_390_GOT32,
+
   /* PC relative 12 bit shifted by 1.  */
   BFD_RELOC_390_PC12DBL,
 
index a47eb99b04040bc7b078fa92d5122ff6f9160e1a..a520bec27803b9782c8e917919f1643d0c2542d4 100644 (file)
@@ -199,7 +199,7 @@ elf_s390_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
       return &elf_howto_table[(int) R_390_PC32];
     case BFD_RELOC_390_GOT12:
       return &elf_howto_table[(int) R_390_GOT12];
-    case BFD_RELOC_32_GOT_PCREL:
+    case BFD_RELOC_390_GOT32:
       return &elf_howto_table[(int) R_390_GOT32];
     case BFD_RELOC_32_PLT_PCREL:
       return &elf_howto_table[(int) R_390_PLT32];
index 05f77e03816a7dceab74f1d7a2992416bc7b64bd..81bf415a27e18ebdf9e04d10d805f3df26f9025e 100644 (file)
@@ -353,7 +353,7 @@ static const struct elf_reloc_map sh_reloc_map[] =
   { BFD_RELOC_SH_TLS_DTPMOD32, R_SH_TLS_DTPMOD32 },
   { BFD_RELOC_SH_TLS_DTPOFF32, R_SH_TLS_DTPOFF32 },
   { BFD_RELOC_SH_TLS_TPOFF32, R_SH_TLS_TPOFF32 },
-  { BFD_RELOC_32_GOT_PCREL, R_SH_GOT32 },
+  { BFD_RELOC_SH_GOT32, R_SH_GOT32 },
   { BFD_RELOC_32_PLT_PCREL, R_SH_PLT32 },
   { BFD_RELOC_COPY, R_SH_COPY },
   { BFD_RELOC_GLOB_DAT, R_SH_GLOB_DAT },
index 4eb9f3d866ea4a143fc488556bfdebe1f189490d..f635cba0bfbf53b5c762a96b805468d837a1bbb7 100644 (file)
@@ -213,7 +213,7 @@ elf_s390_reloc_type_lookup (bfd *abfd,
       return &elf_howto_table[(int) R_390_PC32];
     case BFD_RELOC_390_GOT12:
       return &elf_howto_table[(int) R_390_GOT12];
-    case BFD_RELOC_32_GOT_PCREL:
+    case BFD_RELOC_390_GOT32:
       return &elf_howto_table[(int) R_390_GOT32];
     case BFD_RELOC_32_PLT_PCREL:
       return &elf_howto_table[(int) R_390_PLT32];
index a5a7245c5fd8de2ce5c3654c97cb97dadfbffa95..17df7667564f763282a979b90a18bcec263f8852 100644 (file)
@@ -1827,6 +1827,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
   "BFD_RELOC_SH_RELATIVE64",
   "BFD_RELOC_SH_GOT10BY4",
   "BFD_RELOC_SH_GOT10BY8",
+  "BFD_RELOC_SH_GOT32",
   "BFD_RELOC_SH_GOTPLT10BY4",
   "BFD_RELOC_SH_GOTPLT10BY8",
   "BFD_RELOC_SH_GOTPLT32",
@@ -2419,6 +2420,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
   "BFD_RELOC_390_GOT12",
   "BFD_RELOC_390_GOTPC",
   "BFD_RELOC_390_GOT16",
+  "BFD_RELOC_390_GOT32",
   "BFD_RELOC_390_PC12DBL",
   "BFD_RELOC_390_PLT12DBL",
   "BFD_RELOC_390_PC16DBL",
index ff237b817be44813470da482db67627c5074b92c..bd12910a07d990ebecfabe832b6ee54feb49c98c 100644 (file)
@@ -3203,6 +3203,8 @@ ENUMX
   BFD_RELOC_SH_GOT10BY4
 ENUMX
   BFD_RELOC_SH_GOT10BY8
+ENUMX
+  BFD_RELOC_SH_GOT32
 ENUMX
   BFD_RELOC_SH_GOTPLT10BY4
 ENUMX
@@ -4918,6 +4920,10 @@ ENUM
   BFD_RELOC_390_GOT16
 ENUMDOC
   16 bit GOT offset.
+ENUM
+  BFD_RELOC_390_GOT32
+ENUMDOC
+  32 bit GOT offset.
 ENUM
   BFD_RELOC_390_PC12DBL
 ENUMDOC
index 61ae323fe80f2264c0b76141a5aaf44b7e7be03f..f378b3a40116669e708be3f8ef571eadfd369afb 100644 (file)
@@ -1107,7 +1107,7 @@ s390_lit_suffix (char **str_p, expressionS *exp_p, elf_suffix_type suffix)
       if (nbytes == 2)
        reloc = BFD_RELOC_390_GOT16;
       else if (nbytes == 4)
-       reloc = BFD_RELOC_32_GOT_PCREL;
+       reloc = BFD_RELOC_390_GOT32;
       else if (nbytes == 8)
        reloc = BFD_RELOC_390_GOT64;
     }
@@ -1271,7 +1271,7 @@ s390_elf_cons (int nbytes /* 1=.byte, 2=.word, 4=.long */)
              static bfd_reloc_code_real_type tab4[] =
                {
                  BFD_RELOC_UNUSED,             /* ELF_SUFFIX_NONE  */
-                 BFD_RELOC_32_GOT_PCREL,       /* ELF_SUFFIX_GOT  */
+                 BFD_RELOC_390_GOT32,          /* ELF_SUFFIX_GOT  */
                  BFD_RELOC_32_PLT_PCREL,       /* ELF_SUFFIX_PLT  */
                  BFD_RELOC_UNUSED,             /* ELF_SUFFIX_GOTENT  */
                  BFD_RELOC_32_GOTOFF,          /* ELF_SUFFIX_GOTOFF  */
@@ -2396,7 +2396,7 @@ tc_s390_fix_adjustable (fixS *fixP)
       || fixP->fx_r_type == BFD_RELOC_390_GOT12
       || fixP->fx_r_type == BFD_RELOC_390_GOT20
       || fixP->fx_r_type == BFD_RELOC_390_GOT16
-      || fixP->fx_r_type == BFD_RELOC_32_GOT_PCREL
+      || fixP->fx_r_type == BFD_RELOC_390_GOT32
       || fixP->fx_r_type == BFD_RELOC_390_GOT64
       || fixP->fx_r_type == BFD_RELOC_390_GOTENT
       || fixP->fx_r_type == BFD_RELOC_390_GOTPLT12
@@ -2443,7 +2443,7 @@ tc_s390_force_relocation (struct fix *fixp)
     {
     case BFD_RELOC_390_GOT12:
     case BFD_RELOC_390_GOT20:
-    case BFD_RELOC_32_GOT_PCREL:
+    case BFD_RELOC_390_GOT32:
     case BFD_RELOC_32_GOTOFF:
     case BFD_RELOC_64_GOTOFF:
     case BFD_RELOC_390_PLTOFF16:
@@ -2728,7 +2728,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
          if (fixP->fx_done)
            md_number_to_chars (where, value, 4);
          break;
-       case BFD_RELOC_32_GOT_PCREL:
+       case BFD_RELOC_390_GOT32:
        case BFD_RELOC_390_PLTOFF32:
        case BFD_RELOC_32_PLT_PCREL:
        case BFD_RELOC_390_GOTPLT32:
index 5221ca99406452540be857e032e4450288c257aa..04923915f4051578d9475fe731ab4473d2226127 100644 (file)
@@ -340,7 +340,7 @@ sh_check_fixup (expressionS *main_exp, bfd_reloc_code_real_type *r_type_p)
        case BFD_RELOC_SH_DISP20:
          switch (exp->X_md)
            {
-           case BFD_RELOC_32_GOT_PCREL:
+           case BFD_RELOC_SH_GOT32:
              *r_type_p = BFD_RELOC_SH_GOT20;
              break;
 
@@ -3313,7 +3313,7 @@ bool
 sh_fix_adjustable (fixS *fixP)
 {
   if (fixP->fx_r_type == BFD_RELOC_32_PLT_PCREL
-      || fixP->fx_r_type == BFD_RELOC_32_GOT_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_SH_GOTFUNCDESC
@@ -3670,7 +3670,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
     case BFD_RELOC_SH_TLS_IE_32:
       S_SET_THREAD_LOCAL (fixP->fx_addsy);
       /* Fallthrough */
-    case BFD_RELOC_32_GOT_PCREL:
+    case BFD_RELOC_SH_GOT32:
     case BFD_RELOC_SH_GOT20:
     case BFD_RELOC_SH_GOTPLT32:
     case BFD_RELOC_SH_GOTFUNCDESC:
@@ -3962,7 +3962,7 @@ sh_parse_name (char const *name,
   else if ((next_end = sh_end_of_match (next + 1, "GOTPLT")))
     reloc_type = BFD_RELOC_SH_GOTPLT32;
   else if ((next_end = sh_end_of_match (next + 1, "GOT")))
-    reloc_type = BFD_RELOC_32_GOT_PCREL;
+    reloc_type = BFD_RELOC_SH_GOT32;
   else if ((next_end = sh_end_of_match (next + 1, "PLT")))
     reloc_type = BFD_RELOC_32_PLT_PCREL;
   else if ((next_end = sh_end_of_match (next + 1, "TLSGD")))
index 0c3db2cb95832ef9c1764160be742b3498e46be4..404662578ed73adc9cd986dc4cb36285f6ff1094 100644 (file)
@@ -202,7 +202,7 @@ extern bool sh_fix_adjustable (struct fix *);
 #define TC_FORCE_RELOCATION_LOCAL(FIX)                 \
   (GENERIC_FORCE_RELOCATION_LOCAL (FIX)                        \
    || (FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL       \
-   || (FIX)->fx_r_type == BFD_RELOC_32_GOT_PCREL       \
+   || (FIX)->fx_r_type == BFD_RELOC_SH_GOT32           \
    || (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC)
 
 #define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG)                \