aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-06-03 07:07:09 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-06-03 07:07:24 -0700
commitd49e5065ed43ec88627fd8cc6ab9e45fcc0e538a (patch)
tree0be2a8afdd4b29f286a9aa6ccae341a3441f8073
parentad172eaa4f5ff973890a6c37574946cecf0668b0 (diff)
downloadgdb-d49e5065ed43ec88627fd8cc6ab9e45fcc0e538a.zip
gdb-d49e5065ed43ec88627fd8cc6ab9e45fcc0e538a.tar.gz
gdb-d49e5065ed43ec88627fd8cc6ab9e45fcc0e538a.tar.bz2
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.
-rw-r--r--bfd/ChangeLog65
-rw-r--r--bfd/elf-bfd.h2
-rw-r--r--bfd/elf32-arm.c31
-rw-r--r--bfd/elf32-csky.c30
-rw-r--r--bfd/elf32-hppa.c30
-rw-r--r--bfd/elf32-lm32.c30
-rw-r--r--bfd/elf32-m32r.c30
-rw-r--r--bfd/elf32-metag.c30
-rw-r--r--bfd/elf32-nds32.c30
-rw-r--r--bfd/elf32-or1k.c30
-rw-r--r--bfd/elf32-ppc.c30
-rw-r--r--bfd/elf32-s390.c30
-rw-r--r--bfd/elf32-sh.c30
-rw-r--r--bfd/elf32-tic6x.c30
-rw-r--r--bfd/elf32-tilepro.c30
-rw-r--r--bfd/elf64-ppc.c30
-rw-r--r--bfd/elf64-s390.c30
-rw-r--r--bfd/elflink.c34
-rw-r--r--bfd/elfnn-aarch64.c30
-rw-r--r--bfd/elfnn-riscv.c30
-rw-r--r--bfd/elfxx-sparc.c30
-rw-r--r--bfd/elfxx-tilegx.c30
-rw-r--r--bfd/elfxx-x86.c41
23 files changed, 141 insertions, 572 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 0bafece..d215113 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,70 @@
2020-06-03 H.J. Lu <hongjiu.lu@intel.com>
+ * 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 <hongjiu.lu@intel.com>
+
PR ld/26067
* elf32-arm.c (elf32_arm_copy_indirect_symbol): Don't copy
dyn_relocs.
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 6b8b566..fbdd19b 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 fc67ca5..8d184b5 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 03e83d5..43828be 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 106b5c8..d131f1a 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 5d09f2d..3c31dd4 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 afe0ee8..931e138 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 d5e9a9d..7938b24 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 4f7ea76..01ea277 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 b141b45..ac62d63 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 588b797..0cb7f67 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 42f230d..5bd63fe 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 0428829..9ec745b 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 f673fe1..d1ba4c2 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 9707a9e..2d78f3c9 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 49fda96..5f99d43 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 197e9bc..5b95b5f 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 a2b40cc..ce6282a 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 71634ff..64215f7 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 3c972e2..163c4d9 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 e4700e3..5ef29ea 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 07288a1..9d8b42e 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 b8c616f..035b5c5 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)
{