aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2024-04-16 15:48:21 -0700
committerH.J. Lu <hjl.tools@gmail.com>2024-04-16 17:45:23 -0700
commitc2fbf57864a2da2ceda81706a54d125ef3fce0a7 (patch)
tree15b12d00599ddfaccc3cee67e324b57040f011cb /bfd
parent79484e95665430b6960425e5c50ffb9f90072bf4 (diff)
downloadgdb-c2fbf57864a2da2ceda81706a54d125ef3fce0a7.zip
gdb-c2fbf57864a2da2ceda81706a54d125ef3fce0a7.tar.gz
gdb-c2fbf57864a2da2ceda81706a54d125ef3fce0a7.tar.bz2
elf: Skip the archive if the symbol isn't referenced
Also skip the archive if the symbol isn't referenced by a regular object. bfd/ PR ld/31644 * elflink.c (elf_link_add_archive_symbols): Also skip the archive if the symbol isn't referenced by a regular object. ld/ PR ld/31644 * testsuite/ld-plugin/lto.exp: Run PR ld/31644 tests. * testsuite/ld-plugin/pr31644a.c: New test. * testsuite/ld-plugin/pr31644b.c: Likewise. * testsuite/ld-plugin/pr31644c.c: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elflink.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 321e3d5..9c53bfc 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -6261,9 +6261,11 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
if (!is_elf_hash_table (info->hash))
continue;
- /* Ignore the archive if the symbol isn't defined in a
- shared object. */
- if (!((struct elf_link_hash_entry *) h)->def_dynamic)
+ struct elf_link_hash_entry *eh
+ = (struct elf_link_hash_entry *) h;
+ /* Ignore the archive if the symbol isn't referenced by a
+ regular object or isn't defined in a shared object. */
+ if (!eh->ref_regular || !eh->def_dynamic)
continue;
/* Ignore the dynamic definition if symbol is first
defined in this archive. */