This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH]: sparc: Don't output PLT entries/relocs for unref'd STT_GNU_IFUNC in shared objects.
- From: David Miller <davem at davemloft dot net>
- To: binutils at sourceware dot org
- Date: Thu, 25 Feb 2010 23:40:03 -0800 (PST)
- Subject: [PATCH]: sparc: Don't output PLT entries/relocs for unref'd STT_GNU_IFUNC in shared objects.
While testing support for multiarch versions of memset/bzero/memcpy
in glibc on sparc I noticed a bug in my STT_GNU_IFUNC implementation.
Even though no references to the symbols occur in the shared object,
the PLT entries and associated relocations were still being emitted.
This fixes that bug.
Ok to commit?
bfd/
2010-02-25 David S. Miller <davem@davemloft.net>
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): When STT_GNU_IFUNC and
h->def_regular, set h->ref_regular.
(allocate_dynrelocs): Only force output of STT_GNU_IFUNC plt entries
and dynamic relocations if h->ref_regular.
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index 1947d1a..2137df0 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -1277,7 +1277,10 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
if (h && h->type == STT_GNU_IFUNC)
{
if (h->def_regular)
- h->plt.refcount += 1;
+ {
+ h->ref_regular = 1;
+ h->plt.refcount += 1;
+ }
}
/* Compatibility with old R_SPARC_REV32 reloc conflicting
@@ -2022,7 +2025,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, PTR inf)
if ((htab->elf.dynamic_sections_created
&& h->plt.refcount > 0)
|| (h->type == STT_GNU_IFUNC
- && h->def_regular))
+ && h->def_regular
+ && h->ref_regular))
{
/* Make sure this symbol is output as a dynamic symbol.
Undefined weak syms won't yet be marked as dynamic. */
@@ -2034,7 +2038,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, PTR inf)
}
if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h)
- || h->type == STT_GNU_IFUNC)
+ || (h->type == STT_GNU_IFUNC
+ && h->def_regular))
{
asection *s = htab->elf.splt;