public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Alan Modra <amodra@gmail.com>
Cc: Binutils <binutils@sourceware.org>, Nick Clifton <nickc@redhat.com>
Subject: Re: [PATCH] ld: Keep indirect symbol from IR if referenced from shared object
Date: Sun, 13 Feb 2022 18:58:48 -0800	[thread overview]
Message-ID: <CAMe9rOp-P3=7TCunZG+GHoBCPmQApRDDhAi_g3Je74ps9rYUKA@mail.gmail.com> (raw)
In-Reply-To: <YgnCwVEF9LqTR/4G@squeak.grove.modra.org>

On Sun, Feb 13, 2022 at 6:47 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Sun, Feb 13, 2022 at 04:16:35PM -0800, H.J. Lu wrote:
> > On Fri, Feb 11, 2022 at 3:19 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > Don't change indirect symbol defined in IR to undefined if it is
> > > referenced from shared object.
>
> The description above
>
> > > diff --git a/bfd/elflink.c b/bfd/elflink.c
> > > index 6fa18d92007..f8521426cad 100644
> > > --- a/bfd/elflink.c
> > > +++ b/bfd/elflink.c
> > > @@ -1294,9 +1294,8 @@ _bfd_elf_merge_symbol (bfd *abfd,
> > >           h->root.non_ir_ref_dynamic = true;
> > >           hi->root.non_ir_ref_dynamic = true;
> > >         }
> > > -
> > > -      if ((oldbfd->flags & BFD_PLUGIN) != 0
> > > -         && hi->root.type == bfd_link_hash_indirect)
> > > +      else if ((oldbfd->flags & BFD_PLUGIN) != 0
> > > +              && hi->root.type == bfd_link_hash_indirect)
> > >         {
> > >           /* Change indirect symbol from IR to undefined.  */
> > >           hi->root.type = bfd_link_hash_undefined;
>
> and the patch do not exactly match.  The code logic is old sym
> indirect in IR, new sym not IR, both in shared library *or both not*.
> Is that correct?
>

The existing code is

      if (newdyn != olddyn)
        {
          /* Handle a case where plugin_notice won't be called and thus
             won't set the non_ir_ref flags on the first pass over
             symbols.  */
          h->root.non_ir_ref_dynamic = true;
          hi->root.non_ir_ref_dynamic = true;
        }

If an indirect symbol defined in IR is marked with
non_ir_ref_dynamic, we can't change it to undefined.
That is why I added "else" so that we don't get the
error of undefined reference from shared object.

      if ((oldbfd->flags & BFD_PLUGIN) != 0
          && hi->root.type == bfd_link_hash_indirect)
        {
          /* Change indirect symbol from IR to undefined.  */
          hi->root.type = bfd_link_hash_undefined;
          hi->root.u.undef.abfd = oldbfd;
        }


-- 
H.J.

  reply	other threads:[~2022-02-14  2:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11 23:19 H.J. Lu
2022-02-14  0:16 ` H.J. Lu
2022-02-14  2:47   ` Alan Modra
2022-02-14  2:58     ` H.J. Lu [this message]
2022-02-14  4:13       ` Alan Modra
2022-02-14 15:28         ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMe9rOp-P3=7TCunZG+GHoBCPmQApRDDhAi_g3Je74ps9rYUKA@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).