aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2022-11-16 15:06:37 -0800
committerH.J. Lu <hjl.tools@gmail.com>2022-11-17 08:13:37 -0800
commit25d17459e337a4cc9856f36c55a88b072c8709c9 (patch)
tree39df322bb8810b66dd76b81eac13426c3039fcd2 /bfd
parentcbda14deaf49b48450207cfb0990c71c11d07a64 (diff)
downloadbinutils-25d17459e337a4cc9856f36c55a88b072c8709c9.zip
binutils-25d17459e337a4cc9856f36c55a88b072c8709c9.tar.gz
binutils-25d17459e337a4cc9856f36c55a88b072c8709c9.tar.bz2
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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elf32-arm.c5
-rw-r--r--bfd/elflink.c3
-rw-r--r--bfd/elfnn-aarch64.c5
3 files changed, 11 insertions, 2 deletions
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index ec18a8a..c7d73171 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -18110,6 +18110,11 @@ elf32_arm_output_arch_local_syms (bfd *output_bfd,
bfd_size_type size;
bfd *input_bfd;
+ if (info->strip == strip_all
+ && !info->emitrelocations
+ && !bfd_link_relocatable (info))
+ return true;
+
htab = elf32_arm_hash_table (info);
if (htab == NULL)
return false;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 20cee4c..81b3412 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -12877,8 +12877,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
/* If backend needs to output some local symbols not present in the hash
table, do it now. */
- if (bed->elf_backend_output_arch_local_syms
- && (info->strip != strip_all || emit_relocs))
+ if (bed->elf_backend_output_arch_local_syms)
{
if (! ((*bed->elf_backend_output_arch_local_syms)
(abfd, info, &flinfo, elf_link_output_symstrtab)))
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 7b93672..a9fefbd 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -8476,6 +8476,11 @@ elfNN_aarch64_output_arch_local_syms (bfd *output_bfd,
output_arch_syminfo osi;
struct elf_aarch64_link_hash_table *htab;
+ if (info->strip == strip_all
+ && !info->emitrelocations
+ && !bfd_link_relocatable (info))
+ return true;
+
htab = elf_aarch64_hash_table (info);
osi.finfo = finfo;