From d1ed1c7d69e6656de213b12594e702afec31a66d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 8 Mar 2016 09:42:01 -0800 Subject: Handle local IFUNC symbols in shared object Increment PLT reference count for locally defined local IFUNC symbols in shared object since STT_GNU_IFUNC symbol must go through PLT even if it is locally defined and undefined symbol may turn out to be a STT_GNU_IFUNC symbol later. bfd/ PR ld/19784 * elf32-i386.c (elf_i386_check_relocs): Increment PLT reference count for locally defined local IFUNC symbols in shared object. * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise. ld/ PR ld/19784 * testsuite/ld-i386/i386.exp: Remove pr19636-2e-nacl test. * testsuite/ld-i386/pr19636-2e-nacl.d: Moved to ... * testsuite/ld-i386/pr19636-2e.d: Here. Remove notarget. * testsuite/ld-ifunc/ifunc.exp: Run PR ld/19784 tests. * testsuite/ld-ifunc/pass.out: New file. * testsuite/ld-ifunc/pr19784a.c: Likewise. * testsuite/ld-ifunc/pr19784b.c: Likewise. * testsuite/ld-ifunc/pr19784c.c: Likewise. --- bfd/elf32-i386.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'bfd/elf32-i386.c') diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index ab3945d..ac3c2f4 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1808,7 +1808,15 @@ elf_i386_check_relocs (bfd *abfd, if (eh != NULL && (sec->flags & SEC_CODE) != 0) eh->has_non_got_reloc = 1; do_relocation: - if (h != NULL && bfd_link_executable (info)) + /* STT_GNU_IFUNC symbol must go through PLT even if it is + locally defined and undefined symbol may turn out to be + a STT_GNU_IFUNC symbol later. */ + if (h != NULL + && (bfd_link_executable (info) + || ((h->type == STT_GNU_IFUNC + || h->root.type == bfd_link_hash_undefweak + || h->root.type == bfd_link_hash_undefined) + && SYMBOLIC_BIND (info, h)))) { /* If this reloc is in a read-only section, we might need a copy reloc. We can't check reliably at this -- cgit v1.1