From 25d17459e337a4cc9856f36c55a88b072c8709c9 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 16 Nov 2022 15:06:37 -0800 Subject: ld: Always call elf_backend_output_arch_local_syms Always call elf_backend_output_arch_local_syms since only the backend knows if elf_backend_output_arch_local_syms is needed when all symbols are striped. elf_backend_output_arch_local_syms is defined only for x86, ARM and AARCH64. On x86, elf_backend_output_arch_local_syms must be called to handle local IFUNC symbols even if all symbols are striped. Update ARM and AARCH64 to skip elf_backend_output_arch_local_syms when symbols aren't needed. bfd/ PR ld/29797 * elf32-arm.c (elf32_arm_output_arch_local_syms): Skip if symbols aren't needed. * elfnn-aarch64.c (elfNN_aarch64_output_arch_local_syms): Likewise. * elflink.c (bfd_elf_final_link): Always call elf_backend_output_arch_local_syms if available. ld/ PR ld/29797 * testsuite/ld-elf/linux-x86.exp: Run PR ld/29797 test. * testsuite/ld-elf/pr29797.c: New file. --- ld/testsuite/ld-elf/linux-x86.exp | 15 +++++++++++++++ ld/testsuite/ld-elf/pr29797.c | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 ld/testsuite/ld-elf/pr29797.c (limited to 'ld') diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp index 0637905..7822bd2 100644 --- a/ld/testsuite/ld-elf/linux-x86.exp +++ b/ld/testsuite/ld-elf/linux-x86.exp @@ -203,6 +203,21 @@ run_ld_link_exec_tests [list \ ] \ ] +# Run-time tests which require working ifunc attribute support. +if { [check_ifunc_attribute_available] } { + run_ld_link_exec_tests [list \ + [list \ + "Run pr29797" \ + "-s" \ + "" \ + { pr29797.c } \ + "pr29797" \ + "pass.out" \ + "-O0" \ + ] \ + ] +} + # Old gcc silently ignores __attribute__ ((aligned())) with too big alignment. proc compiler_honours_aligned { } { global CC_FOR_TARGET READELF srcdir subdir diff --git a/ld/testsuite/ld-elf/pr29797.c b/ld/testsuite/ld-elf/pr29797.c new file mode 100644 index 0000000..9e3113f --- /dev/null +++ b/ld/testsuite/ld-elf/pr29797.c @@ -0,0 +1,21 @@ +#include + +static int foo (int x) __attribute__ ((ifunc ("resolve_foo"))); + +static int foo_impl(int x) +{ + return x; +} + +static void *resolve_foo (void) +{ + return (void *) foo_impl; +} + +int +main () +{ + foo (0); + puts ("PASS"); + return 0; +} -- cgit v1.1