[PATCH] LTO: Handle __real_SYM reference in IR

H.J. Lu hjl.tools@gmail.com
Wed May 4 23:26:24 GMT 2022


On Tue, May 3, 2022 at 9:12 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Fri, Apr 29, 2022 at 10:59:32AM -0700, H.J. Lu via Binutils wrote:
> > --- a/bfd/elflink.c
> > +++ b/bfd/elflink.c
> > @@ -1101,8 +1101,19 @@ _bfd_elf_merge_symbol (bfd *abfd,
> >    if (! bfd_is_und_section (sec))
> >      h = elf_link_hash_lookup (elf_hash_table (info), name, true, false, false);
> >    else
> > -    h = ((struct elf_link_hash_entry *)
> > -      bfd_wrapped_link_hash_lookup (abfd, info, name, true, false, false));
> > +    {
> > +      h = ((struct elf_link_hash_entry *)
> > +        bfd_wrapped_link_hash_lookup (abfd, info, name, true, false,
> > +                                      false));
> > +      /* Mark SYM is referenced in IR if __real_SYM is referenced in
> > +      IR.  */
> > +      if (h != NULL
> > +       && info->wrap_hash != NULL
> > +       && (abfd->flags & BFD_PLUGIN) != 0
> > +       && strcmp (h->root.root.string,
> > +                  name + sizeof "__real_" - 1) == 0)
> > +     h->root.ir_ref_real = 1;
> > +    }
> >    if (h == NULL)
> >      return false;
> >    *sym_hash = h;
>
> How about putting the above in linker.c:bfd_wrapped_link_hash_lookup
> instead, to avoid the extra strcmp?  That seems like a better place to
> me since there isn't really anything ELF specific about wrapped symbol
> lookup.
>
> Hmm, and maybe without the BFD_PLUGIN test and losing "ir" from the
> flag name.
>
> If that works for you, OK with those changes.
>

It works.  This is what I am checking in.

Thanks.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-LTO-Handle-__real_SYM-reference-in-IR.patch
Type: text/x-patch
Size: 3750 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20220504/c5629c4b/attachment.bin>


More information about the Binutils mailing list