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.
This commit is contained in:
H.J. Lu 2020-06-03 07:07:09 -07:00
parent ad172eaa4f
commit d49e5065ed
23 changed files with 141 additions and 572 deletions

View File

@ -1,3 +1,68 @@
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> 2020-06-03 H.J. Lu <hongjiu.lu@intel.com>
PR ld/26067 PR ld/26067

View File

@ -2876,6 +2876,8 @@ extern unsigned int _bfd_elf_symbol_section_index
extern asection *_bfd_elf_readonly_dynrelocs extern asection *_bfd_elf_readonly_dynrelocs
(struct elf_link_hash_entry *); (struct elf_link_hash_entry *);
extern bfd_boolean _bfd_elf_maybe_set_textrel
(struct elf_link_hash_entry *, void *);
/* Large common section. */ /* Large common section. */
extern asection _bfd_elf_large_com_section; extern asection _bfd_elf_large_com_section;

View File

@ -16671,34 +16671,6 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf)
return TRUE; 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 void
bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *info, bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *info,
int byteswap_code) 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -1893,33 +1893,6 @@ csky_allocate_dynrelocs (struct elf_link_hash_entry *h, PTR inf)
return TRUE; 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. */ /* Set the sizes of the dynamic sections. */
static bfd_boolean 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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 if ((info->flags & DF_TEXTREL) != 0
&& !add_dynamic_entry (DT_TEXTREL, 0)) && !add_dynamic_entry (DT_TEXTREL, 0))

View File

@ -2042,33 +2042,6 @@ clobber_millicode_symbols (struct elf_link_hash_entry *eh,
return TRUE; 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. */ /* Set the sizes of the dynamic sections. */
static bfd_boolean 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -1914,33 +1914,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
return TRUE; 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. */ /* Set the sizes of the dynamic sections. */
static bfd_boolean 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -1978,33 +1978,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
return TRUE; 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. */ /* Set the sizes of the dynamic sections. */
static bfd_boolean 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -2715,33 +2715,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
return TRUE; 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. */ /* Set the sizes of the dynamic sections. */
static bfd_boolean 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -4252,33 +4252,6 @@ elf32_nds32_add_dynreloc (bfd *output_bfd,
bfd_elf32_swap_reloca_out (output_bfd, rel, loc); 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. */ /* Set the sizes of the dynamic sections. */
static bfd_boolean 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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); (void *) info);
if ((info->flags & DF_TEXTREL) != 0) if ((info->flags & DF_TEXTREL) != 0)

View File

@ -2919,33 +2919,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
return TRUE; 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. */ /* Set the sizes of the dynamic sections. */
static bfd_boolean 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -5423,33 +5423,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
return TRUE; 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[] = static const unsigned char glink_eh_frame_cie[] =
{ {
0, 0, 0, 16, /* length. */ 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 /* If any dynamic relocs apply to a read-only section, then we
need a DT_TEXTREL entry. */ need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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); info);
if ((info->flags & DF_TEXTREL) != 0) if ((info->flags & DF_TEXTREL) != 0)

View File

@ -1777,33 +1777,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
return TRUE; 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. */ /* Set the sizes of the dynamic sections. */
static bfd_boolean 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -2926,33 +2926,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
return TRUE; 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, /* This function is called after all the input files have been read,
and the input sections have been assigned to output sections. and the input sections have been assigned to output sections.
It's a convenient place to determine the PLT style. */ 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -3170,33 +3170,6 @@ elf32_tic6x_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
return TRUE; 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. */ /* Set the sizes of the dynamic sections. */
static bfd_boolean 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -2168,33 +2168,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
return TRUE; 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 /* Return true if the dynamic symbol for a given section should be
omitted when creating a shared library. */ 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if (info->flags & DF_TEXTREL)
{ {

View File

@ -9862,33 +9862,6 @@ size_global_entry_stubs (struct elf_link_hash_entry *h, void *inf)
return TRUE; 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. */ /* Set the sizes of the dynamic sections. */
static bfd_boolean 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -1713,33 +1713,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h,
return TRUE; 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. */ /* Set the sizes of the dynamic sections. */
static bfd_boolean 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -14841,3 +14841,37 @@ _bfd_elf_readonly_dynrelocs (struct elf_link_hash_entry *h)
} }
return NULL; 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;
}

View File

@ -8856,33 +8856,6 @@ elfNN_aarch64_allocate_local_ifunc_dynrelocs (void **slot, void *inf)
return elfNN_aarch64_allocate_ifunc_dynrelocs (h, 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 /* This is the most important function of all . Innocuosly named
though ! */ 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {

View File

@ -1088,33 +1088,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
return TRUE; 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 static bfd_boolean
riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if (info->flags & DF_TEXTREL)
{ {

View File

@ -2359,33 +2359,6 @@ allocate_local_dynrelocs (void **slot, void *inf)
return allocate_dynrelocs (h, 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 /* Return true if the dynamic symbol for a given section should be
omitted when creating a shared library. */ 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if (info->flags & DF_TEXTREL)
{ {

View File

@ -2414,33 +2414,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
return TRUE; 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 /* Return true if the dynamic symbol for a given section should be
omitted when creating a shared library. */ 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if (info->flags & DF_TEXTREL)
{ {

View File

@ -532,44 +532,6 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
return TRUE; 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 /* Allocate space in .plt, .got and associated reloc sections for
local dynamic relocs. */ 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, /* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */ then we need a DT_TEXTREL entry. */
if ((info->flags & DF_TEXTREL) == 0) 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) if ((info->flags & DF_TEXTREL) != 0)
{ {