From 20ea3acc727f3be6322dfbd881e506873535231d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 11 Feb 2022 15:13:19 -0800 Subject: ld: Keep indirect symbol from IR if referenced from shared object Don't change indirect symbol defined in IR to undefined if it is referenced from shared object. bfd/ PR ld/28879 * elflink.c (_bfd_elf_merge_symbol): Don't change indirect symbol defined in IR to undefined if it is referenced from shared object. ld/ PR ld/28879 * testsuite/ld-plugin/lto.exp: Run PR ld/28879 tests. * testsuite/ld-plugin/pr28879a.cc: New file. * testsuite/ld-plugin/pr28879b.cc: Likewise. --- bfd/elflink.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'bfd') diff --git a/bfd/elflink.c b/bfd/elflink.c index 6fa18d9..f852142 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -1294,9 +1294,8 @@ _bfd_elf_merge_symbol (bfd *abfd, h->root.non_ir_ref_dynamic = true; hi->root.non_ir_ref_dynamic = true; } - - if ((oldbfd->flags & BFD_PLUGIN) != 0 - && hi->root.type == bfd_link_hash_indirect) + else if ((oldbfd->flags & BFD_PLUGIN) != 0 + && hi->root.type == bfd_link_hash_indirect) { /* Change indirect symbol from IR to undefined. */ hi->root.type = bfd_link_hash_undefined; -- cgit v1.1