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. --- ld/testsuite/ld-ifunc/ifunc.exp | 40 ++++++++++++++++++++++++++++++++++++++++ ld/testsuite/ld-ifunc/pass.out | 1 + ld/testsuite/ld-ifunc/pr19784a.c | 6 ++++++ ld/testsuite/ld-ifunc/pr19784b.c | 11 +++++++++++ ld/testsuite/ld-ifunc/pr19784c.c | 11 +++++++++++ 5 files changed, 69 insertions(+) create mode 100644 ld/testsuite/ld-ifunc/pass.out create mode 100644 ld/testsuite/ld-ifunc/pr19784a.c create mode 100644 ld/testsuite/ld-ifunc/pr19784b.c create mode 100644 ld/testsuite/ld-ifunc/pr19784c.c (limited to 'ld/testsuite/ld-ifunc') diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp index 96627e7..e860f36 100644 --- a/ld/testsuite/ld-ifunc/ifunc.exp +++ b/ld/testsuite/ld-ifunc/ifunc.exp @@ -505,6 +505,30 @@ run_cc_link_tests [list \ {} \ "libpr18841c.so" \ ] \ + [list \ + "Build libpr19784a.so" \ + "-shared -Wl,-Bsymbolic-functions" \ + "-fPIC -O2 -g" \ + { pr19784b.c pr19784c.c } \ + {} \ + "libpr19784a.so" \ + ] \ + [list \ + "Build libpr19784b.so" \ + "-shared -Wl,-Bsymbolic-functions" \ + "-fPIC -O2 -g" \ + { pr19784c.c pr19784b.c } \ + {} \ + "libpr19784b.so" \ + ] \ + [list \ + "Build pr19784a.o" \ + "" \ + "" \ + { pr19784a.c } \ + "" \ + "" \ + ] \ ] run_ld_link_exec_tests [] [list \ @@ -532,4 +556,20 @@ run_ld_link_exec_tests [] [list \ "pr18841c" \ "pr18841.out" \ ] \ + [list \ + "Run pr19784a" \ + "tmpdir/pr19784a.o tmpdir/libpr19784a.so" \ + "" \ + { dummy.c } \ + "pr19784a" \ + "pass.out" \ + ] \ + [list \ + "Run pr19784b" \ + "--as-needed tmpdir/pr19784a.o tmpdir/libpr19784b.so" \ + "" \ + { dummy.c } \ + "pr19784b" \ + "pass.out" \ + ] \ ] diff --git a/ld/testsuite/ld-ifunc/pass.out b/ld/testsuite/ld-ifunc/pass.out new file mode 100644 index 0000000..7ef22e9 --- /dev/null +++ b/ld/testsuite/ld-ifunc/pass.out @@ -0,0 +1 @@ +PASS diff --git a/ld/testsuite/ld-ifunc/pr19784a.c b/ld/testsuite/ld-ifunc/pr19784a.c new file mode 100644 index 0000000..c922cb9 --- /dev/null +++ b/ld/testsuite/ld-ifunc/pr19784a.c @@ -0,0 +1,6 @@ +void bar(void); +int main(void) +{ + bar(); + return 0; +} diff --git a/ld/testsuite/ld-ifunc/pr19784b.c b/ld/testsuite/ld-ifunc/pr19784b.c new file mode 100644 index 0000000..8ea7ce2 --- /dev/null +++ b/ld/testsuite/ld-ifunc/pr19784b.c @@ -0,0 +1,11 @@ +int foo (int x) __attribute__ ((ifunc ("resolve_foo"))); + +static int foo_impl(int x) +{ + return x; +} + +void *resolve_foo (void) +{ + return (void *) foo_impl; +} diff --git a/ld/testsuite/ld-ifunc/pr19784c.c b/ld/testsuite/ld-ifunc/pr19784c.c new file mode 100644 index 0000000..117dfec --- /dev/null +++ b/ld/testsuite/ld-ifunc/pr19784c.c @@ -0,0 +1,11 @@ +#include + +extern void abort (void); +extern int foo (int) __attribute__ ((visibility("hidden"))); + +int bar() +{ + if (foo (5) != 5) + abort (); + printf("PASS\n"); +} -- cgit v1.1