From d49e5065ed43ec88627fd8cc6ab9e45fcc0e538a Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 3 Jun 2020 07:07:09 -0700 Subject: [PATCH] ELF: Consolidate maybe_set_textrel All maybe_set_textrel implementations are the same. Consolidate them to a single _bfd_elf_maybe_set_textrel. * elf-bfd.h (_bfd_elf_maybe_set_textrel): New * elf32-arm.c (maybe_set_textrel): Removed. (elf32_arm_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-csky.c (maybe_set_textrel): Removed. (csky_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-hppa.c (maybe_set_textrel): Removed. (elf32_hppa_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-lm32.c (maybe_set_textrel): Removed. (lm32_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-m32r.c (maybe_set_textrel): Removed. (m32r_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-metag.c (maybe_set_textrel): Removed. (elf_metag_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-nds32.c (maybe_set_textrel): Removed. (nds32_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-or1k.c (maybe_set_textrel): Removed. (or1k_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-ppc.c (maybe_set_textrel): Removed. (ppc_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-s390.c (maybe_set_textrel): Removed. (elf_s390_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-sh.c (maybe_set_textrel): Removed. (sh_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-tic6x.c (maybe_set_textrel): Removed. (elf32_tic6x_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf32-tilepro.c (maybe_set_textrel): Removed. (tilepro_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf64-ppc.c (maybe_set_textrel): Removed. (ppc64_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elf64-s390.c (maybe_set_textrel): Removed. (elf_s390_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elfnn-aarch64.c (maybe_set_textrel): Removed. (elfNN_aarch64_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elfnn-riscv.c (maybe_set_textrel): Removed. (riscv_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elfxx-sparc.c (maybe_set_textrel): Removed. (_bfd_sparc_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elfxx-tilegx.c (maybe_set_textrel): Removed. (tilegx_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elfxx-x86.c (maybe_set_textrel): Removed. (_bfd_x86_elf_size_dynamic_sections): Replace maybe_set_textrel with _bfd_elf_maybe_set_textrel. * elflink.c (_bfd_elf_maybe_set_textrel): New. --- bfd/ChangeLog | 65 +++++++++++++++++++++++++++++++++++++++++++++ bfd/elf-bfd.h | 2 ++ bfd/elf32-arm.c | 31 ++------------------- bfd/elf32-csky.c | 30 ++------------------- bfd/elf32-hppa.c | 30 ++------------------- bfd/elf32-lm32.c | 30 ++------------------- bfd/elf32-m32r.c | 30 ++------------------- bfd/elf32-metag.c | 30 ++------------------- bfd/elf32-nds32.c | 30 ++------------------- bfd/elf32-or1k.c | 30 ++------------------- bfd/elf32-ppc.c | 30 ++------------------- bfd/elf32-s390.c | 30 ++------------------- bfd/elf32-sh.c | 30 ++------------------- bfd/elf32-tic6x.c | 30 ++------------------- bfd/elf32-tilepro.c | 30 ++------------------- bfd/elf64-ppc.c | 30 ++------------------- bfd/elf64-s390.c | 30 ++------------------- bfd/elflink.c | 34 ++++++++++++++++++++++++ bfd/elfnn-aarch64.c | 30 ++------------------- bfd/elfnn-riscv.c | 30 ++------------------- bfd/elfxx-sparc.c | 30 ++------------------- bfd/elfxx-tilegx.c | 30 ++------------------- bfd/elfxx-x86.c | 41 ++-------------------------- 23 files changed, 141 insertions(+), 572 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 0bafecef2fa..d215113495f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,68 @@ +2020-06-03 H.J. Lu + + * elf-bfd.h (_bfd_elf_maybe_set_textrel): New + * elf32-arm.c (maybe_set_textrel): Removed. + (elf32_arm_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-csky.c (maybe_set_textrel): Removed. + (csky_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-hppa.c (maybe_set_textrel): Removed. + (elf32_hppa_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-lm32.c (maybe_set_textrel): Removed. + (lm32_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-m32r.c (maybe_set_textrel): Removed. + (m32r_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-metag.c (maybe_set_textrel): Removed. + (elf_metag_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-nds32.c (maybe_set_textrel): Removed. + (nds32_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-or1k.c (maybe_set_textrel): Removed. + (or1k_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-ppc.c (maybe_set_textrel): Removed. + (ppc_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-s390.c (maybe_set_textrel): Removed. + (elf_s390_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-sh.c (maybe_set_textrel): Removed. + (sh_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-tic6x.c (maybe_set_textrel): Removed. + (elf32_tic6x_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf32-tilepro.c (maybe_set_textrel): Removed. + (tilepro_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf64-ppc.c (maybe_set_textrel): Removed. + (ppc64_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elf64-s390.c (maybe_set_textrel): Removed. + (elf_s390_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elfnn-aarch64.c (maybe_set_textrel): Removed. + (elfNN_aarch64_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elfnn-riscv.c (maybe_set_textrel): Removed. + (riscv_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elfxx-sparc.c (maybe_set_textrel): Removed. + (_bfd_sparc_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elfxx-tilegx.c (maybe_set_textrel): Removed. + (tilegx_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elfxx-x86.c (maybe_set_textrel): Removed. + (_bfd_x86_elf_size_dynamic_sections): Replace maybe_set_textrel + with _bfd_elf_maybe_set_textrel. + * elflink.c (_bfd_elf_maybe_set_textrel): New. + 2020-06-03 H.J. Lu PR ld/26067 diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 6b8b5660fb7..fbdd19ba21e 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2876,6 +2876,8 @@ extern unsigned int _bfd_elf_symbol_section_index extern asection *_bfd_elf_readonly_dynrelocs (struct elf_link_hash_entry *); +extern bfd_boolean _bfd_elf_maybe_set_textrel + (struct elf_link_hash_entry *, void *); /* Large common section. */ extern asection _bfd_elf_large_com_section; diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index fc67ca52077..8d184b5a094 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -16671,34 +16671,6 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - - return TRUE; -} - void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *info, int byteswap_code) @@ -17142,7 +17114,8 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->root, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->root, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c index 03e83d53a50..43828beed03 100644 --- a/bfd/elf32-csky.c +++ b/bfd/elf32-csky.c @@ -1893,33 +1893,6 @@ csky_allocate_dynrelocs (struct elf_link_hash_entry *h, PTR inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -2152,7 +2125,8 @@ csky_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->elf, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0 && !add_dynamic_entry (DT_TEXTREL, 0)) diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 106b5c83159..d131f1a0794 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -2042,33 +2042,6 @@ clobber_millicode_symbols (struct elf_link_hash_entry *eh, return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *eh, void *inf) -{ - asection *sec; - - if (eh->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (eh); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) inf; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, eh->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -2346,7 +2319,8 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->etab, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->etab, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index 5d09f2d350d..3c31dd44c85 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -1914,33 +1914,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -2132,7 +2105,8 @@ lm32_elf_size_dynamic_sections (bfd *output_bfd, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->root, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->root, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index afe0ee899cd..931e138b37a 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1978,33 +1978,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -2200,7 +2173,8 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->root, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->root, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c index d5e9a9d034e..7938b24d2a5 100644 --- a/bfd/elf32-metag.c +++ b/bfd/elf32-metag.c @@ -2715,33 +2715,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -2966,7 +2939,8 @@ elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->etab, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->etab, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index 4f7ea764691..01ea277426f 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -4252,33 +4252,6 @@ elf32_nds32_add_dynreloc (bfd *output_bfd, bfd_elf32_swap_reloca_out (output_bfd, rel, loc); } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -4552,7 +4525,8 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->root, maybe_set_textrel, + elf_link_hash_traverse (&htab->root, + _bfd_elf_maybe_set_textrel, (void *) info); if ((info->flags & DF_TEXTREL) != 0) diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index b141b45886d..ac62d630ab3 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -2919,33 +2919,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -3150,7 +3123,8 @@ or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->root, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->root, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 588b79781d8..0cb7f67504d 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -5423,33 +5423,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - static const unsigned char glink_eh_frame_cie[] = { 0, 0, 0, 16, /* length. */ @@ -5900,7 +5873,8 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (elf_hash_table (info), maybe_set_textrel, + elf_link_hash_traverse (elf_hash_table (info), + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 42f230d9b14..5bd63fe1c94 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -1777,33 +1777,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -2027,7 +2000,8 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->elf, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 0428829757f..9ec745be199 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -2926,33 +2926,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* This function is called after all the input files have been read, and the input sections have been assigned to output sections. It's a convenient place to determine the PLT style. */ @@ -3268,7 +3241,8 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->root, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->root, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c index f673fe191a6..d1ba4c2a93f 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -3170,33 +3170,6 @@ elf32_tic6x_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -3410,7 +3383,8 @@ elf32_tic6x_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->elf, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c index 9707a9e18e5..2d78f3c9c89 100644 --- a/bfd/elf32-tilepro.c +++ b/bfd/elf32-tilepro.c @@ -2168,33 +2168,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Return true if the dynamic symbol for a given section should be omitted when creating a shared library. */ @@ -2441,7 +2414,8 @@ tilepro_elf_size_dynamic_sections (bfd *output_bfd, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->elf, + _bfd_elf_maybe_set_textrel, info); if (info->flags & DF_TEXTREL) { diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 49fda96be7a..5f99d4344b7 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -9862,33 +9862,6 @@ size_global_entry_stubs (struct elf_link_hash_entry *h, void *inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *inf) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) inf; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo (_("%pB: dynamic relocation against `%pT'" - " in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -10264,7 +10237,8 @@ ppc64_elf_size_dynamic_sections (bfd *output_bfd, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->elf, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 197e9bc68c7..5b95b5f814a 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -1713,33 +1713,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Set the sizes of the dynamic sections. */ static bfd_boolean @@ -1981,7 +1954,8 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->elf, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elflink.c b/bfd/elflink.c index a2b40ccb046..ce6282a9dcf 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -14841,3 +14841,37 @@ _bfd_elf_readonly_dynrelocs (struct elf_link_hash_entry *h) } return NULL; } + +/* Set DF_TEXTREL if we find any dynamic relocs that apply to + read-only sections. */ + +bfd_boolean +_bfd_elf_maybe_set_textrel (struct elf_link_hash_entry *h, void *inf) +{ + asection *sec; + + if (h->root.type == bfd_link_hash_indirect) + return TRUE; + + sec = _bfd_elf_readonly_dynrelocs (h); + if (sec != NULL) + { + struct bfd_link_info *info = (struct bfd_link_info *) inf; + + info->flags |= DF_TEXTREL; + /* xgettext:c-format */ + info->callbacks->minfo (_("%pB: dynamic relocation against `%pT' " + "in read-only section `%pA'\n"), + sec->owner, h->root.root.string, sec); + + if (bfd_link_textrel_check (info)) + /* xgettext:c-format */ + info->callbacks->einfo (_("%P: %pB: warning: relocation against `%s' " + "in read-only section `%pA'\n"), + sec->owner, h->root.root.string, sec); + + /* Not an error, just cut short the traversal. */ + return FALSE; + } + return TRUE; +} diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 71634ffba77..64215f71850 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -8856,33 +8856,6 @@ elfNN_aarch64_allocate_local_ifunc_dynrelocs (void **slot, void *inf) return elfNN_aarch64_allocate_ifunc_dynrelocs (h, inf); } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* This is the most important function of all . Innocuosly named though ! */ @@ -9186,7 +9159,8 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->root, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->root, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 3c972e20ab5..163c4d9f745 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -1088,33 +1088,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - static bfd_boolean riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) { @@ -1321,7 +1294,8 @@ riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->elf, + _bfd_elf_maybe_set_textrel, info); if (info->flags & DF_TEXTREL) { diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c index e4700e31069..5ef29eac283 100644 --- a/bfd/elfxx-sparc.c +++ b/bfd/elfxx-sparc.c @@ -2359,33 +2359,6 @@ allocate_local_dynrelocs (void **slot, void *inf) return allocate_dynrelocs (h, inf); } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Return true if the dynamic symbol for a given section should be omitted when creating a shared library. */ @@ -2640,7 +2613,8 @@ _bfd_sparc_elf_size_dynamic_sections (bfd *output_bfd, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->elf, + _bfd_elf_maybe_set_textrel, info); if (info->flags & DF_TEXTREL) { diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c index 07288a13e8c..9d8b42e1de0 100644 --- a/bfd/elfxx-tilegx.c +++ b/bfd/elfxx-tilegx.c @@ -2414,33 +2414,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Return true if the dynamic symbol for a given section should be omitted when creating a shared library. */ @@ -2681,7 +2654,8 @@ tilegx_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->elf, + _bfd_elf_maybe_set_textrel, info); if (info->flags & DF_TEXTREL) { diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index b8c616f4d84..035b5c5c64c 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -532,44 +532,6 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return TRUE; } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *inf) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - /* Skip local IFUNC symbols. */ - if (h->forced_local && h->type == STT_GNU_IFUNC) - return TRUE; - - sec = _bfd_elf_readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) inf; - - info->flags |= DF_TEXTREL; - /* xgettext:c-format */ - info->callbacks->minfo (_("%pB: dynamic relocation against `%pT' " - "in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - if (bfd_link_textrel_check (info)) - /* xgettext:c-format */ - info->callbacks->einfo (_("%P: %pB: warning: relocation against `%s' " - "in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* Allocate space in .plt, .got and associated reloc sections for local dynamic relocs. */ @@ -1450,7 +1412,8 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd, /* If any dynamic relocs apply to a read-only section, then we need a DT_TEXTREL entry. */ if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info); + elf_link_hash_traverse (&htab->elf, + _bfd_elf_maybe_set_textrel, info); if ((info->flags & DF_TEXTREL) != 0) { -- 2.30.2