From cae1fbbb7e3d770702a0d7a5027b46835e6adc13 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 18 Aug 2015 09:47:59 -0700 Subject: Return reloc_class_ifunc for reloc against IFUNC elf_XXX_reloc_type_class should return reloc_class_ifunc for relocation against STT_GNU_IFUNC symbol. bfd/ PR ld/18841 * elf-bfd.h (elf_link_hash_table): Add dynsym. * elf32-i386.c (elf_i386_reloc_type_class): Return reloc_class_ifunc for relocation against STT_GNU_IFUNC symbol. * elf64-x86-64.c (elf_x86_64_reloc_type_class): Likewise. * elflink.c (_bfd_elf_link_create_dynamic_sections): Set dynsym. (bfd_elf_size_dynsym_hash_dynstr): Use dynsym. (elf_final_link_info): Remove dynsym_sec. (elf_link_output_extsym): Replace dynsym_sec with dynsym. (bfd_elf_final_link): Remove reference to dynsym_sec. Replace dynsym_sec with dynsym. ld/testsuite/ PR ld/18841 * ld-ifunc/ifunc.exp: Add a test for PR ld/18841. * ld-ifunc/pr18841.out: New file. * ld-ifunc/pr18841a.c: Likewise. * ld-ifunc/pr18841b.c: Likewise. --- ld/testsuite/ChangeLog | 8 ++++++++ ld/testsuite/ld-ifunc/ifunc.exp | 16 ++++++++++++++++ ld/testsuite/ld-ifunc/pr18841.out | 1 + ld/testsuite/ld-ifunc/pr18841a.c | 12 ++++++++++++ ld/testsuite/ld-ifunc/pr18841b.c | 21 +++++++++++++++++++++ 5 files changed, 58 insertions(+) create mode 100644 ld/testsuite/ld-ifunc/pr18841.out create mode 100644 ld/testsuite/ld-ifunc/pr18841a.c create mode 100644 ld/testsuite/ld-ifunc/pr18841b.c (limited to 'ld') diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 5ae5cd4..b8546d0 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2015-08-18 H.J. Lu + + PR ld/18841 + * ld-ifunc/ifunc.exp: Add a test for PR ld/18841. + * ld-ifunc/pr18841.out: New file. + * ld-ifunc/pr18841a.c: Likewise. + * ld-ifunc/pr18841b.c: Likewise. + 2015-08-13 H.J. Lu PR ld/18801 diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp index 498cb2d..b0f6de0 100644 --- a/ld/testsuite/ld-ifunc/ifunc.exp +++ b/ld/testsuite/ld-ifunc/ifunc.exp @@ -472,6 +472,14 @@ run_cc_link_tests [list \ {} \ "libpr18808.so" \ ] \ + [list \ + "Build libpr18841.so" \ + "-shared" \ + "-fPIC -O0 -g" \ + { pr18841b.c } \ + {} \ + "libpr18841.so" \ + ] \ ] run_ld_link_exec_tests [] [list \ @@ -483,4 +491,12 @@ run_ld_link_exec_tests [] [list \ "pr18808" \ "pr18808.out" \ ] \ + [list \ + "Run pr18841" \ + "tmpdir/libpr18841.so" \ + "" \ + { pr18841a.c } \ + "pr18841" \ + "pr18841.out" \ + ] \ ] diff --git a/ld/testsuite/ld-ifunc/pr18841.out b/ld/testsuite/ld-ifunc/pr18841.out new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/ld/testsuite/ld-ifunc/pr18841.out @@ -0,0 +1 @@ +OK diff --git a/ld/testsuite/ld-ifunc/pr18841a.c b/ld/testsuite/ld-ifunc/pr18841a.c new file mode 100644 index 0000000..72179d2 --- /dev/null +++ b/ld/testsuite/ld-ifunc/pr18841a.c @@ -0,0 +1,12 @@ +#include + +extern void test(void); + +void zoo(){} + +int main() +{ + test(); + printf("OK\n"); + return 0; +} diff --git a/ld/testsuite/ld-ifunc/pr18841b.c b/ld/testsuite/ld-ifunc/pr18841b.c new file mode 100644 index 0000000..1e87469 --- /dev/null +++ b/ld/testsuite/ld-ifunc/pr18841b.c @@ -0,0 +1,21 @@ +void foo() __attribute__((ifunc("resolve_foo"))); + +static void foo_impl() {} + +extern void abort (void); +void test() +{ + void (*pg)(void) = foo; + if (pg != foo_impl) + abort (); + pg(); +} + +static void* resolve_foo() +{ + extern void zoo(void); + + void (*pz)(void) = zoo; + pz(); + return foo_impl; +} -- cgit v1.1