diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2fa19f8130..64f01ef5ef 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,89 @@ +2020-06-03 H.J. Lu + + PR ld/26067 + * elf-bfd.h (_bfd_elf_readonly_dynrelocs): New. + * elf32-arm.c (readonly_dynrelocs): Removed. + (maybe_set_textrel): Replace readonly_dynrelocs with + _bfd_elf_readonly_dynrelocs. + * elf32-csky.c (readonly_dynrelocs): Removed. + (maybe_set_textrel): Replace readonly_dynrelocs with + _bfd_elf_readonly_dynrelocs. + * elf32-hppa.c(readonly_dynrelocs): Removed. + (alias_readonly_dynrelocs): Replace readonly_dynrelocs with + _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elf32-lm32.c (readonly_dynrelocs): Removed. + (lm32_elf_adjust_dynamic_symbol): Replace readonly_dynrelocs + with _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elf32-m32r.c (readonly_dynrelocs): Removed. + (m32r_elf_adjust_dynamic_symbol): Replace readonly_dynrelocs + with _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elf32-metag.c (readonly_dynrelocs): Removed. + (elf_metag_adjust_dynamic_symbol): Replace readonly_dynrelocs + with _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elf32-microblaze.c (readonly_dynrelocs): Removed. + (microblaze_elf_adjust_dynamic_symbol): Replace readonly_dynrelocs + with _bfd_elf_readonly_dynrelocs. + * elf32-nds32.c (readonly_dynrelocs): Removed. + (nds32_elf_adjust_dynamic_symbol): Replace readonly_dynrelocs + with _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elf32-or1k.c (readonly_dynrelocs): Removed. + (or1k_elf_adjust_dynamic_symbol): Replace readonly_dynrelocs + with _bfd_elf_readonly_dynrelocs. + * elf32-ppc.c (readonly_dynrelocs): Removed. + (alias_readonly_dynrelocs): Replace readonly_dynrelocs with + _bfd_elf_readonly_dynrelocs. + (ppc_elf_adjust_dynamic_symbol): Likewise. + (maybe_set_textrel): Likewise. + * elf32-s390.c (readonly_dynrelocs): Removed. + (elf_s390_adjust_dynamic_symbol): Replace readonly_dynrelocs + with _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elf32-sh.c (readonly_dynrelocs): Removed. + (sh_elf_adjust_dynamic_symbol): Replace readonly_dynrelocs with + _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elf32-tic6x.c (readonly_dynrelocs): Removed. + (maybe_set_textrel): Replace readonly_dynrelocs with + _bfd_elf_readonly_dynrelocs. + * elf32-tilepro.c (readonly_dynrelocs): Removed. + (tilepro_elf_adjust_dynamic_symbol): Replace readonly_dynrelocs + with _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elf64-ppc.c (readonly_dynrelocs): Removed. + (alias_readonly_dynrelocs): Replace readonly_dynrelocs with + _bfd_elf_readonly_dynrelocs. + (ppc64_elf_adjust_dynamic_symbol): Likewise. + (maybe_set_textrel): Likewise. + * elf64-s390.c (readonly_dynrelocs): Removed. + (elf_s390_adjust_dynamic_symbol): Replace readonly_dynrelocs + with _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elflink.c (_bfd_elf_readonly_dynrelocs): New. + * elfnn-aarch64.c (readonly_dynrelocs): Removed. + (maybe_set_textrel): Replace readonly_dynrelocs with + _bfd_elf_readonly_dynrelocs. + * elfnn-riscv.c (readonly_dynrelocs): Removed. + (riscv_elf_adjust_dynamic_symbol): Replace readonly_dynrelocs + with _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elfxx-sparc.c (readonly_dynrelocs): Removed. + (_bfd_sparc_elf_adjust_dynamic_symbol): Replace + readonly_dynrelocs with _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elfxx-tilegx.c (readonly_dynrelocs): Removed. + (tilegx_elf_adjust_dynamic_symbol): Replace readonly_dynrelocs + with _bfd_elf_readonly_dynrelocs. + (maybe_set_textrel): Likewise. + * elfxx-x86.c (readonly_dynrelocs): Removed. + (maybe_set_textrel): Replace readonly_dynrelocs with + _bfd_elf_readonly_dynrelocs. + (_bfd_x86_elf_adjust_dynamic_symbol): Likewise. + 2020-06-03 H.J. Lu * elfxx-x86.h (GENERATE_DYNAMIC_RELOCATION_P): Silence diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index a979ad3f7b..6b8b5660fb 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2874,6 +2874,8 @@ extern bfd_boolean _bfd_elf_write_secondary_reloc_section extern unsigned int _bfd_elf_symbol_section_index (bfd *, elf_symbol_type *); +extern asection *_bfd_elf_readonly_dynrelocs + (struct elf_link_hash_entry *); /* Large common section. */ extern asection _bfd_elf_large_com_section; diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index f31eb8c9c7..69d3ba16ee 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -16089,23 +16089,6 @@ elf32_arm_find_inliner_info (bfd * abfd, return found; } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -16730,7 +16713,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c index 4be7ea8aa6..52708702a6 100644 --- a/bfd/elf32-csky.c +++ b/bfd/elf32-csky.c @@ -1893,21 +1893,6 @@ csky_allocate_dynrelocs (struct elf_link_hash_entry *h, PTR inf) return TRUE; } -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Set DF_TEXTREL if we find any dynamic relocs that apply to read-only sections. */ @@ -1919,7 +1904,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index ef32ba75cd..15100431c8 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -1654,23 +1654,6 @@ elf32_hppa_hide_symbol (struct bfd_link_info *info, } } -/* Find any dynamic relocs that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *eh) -{ - struct elf_dyn_relocs *hdh_p; - - for (hdh_p = eh->dyn_relocs; hdh_p != NULL; hdh_p = hdh_p->next) - { - asection *sec = hdh_p->sec->output_section; - - if (sec != NULL && (sec->flags & SEC_READONLY) != 0) - return hdh_p->sec; - } - return NULL; -} - /* Return true if we have dynamic relocs against H or any of its weak aliases, that apply to read-only sections. Cannot be used after size_dynamic_sections. */ @@ -1681,7 +1664,7 @@ alias_readonly_dynrelocs (struct elf_link_hash_entry *eh) struct elf32_hppa_link_hash_entry *hh = hppa_elf_hash_entry (eh); do { - if (readonly_dynrelocs (&hh->eh)) + if (_bfd_elf_readonly_dynrelocs (&hh->eh)) return TRUE; hh = hppa_elf_hash_entry (hh->eh.u.alias); } while (hh != NULL && &hh->eh != eh); @@ -2106,7 +2089,7 @@ maybe_set_textrel (struct elf_link_hash_entry *eh, void *inf) if (eh->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (eh); + sec = _bfd_elf_readonly_dynrelocs (eh); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) inf; diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index 0fe09bf44a..9e958617f8 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -1599,23 +1599,6 @@ lm32_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED, } } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -1702,7 +1685,7 @@ lm32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (0 && !readonly_dynrelocs (h)) + if (0 && !_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -1942,7 +1925,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index c147b713de..f719a532d4 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1700,23 +1700,6 @@ m32r_elf_copy_indirect_symbol (struct bfd_link_info *info, } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -1807,7 +1790,7 @@ m32r_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (0 && !readonly_dynrelocs (h)) + if (0 && !_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -2047,7 +2030,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c index bfd4b24f5f..b2cb918d4c 100644 --- a/bfd/elf32-metag.c +++ b/bfd/elf32-metag.c @@ -2435,23 +2435,6 @@ elf_metag_copy_indirect_symbol (struct bfd_link_info *info, _bfd_elf_link_hash_copy_indirect (info, eh_dir, eh_ind); } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -2527,7 +2510,7 @@ elf_metag_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (!readonly_dynrelocs (eh)) + if (!_bfd_elf_readonly_dynrelocs (eh)) { eh->non_got_ref = 0; return TRUE; @@ -2778,7 +2761,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c index 928098d2be..92c5e7c303 100644 --- a/bfd/elf32-microblaze.c +++ b/bfd/elf32-microblaze.c @@ -2614,23 +2614,6 @@ microblaze_elf_copy_indirect_symbol (struct bfd_link_info *info, _bfd_elf_link_hash_copy_indirect (info, dir, ind); } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - static bfd_boolean microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info, struct elf_link_hash_entry *h) @@ -2709,7 +2692,7 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (!readonly_dynrelocs (h)) + if (!_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index ee4eea7372..ad5225fcd7 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -3920,24 +3920,6 @@ nds32_elf_copy_indirect_symbol (struct bfd_link_info *info, _bfd_elf_link_hash_copy_indirect (info, dir, ind); } - -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -4023,7 +4005,7 @@ nds32_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (!readonly_dynrelocs (h)) + if (!_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -4315,7 +4297,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index 7afde7a59a..01556266c1 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -2547,25 +2547,6 @@ or1k_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED, } } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *sec_relocs; - - for (sec_relocs = h->dyn_relocs; - sec_relocs != NULL; - sec_relocs = sec_relocs->next) - { - asection *s = sec_relocs->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return sec_relocs->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -2652,7 +2633,7 @@ or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (!readonly_dynrelocs (h)) + if (!_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -2949,7 +2930,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index eecb15f0bc..588b79781d 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -4694,23 +4694,6 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED, return TRUE; } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Return true if we have dynamic relocs against H or any of its weak aliases, that apply to read-only sections. Cannot be used after size_dynamic_sections. */ @@ -4721,7 +4704,7 @@ alias_readonly_dynrelocs (struct elf_link_hash_entry *h) struct ppc_elf_link_hash_entry *eh = ppc_elf_hash_entry (h); do { - if (readonly_dynrelocs (&eh->elf)) + if (_bfd_elf_readonly_dynrelocs (&eh->elf)) return TRUE; eh = ppc_elf_hash_entry (eh->elf.u.alias); } while (eh != NULL && &eh->elf != h); @@ -4826,7 +4809,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))) && !htab->is_vxworks && !ppc_elf_hash_entry (h)->has_sda_refs - && !readonly_dynrelocs (h)) + && !_bfd_elf_readonly_dynrelocs (h)) { h->pointer_equality_needed = 0; /* If we haven't seen a branch reloc and the symbol @@ -5451,7 +5434,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index c42ce5e83f..c0db4f9bc8 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -1417,23 +1417,6 @@ elf_s390_adjust_gotplt (struct elf_s390_link_hash_entry *h) h->gotplt_refcount = -1; } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -1558,7 +1541,7 @@ elf_s390_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (ELIMINATE_COPY_RELOCS && !readonly_dynrelocs (h)) + if (ELIMINATE_COPY_RELOCS && !_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -1836,7 +1819,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index ebce61c017..29cdb3b569 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -2476,23 +2476,6 @@ sh_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) return TRUE; } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -2581,7 +2564,7 @@ sh_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (0 && !readonly_dynrelocs (h)) + if (0 && !_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -2954,7 +2937,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c index 5e0a7d04b7..f673fe191a 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -1963,23 +1963,6 @@ elf32_tic6x_fake_sections (bfd *abfd ATTRIBUTE_UNUSED, return TRUE; } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -3198,7 +3181,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c index 4b7446fa40..cb6cda8117 100644 --- a/bfd/elf32-tilepro.c +++ b/bfd/elf32-tilepro.c @@ -1871,23 +1871,6 @@ tilepro_elf_gc_mark_hook (asection *sec, return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -1973,7 +1956,7 @@ tilepro_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (!readonly_dynrelocs (h)) + if (!_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -2227,7 +2210,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 5903217077..49fda96be7 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -6356,23 +6356,6 @@ ppc64_elf_func_desc_adjust (bfd *obfd ATTRIBUTE_UNUSED, return TRUE; } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Return true if we have dynamic relocs against H or any of its weak aliases, that apply to read-only sections. Cannot be used after size_dynamic_sections. */ @@ -6383,7 +6366,7 @@ alias_readonly_dynrelocs (struct elf_link_hash_entry *h) struct ppc_link_hash_entry *eh = ppc_elf_hash_entry (h); do { - if (readonly_dynrelocs (&eh->elf)) + if (_bfd_elf_readonly_dynrelocs (&eh->elf)) return TRUE; eh = ppc_elf_hash_entry (eh->elf.u.alias); } @@ -6492,7 +6475,7 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, extra work in ld.so when resolving these symbols. */ if (global_entry_stub (h)) { - if (!readonly_dynrelocs (h)) + if (!_bfd_elf_readonly_dynrelocs (h)) { h->pointer_equality_needed = 0; /* If we haven't seen a branch reloc and the symbol @@ -6510,7 +6493,7 @@ ppc64_elf_adjust_dynamic_symbol (struct bfd_link_info *info, return TRUE; } else if (!h->needs_plt - && !readonly_dynrelocs (h)) + && !_bfd_elf_readonly_dynrelocs (h)) { /* If we haven't seen a branch reloc and the symbol isn't an ifunc then we don't need a plt entry. */ @@ -9890,7 +9873,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *inf) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) inf; diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index ec070ce4a3..07ec4709bb 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -1352,23 +1352,6 @@ elf_s390_adjust_gotplt (struct elf_s390_link_hash_entry *h) h->gotplt_refcount = -1; } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -1492,7 +1475,7 @@ elf_s390_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (ELIMINATE_COPY_RELOCS && !readonly_dynrelocs (h)) + if (ELIMINATE_COPY_RELOCS && !_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -1772,7 +1755,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elflink.c b/bfd/elflink.c index f87927f0bd..0d659c2025 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -14793,3 +14793,20 @@ bfd_elf_define_start_stop (struct bfd_link_info *info, } return NULL; } + +/* Find dynamic relocs for H that apply to read-only sections. */ + +asection * +_bfd_elf_readonly_dynrelocs (struct elf_link_hash_entry *h) +{ + struct elf_dyn_relocs *p; + + for (p = h->dyn_relocs; p != NULL; p = p->next) + { + asection *s = p->sec->output_section; + + if (s != NULL && (s->flags & SEC_READONLY) != 0) + return p->sec; + } + return NULL; +} diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index cbf10deaa4..f521786c8c 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -7381,23 +7381,6 @@ elfNN_aarch64_print_private_bfd_data (bfd *abfd, void *ptr) return TRUE; } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Return true if we need copy relocation against EH. */ static bfd_boolean @@ -8915,7 +8898,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index f6c92b8028..1b530d83df 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -782,23 +782,6 @@ riscv_elf_gc_mark_hook (asection *sec, return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -887,7 +870,7 @@ riscv_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (!readonly_dynrelocs (h)) + if (!_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -1147,7 +1130,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c index d6e3b6d437..633ac59bcc 100644 --- a/bfd/elfxx-sparc.c +++ b/bfd/elfxx-sparc.c @@ -1919,23 +1919,6 @@ _bfd_sparc_elf_fixup_symbol (struct bfd_link_info *info, return TRUE; } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -2032,7 +2015,7 @@ _bfd_sparc_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (!readonly_dynrelocs (h)) + if (!_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -2418,7 +2401,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c index 3e73e0b18e..75b4621276 100644 --- a/bfd/elfxx-tilegx.c +++ b/bfd/elfxx-tilegx.c @@ -2114,23 +2114,6 @@ tilegx_elf_gc_mark_hook (asection *sec, return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the dynamic object, but we're not including those sections. We have to @@ -2219,7 +2202,7 @@ tilegx_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (!readonly_dynrelocs (h)) + if (!_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE; @@ -2473,7 +2456,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) if (h->root.type == bfd_link_hash_indirect) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) info_p; diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index e385ddb539..c89559914e 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -532,23 +532,6 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return TRUE; } -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; -} - /* Set DF_TEXTREL if we find any dynamic relocs that apply to read-only sections. */ @@ -564,7 +547,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *inf) if (h->forced_local && h->type == STT_GNU_IFUNC) return TRUE; - sec = readonly_dynrelocs (h); + sec = _bfd_elf_readonly_dynrelocs (h); if (sec != NULL) { struct bfd_link_info *info = (struct bfd_link_info *) inf; @@ -2078,7 +2061,7 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* If we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (!readonly_dynrelocs (h)) + if (!_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; return TRUE;