[PATCH] ld: Properly override the IR definition

H.J. Lu hjl.tools@gmail.com
Tue Jul 21 13:37:31 GMT 2020


On Mon, Jul 20, 2020 at 4:22 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Jul 20, 2020 at 4:17 PM Alan Modra <amodra@gmail.com> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ld-Properly-override-the-IR-definition.patch
Type: application/x-patch
Size: 8723 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20200721/462058c5/attachment-0001.bin>


More information about the Binutils mailing list