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: Nick Clifton <nickc@redhat.com>, Binutils <binutils@sourceware.org>
Subject: Re: PING^2: [PATCH v3] elf: Always honor the first definition in shared object and archive
Date: Fri, 5 Apr 2024 16:48:38 -0700	[thread overview]
Message-ID: <CAMe9rOqrUiYhmYDpjcE8_B=RGwCBQjRWPWdWTLUF1L7gLfLJ1A@mail.gmail.com> (raw)
In-Reply-To: <ZhCNH6AU46QnJJyZ@squeak.grove.modra.org>

On Fri, Apr 5, 2024 at 4:45 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Fri, Apr 05, 2024 at 04:37:11PM -0700, H.J. Lu wrote:
> > On Fri, Apr 5, 2024 at 3:16 PM Alan Modra <amodra@gmail.com> wrote:
> > >
> > > On Fri, Apr 05, 2024 at 05:00:28AM -0700, H.J. Lu wrote:
> > > > On Fri, Apr 5, 2024 at 3:15 AM Nick Clifton <nickc@redhat.com> wrote:
> > > > >
> > > > > Hi H.J.
> > > > >
> > > > > >>> GCC doesn't put builtin function symbol references, which are defined in
> > > > > >>> the shared C library, in the IR symbol table.  When linker rescans shared
> > > > > >>> objects and archives for newly added symbol references generated from the
> > > > > >>> IR inputs, it skips definitions of the builtin functions in shared
> > > > > >>> objects and archives.
> > > > > >>>
> > > > > >>> Add first_hash to elf_link_hash_table to track unreferenced definitions
> > > > > >>> defined first in shared objects and archives.  Always use them to resolve
> > > > > >>> any references.
> > > > >
> > > > > Approved - please apply.
> > > > >
> > > > > Cheers
> > > > >    Nick
> > > > >
> > > >
> > > > I am checking in the v2 patch:
> > > >
> > > > https://sourceware.org/pipermail/binutils/2024-April/133395.html
> > >
> > > I had some further requests to make.
> > > 1) If you are going to use a bfd_hash_table based first_hash, please
> > > don't use bfd_link_hash_table.  Instead extend bfd_hash_entry with a
> > > single abfd field.  You'll need to write a newfunc, but that's about
> > > all that is required.  There are multiple examples of this in the
> > > source, eg. bfd/stabs.c stab_link_includes_entry.
> >
> > I will add
> >
> > /* An entry in the first definition hash table.  */
> >
> > struct elf_link_first_hash_entry
> > {
> >   struct bfd_hash_entry root;
> >   /* The object of the first definition.  */
> >   bfd *abfd;
> > };
> >
> > > 2) You are accessing freed memory in _bfd_elf_link_hash_table_free.
> > > Free first_hash before freeing the main hash table.  That needs fixing
> > > immediately.
> >
> > I will change it to
> >
> >   if (htab->first_hash != NULL)
> >     {
> >       bfd_hash_table_free (htab->first_hash);
> >       free (htab->first_hash);
> >     }
> >   _bfd_generic_link_hash_table_free (obfd);
>
> Thanks, that along with the elf_link_first_hast_entry change is
> preapproved.

I am checking in this:

https://sourceware.org/pipermail/binutils/2024-April/133415.html

Thanks.

-- 
H.J.

  reply	other threads:[~2024-04-05 23:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15 19:43 H.J. Lu
2024-03-28 13:30 ` PING: " H.J. Lu
2024-04-04 13:29   ` PING^2: " H.J. Lu
2024-04-05 10:15     ` Nick Clifton
2024-04-05 12:00       ` H.J. Lu
2024-04-05 22:16         ` Alan Modra
2024-04-05 23:37           ` H.J. Lu
2024-04-05 23:45             ` Alan Modra
2024-04-05 23:48               ` H.J. Lu [this message]
2024-04-04 23:54 ` Alan Modra
2024-04-05  1:50   ` 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='CAMe9rOqrUiYhmYDpjcE8_B=RGwCBQjRWPWdWTLUF1L7gLfLJ1A@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).