[binutils-gdb] Delete _bfd_elf_get_dynamic_reloc_section
Alan Modra via Binutils-cvs <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c38fc9a9d4958b45cdc9a53b4f6fe28126779705 commit c38fc9a9d4958b45cdc9a53b4f6fe28126779705 Author: Alan Modra <[email protected]> Date: Fri May 1 10:53:03 2026 +0930 Delete _bfd_elf_get_dynamic_reloc_section 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. Diff: --- bfd/elf-bfd.h | 2 -- bfd/elf-m10300.c | 9 ++------- bfd/elf32-arc.c | 4 +--- bfd/elf32-arm.c | 19 +++++++------------ bfd/elf32-cris.c | 22 +++++++--------------- bfd/elf32-m32r.c | 9 ++------- bfd/elf32-sh.c | 18 +++++------------- bfd/elf32-vax.c | 9 ++------- bfd/elflink.c | 28 ---------------------------- 9 files changed, 26 insertions(+), 94 deletions(-) diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 3d2fad49aa4..41be7232664 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -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 diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index 357e65f914d..0740a26c219 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -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; diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index ed58d634157..cf0bc662790 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -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); diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index c3cb9296581..aeef471cb06 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -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 diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 4e89a30eddb..8e5e82d2ce8 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -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; diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 68ef7122368..abba55a7d16 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -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; diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 5dd019512ed..ebb36b7228e 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -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; diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index 6c278d46566..e6329bcef7e 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -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; diff --git a/bfd/elflink.c b/bfd/elflink.c index a6cada099f0..80938f043d4 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -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