+2021-02-25 Alan Modra <amodra@gmail.com>
+
+ PR 27441
+ * elf-bfd.h (struct elf_link_hash_entry): Add ref_ir_nonweak.
+ * elflink.c (elf_link_add_object_symbols): Set ref_ir_nonweak and
+ use when deciding an as-needed library should be loaded instead
+ of using the binding of the library definition.
+
2021-02-24 Alan Modra <amodra@gmail.com>
PR 27459
/* Symbol has a non-weak reference from a non-shared object (other than
the object in which it is defined). */
unsigned int ref_regular_nonweak : 1;
+ /* Symbol has a non-weak reference from a LTO IR object file. */
+ unsigned int ref_ir_nonweak : 1;
/* Dynamic symbol has been adjustd. */
unsigned int dynamic_adjusted : 1;
/* Symbol needs a copy reloc. */
/* Plugin symbols aren't normal. Don't set def/ref flags. */
if ((abfd->flags & BFD_PLUGIN) != 0)
- ;
+ {
+ /* Except for this flag to track nonweak references. */
+ if (!definition
+ && bind != STB_WEAK)
+ h->ref_ir_nonweak = 1;
+ }
else if (!dynamic)
{
if (! definition)
&& h->ref_regular_nonweak)
|| (old_bfd != NULL
&& (old_bfd->flags & BFD_PLUGIN) != 0
- && !info->lto_all_symbols_read
- && bind != STB_WEAK)
+ && h->ref_ir_nonweak
+ && !info->lto_all_symbols_read)
|| (h->ref_dynamic_nonweak
&& (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0
&& !on_needed_list (elf_dt_name (abfd),