summaryrefslogtreecommitdiff
path: root/bfd/elf-ifunc.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-01-06 18:45:03 +0000
committerH.J. Lu <hjl.tools@gmail.com>2011-01-06 18:45:03 +0000
commit758d4f6ed1fd32dec98ba5bdd578b6de9cfd1d0b (patch)
tree063ab86983f4bce0ca4fa08b1bdc8280204b4d17 /bfd/elf-ifunc.c
parent6b557042d624b74d3bb343cd59117331136c019b (diff)
downloadbinutils-redhat-758d4f6ed1fd32dec98ba5bdd578b6de9cfd1d0b.tar.gz
Handle STT_GNU_IFUNC symols when building shared library.
bfd/ 2012-01-06 H.J. Lu <hongjiu.lu@intel.com> PR ld/12366 PR ld/12371 * elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Properly handle symbols marked with regular reference, but not non-GOT reference when building shared library. * elf32-i386.c (elf_i386_gc_sweep_hook): Properly handle local and global STT_GNU_IFUNC symols when building shared library. * elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise. ld/testsuite/ 2012-01-06 H.J. Lu <hongjiu.lu@intel.com> PR ld/12366 PR ld/12371 * ld-ifunc/ifunc-10-i386.s: Add more tests. * ld-ifunc/ifunc-10-x86-64.s: Likewise. * ld-ifunc/ifunc-11-i386.s: Likewise. * ld-ifunc/ifunc-11-x86-64.s: Likewise. * ld-ifunc/ifunc-12-i386.d: New. * ld-ifunc/ifunc-12-i386.s: Likewise. * ld-ifunc/ifunc-12-x86-64.d: Likewise. * ld-ifunc/ifunc-12-x86-64.s: Likewise. * ld-ifunc/ifunc-13-i386.d: Likewise. * ld-ifunc/ifunc-13-x86-64.d: Likewise. * ld-ifunc/ifunc-13a-i386.s: Likewise. * ld-ifunc/ifunc-13a-x86-64.s: Likewise. * ld-ifunc/ifunc-13b-i386.s: Likewise. * ld-ifunc/ifunc-13b-x86-64.s: Likewise.
Diffstat (limited to 'bfd/elf-ifunc.c')
-rw-r--r--bfd/elf-ifunc.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/bfd/elf-ifunc.c b/bfd/elf-ifunc.c
index 760fc26c1a..17b23c2ffc 100644
--- a/bfd/elf-ifunc.c
+++ b/bfd/elf-ifunc.c
@@ -190,10 +190,29 @@ _bfd_elf_allocate_ifunc_dyn_relocs (struct bfd_link_info *info,
/* Support garbage collection against STT_GNU_IFUNC symbols. */
if (h->plt.refcount <= 0 && h->got.refcount <= 0)
{
- h->got = htab->init_got_offset;
- h->plt = htab->init_plt_offset;
- *head = NULL;
- return TRUE;
+ /* When building shared library, we need to handle the case
+ where it is marked with regular reference, but not non-GOT
+ reference. It may happen if we didn't see STT_GNU_IFUNC
+ symbol at the time when checking relocations. */
+ bfd_size_type count = 0;
+
+ if (info->shared
+ && !h->non_got_ref
+ && h->ref_regular)
+ {
+ for (p = *head; p != NULL; p = p->next)
+ count += p->count;
+ if (count != 0)
+ h->non_got_ref = 1;
+ }
+
+ if (count == 0)
+ {
+ h->got = htab->init_got_offset;
+ h->plt = htab->init_plt_offset;
+ *head = NULL;
+ return TRUE;
+ }
}
/* Return and discard space for dynamic relocations against it if