On Mon, Jul 20, 2020 at 4:22 PM H.J. Lu wrote: > > On Mon, Jul 20, 2020 at 4:17 PM Alan Modra wrote: > > > > On Mon, Jul 20, 2020 at 06:34:29AM -0700, H.J. Lu via Binutils wrote: > > > --- a/bfd/elflink.c > > > +++ b/bfd/elflink.c > > > @@ -1269,6 +1269,18 @@ _bfd_elf_merge_symbol (bfd *abfd, > > > && h->root.type != bfd_link_hash_undefweak > > > && h->root.type != bfd_link_hash_common); > > > > > > + /* NB: Ignore the new weak definition if the old definition comes > > > + from the LTO IR object since plugin_notice will turn it into > > > + undefweak. */ > > > + if (olddef > > > + && oldbfd > > > + && (oldbfd->flags & BFD_PLUGIN) != 0 > > > + && newweak) > > > + { > > > + *skip = TRUE; > > > + return TRUE; > > > + } > > > + > > > /* NEWFUNC and OLDFUNC indicate whether the new or old symbol, > > > respectively, appear to be a function. */ > > > > > > > How do you square this with later code in _bfd_elf_merge_symbol? > > See PR12696. > > > > /* Skip weak definitions of symbols that are already defined. */ > > if (newdef && olddef && newweak) > > { > > /* Don't skip new non-IR weak syms. */ > > if (!(oldbfd != NULL > > && (oldbfd->flags & BFD_PLUGIN) != 0 > > && (abfd->flags & BFD_PLUGIN) == 0)) > > { > > newdef = FALSE; > > *skip = TRUE; > > } > > > After all LTO symbols have been read, a new definition in real object overrides the previous definition in the IR object. Before all LTO symbols have been read, a new non-weak definition overrides the weak definition in the IR object. OK for master? Thanks. -- H.J.