]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Delete _bfd_elf_get_dynamic_reloc_section
authorAlan Modra <amodra@gmail.com>
Fri, 1 May 2026 01:23:03 +0000 (10:53 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 1 May 2026 12:48:44 +0000 (22:18 +0930)
When _bfd_elf_make_dynamic_reloc_section is used by a target's
check_relocs, it guarantees elf_section_data(sec)->sreloc is set to
the dynamic reloc section associated with the input section.  That
means there is no need to later search for the dynamic reloc section
via name lookup.

* elflink.c (_bfd_elf_get_dynamic_reloc_section): Delete.
* elf-bfd.h (_bfd_elf_get_dynamic_reloc_section): Don't declare.
* elf-m10300.c (mn10300_elf_final_link_relocate): Get dynamic
reloc section via elf_section_data.
* elf32-arc.c (elf_arc_relocate_section): Likewise.
* elf32-arm.c (elf32_arm_final_link_relocate): Likewise.
* elf32-cris.c (cris_elf_relocate_section): Likewise.
(elf_cris_discard_excess_dso_dynamics): Likewise.
* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
* elf32-sh.c (sh_elf_relocate_section): Likewise.
* elf32-vax.c (elf_vax_relocate_section): Likewise.

bfd/elf-bfd.h
bfd/elf-m10300.c
bfd/elf32-arc.c
bfd/elf32-arm.c
bfd/elf32-cris.c
bfd/elf32-m32r.c
bfd/elf32-sh.c
bfd/elf32-vax.c
bfd/elflink.c

index 3d2fad49aa4c4e53dbb90467e8a9d5130a9d3dcb..41be72326649c5487c1ab3ab1c9ede455d590155 100644 (file)
@@ -2497,8 +2497,6 @@ extern long _bfd_elf_get_reloc_upper_bound
   (bfd *, sec_ptr) ATTRIBUTE_HIDDEN;
 extern long _bfd_elf_canonicalize_reloc
   (bfd *, sec_ptr, arelent **, asymbol **) ATTRIBUTE_HIDDEN;
-extern asection * _bfd_elf_get_dynamic_reloc_section
-  (bfd *, asection *, bool) ATTRIBUTE_HIDDEN;
 extern asection * _bfd_elf_make_dynamic_reloc_section
   (asection *, bfd *, unsigned int, bfd *, bool) ATTRIBUTE_HIDDEN;
 extern long _bfd_elf_get_dynamic_reloc_upper_bound
index 357e65f914d6a701853334f5e2021e0560205fe5..0740a26c2196f23f7682c7534fcb842c26deed52 100644 (file)
@@ -1431,7 +1431,6 @@ mn10300_elf_final_link_relocate (reloc_howto_type *howto,
   dynobj = elf_hash_table (info)->dynobj;
   sgot   = NULL;
   splt   = NULL;
-  sreloc = NULL;
 
   switch (r_type)
     {
@@ -1531,13 +1530,9 @@ mn10300_elf_final_link_relocate (reloc_howto_type *howto,
          /* When generating a shared object, these relocations are
             copied into the output file to be resolved at run
             time.  */
+         sreloc = elf_section_data (input_section)->sreloc;
          if (sreloc == NULL)
-           {
-             sreloc = _bfd_elf_get_dynamic_reloc_section
-               (input_bfd, input_section, /*rela?*/ true);
-             if (sreloc == NULL)
-               return false;
-           }
+           return false;
 
          skip = false;
 
index ed58d634157032b396fc40cdacfbc02f82a2a430..cf0bc66279025c2d9349aba602ae8dc2aba54b7a 100644 (file)
@@ -1812,9 +1812,7 @@ elf_arc_relocate_section (bfd *                     output_bfd,
                bfd_byte *loc;
                bool skip = false;
                bool relocate = false;
-               asection *sreloc = _bfd_elf_get_dynamic_reloc_section
-                                (input_bfd, input_section,
-                                 /*RELA*/ true);
+               asection *sreloc = elf_section_data (input_section)->sreloc;
 
                BFD_ASSERT (sreloc != NULL);
 
index c3cb929658189ba6d3903aebfdd15f0e8a02bf37..aeef471cb06b889fccba41b124ad918f1ff44441 100644 (file)
@@ -10211,7 +10211,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
   bfd_vma *                    local_tlsdesc_gotents;
   asection *                   sgot;
   asection *                   splt;
-  asection *                   sreloc = NULL;
+  asection *                   sreloc;
   asection *                   srelgot;
   bfd_vma                      addend;
   bfd_signed_vma               signed_addend;
@@ -10502,16 +10502,6 @@ elf32_arm_final_link_relocate (reloc_howto_type *          howto,
            }
 
          *unresolved_reloc_p = false;
-
-         if (sreloc == NULL && globals->root.dynamic_sections_created)
-           {
-             sreloc = _bfd_elf_get_dynamic_reloc_section (input_bfd, input_section,
-                                                          ! globals->use_rel);
-
-             if (sreloc == NULL)
-               return bfd_reloc_notsupported;
-           }
-
          skip = false;
          relocate = false;
 
@@ -10565,7 +10555,12 @@ elf32_arm_final_link_relocate (reloc_howto_type *          howto,
          if (isrofixup)
            arm_elf_add_rofixup (output_bfd, globals->srofixup, outrel.r_offset);
          else
-           elf32_arm_add_dynreloc (output_bfd, info, sreloc, &outrel);
+           {
+             sreloc = elf_section_data (input_section)->sreloc;
+             if (sreloc == NULL)
+               return bfd_reloc_notsupported;
+             elf32_arm_add_dynreloc (output_bfd, info, sreloc, &outrel);
+           }
 
          /* If this reloc is against an external symbol, we do not want to
             fiddle with the addend.  Otherwise, we need to include the symbol
index 4e89a30eddb0b31114d87155c35a5efcc25f8dc8..8e5e82d2ce8a425c5afc6115782a8960e4793f5f 100644 (file)
@@ -1457,18 +1457,14 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                 are copied into the output file to be resolved at run
                 time.  */
 
+             sreloc = elf_section_data (input_section)->sreloc;
+             /* The section should have been created in cris_elf_check_relocs,
+                but that function will not be called for objects which fail in
+                cris_elf_merge_private_bfd_data.  */
              if (sreloc == NULL)
                {
-                 sreloc = _bfd_elf_get_dynamic_reloc_section
-                   (dynobj, input_section, /*rela?*/ true);
-                 /* The section should have been created in cris_elf_check_relocs,
-                    but that function will not be called for objects which fail in
-                    cris_elf_merge_private_bfd_data.  */
-                 if (sreloc == NULL)
-                   {
-                     bfd_set_error (bfd_error_bad_value);
-                     return false;
-                   }
+                 bfd_set_error (bfd_error_bad_value);
+                 return false;
                }
 
              skip = false;
@@ -3678,11 +3674,7 @@ elf_cris_discard_excess_dso_dynamics (struct elf_cris_link_hash_entry *h,
     {
       for (s = h->pcrel_relocs_copied; s != NULL; s = s->next)
        {
-         asection *sreloc
-           = _bfd_elf_get_dynamic_reloc_section (elf_hash_table (info)
-                                                 ->dynobj,
-                                                 s->section,
-                                                 /*rela?*/ true);
+         asection *sreloc = elf_section_data (s->section)->sreloc;
          sreloc->size -= s->count * sizeof (Elf32_External_Rela);
        }
       return true;
index 68ef7122368ae12a24eb0c2a6311984c5c3cda30..abba55a7d16c9876007c219b47b062f12d26062f 100644 (file)
@@ -2237,7 +2237,6 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   sgot = htab->sgot;
   splt = htab->splt;
-  sreloc = NULL;
 
   rel = relocs;
   relend = relocs + input_section->reloc_count;
@@ -2694,13 +2693,9 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                  /* When generating a shared object, these relocations
                     are copied into the output file to be resolved at run
                     time.  */
+                 sreloc = elf_section_data (input_section)->sreloc;
                  if (sreloc == NULL)
-                   {
-                     sreloc = _bfd_elf_get_dynamic_reloc_section
-                       (input_bfd, input_section, /*rela?*/ true);
-                     if (sreloc == NULL)
-                       return false;
-                   }
+                   return false;
 
                  skip = false;
                  relocate = false;
index 5dd019512edc0eee1b590377be0b5bba87bb889d..ebb36b7228e9809407cad994a45af697539a3a6a 100644 (file)
@@ -3394,7 +3394,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
   asection *sgot = NULL;
   asection *sgotplt = NULL;
   asection *splt = NULL;
-  asection *sreloc = NULL;
+  asection *sreloc;
   asection *srelgot = NULL;
   bool is_vxworks_tls;
   unsigned isec_segment, got_segment, plt_segment, check_segment[2];
@@ -3864,13 +3864,9 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                 are copied into the output file to be resolved at run
                 time.  */
 
+             sreloc = elf_section_data (input_section)->sreloc;
              if (sreloc == NULL)
-               {
-                 sreloc = _bfd_elf_get_dynamic_reloc_section
-                   (input_bfd, input_section, /*rela?*/ true);
-                 if (sreloc == NULL)
-                   return false;
-               }
+               return false;
 
              skip = false;
              relocate = false;
@@ -4974,13 +4970,9 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                goto final_link_relocate;
              }
 
+           sreloc = elf_section_data (input_section)->sreloc;
            if (sreloc == NULL)
-             {
-               sreloc = _bfd_elf_get_dynamic_reloc_section
-                 (input_bfd, input_section, /*rela?*/ true);
-               if (sreloc == NULL)
-                 return false;
-             }
+             return false;
 
            if (h == NULL || h->dynindx == -1)
              indx = 0;
index 6c278d4656678464fe2554076c746db68da9ce7b..e6329bcef7e41d81fb11746ac47732110f5b7900 100644 (file)
@@ -1226,7 +1226,6 @@ elf_vax_relocate_section (bfd *output_bfd,
   sgot = NULL;
   splt = NULL;
   sgotplt = NULL;
-  sreloc = NULL;
 
   rel = relocs;
   relend = relocs + input_section->reloc_count;
@@ -1423,13 +1422,9 @@ elf_vax_relocate_section (bfd *output_bfd,
              /* When generating a shared object, these relocations
                 are copied into the output file to be resolved at run
                 time.  */
+             sreloc = elf_section_data (input_section)->sreloc;
              if (sreloc == NULL)
-               {
-                 sreloc = _bfd_elf_get_dynamic_reloc_section
-                   (input_bfd, input_section, /*rela?*/ true);
-                 if (sreloc == NULL)
-                   return false;
-               }
+               return false;
 
              skip = false;
              relocate = false;
index a6cada099f0a36820602408568836ccb0c01315e..80938f043d47b342197f6371f38193a6a43f4acd 100644 (file)
@@ -15584,34 +15584,6 @@ get_dynamic_reloc_section_name (bfd *       abfd,
   return name;
 }
 
-/* Returns the dynamic reloc section associated with SEC.
-   If necessary compute the name of the dynamic reloc section based
-   on SEC's name (looked up in ABFD's string table) and the setting
-   of IS_RELA.  */
-
-asection *
-_bfd_elf_get_dynamic_reloc_section (bfd *abfd,
-                                   asection *sec,
-                                   bool is_rela)
-{
-  asection *reloc_sec = elf_section_data (sec)->sreloc;
-
-  if (reloc_sec == NULL)
-    {
-      const char *name = get_dynamic_reloc_section_name (abfd, sec, is_rela);
-
-      if (name != NULL)
-       {
-         reloc_sec = bfd_get_linker_section (abfd, name);
-
-         if (reloc_sec != NULL)
-           elf_section_data (sec)->sreloc = reloc_sec;
-       }
-    }
-
-  return reloc_sec;
-}
-
 /* Returns the dynamic reloc section associated with SEC.  If the
    section does not exist it is created and attached to the DYNOBJ
    bfd and stored in the SRELOC field of SEC's elf_section_data