public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	 GNU C Library <libc-alpha@sourceware.org>,
	Andreas Schwab <schwab@linux-m68k.org>
Subject: Re: [PATCH v2] elf: Implement filtering of symbols historically defined in libpthread
Date: Wed, 5 May 2021 11:18:32 -0700	[thread overview]
Message-ID: <CAMe9rOr91o0vU5=NjVxc7CwJHrmrNhuzXh6uhCAuaCpUP4jGpg@mail.gmail.com> (raw)
In-Reply-To: <87o8dpavx3.fsf@oldenburg.str.redhat.com>

On Wed, May 5, 2021 at 11:15 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Adhemerval Zanella:
>
> > On 05/05/2021 14:19, Florian Weimer wrote:
> >> * Adhemerval Zanella:
> >>
> >>>> But that is not why my patch contains a symbol table: Once we detect an
> >>>> old binary, we need to treat certain symbols differently.  There are
> >>>> actually unversioned weak references to pthread_mutex_lock out there.
> >>>> pthread_mutex_lock@@GLIBC_2.0 has existed in libc.so.6 for a long time,
> >>>> so we need to bind such weak references to a definition.  In contrast,
> >>>> __pthread_mutex_lock@@GLIBC_2.0 only existed in libpthread.so.0 in glibc
> >>>> 2.33 and earlier.  This is why there is a table of magic symbols.  It's
> >>>> not to detect old binaries, it's there to record certain symbols which
> >>>> were historically part of libpthread.so.0 only.  That is a property of
> >>>> past binaries; as such it won't change with future glibc versions.
> >>>> That's why I think we need to encode that symbol set somewhere.  And a
> >>>> sorted table is a low-tech version to implement that.
> >>>
> >>> I am trying to understand which scenario the _dl_pthread_hidden_symbol is
> >>> required where the first part of dl_pthread_hide_symbol can't find that the
> >>> symbol should be hidden.
> >>
> >> glibc 2.34 defines both pthread_mutex_lock@GLIBC_2.0 and
> >> __pthread_mutex_lock@GLIBC_2.0 in libc.  glibc 2.33 and earlier only
> >> defined pthread_mutex_lock@@GLIBC_2.0 in libc.
> >>
> >> There are old binaries out there that contain unversioned weak
> >> references to pthread_mutex_lock or to __pthread_mutex_lock, without
> >> linking against libpthread.  To preserve backwards compatibility,
> >> pthread_mutex_lock must be bound to the function symbol in libc, but
> >> __pthread_mutex_lock must not be bound.
> >
> > From where unversioned weak __pthread_mutex_lock come from and how are
> > they generated? It seems another interface abuse and I am not sure if we
> > should keep backwards compatibility for double underscore symbols.
>
> I can drop the __ symbols if you want.  With the string table, we can
> add more symbols again if needed.
>
> Most of the unversioned weak __pthread_mutex_lock references I have
> actually come from our __libc_lock_lock macro.  (They are now strong
> references obviously.)  However, someone copied that coding pattern into
> the old nss_ldap module.  This suggests that there could be other cases.

Why can't we just hide symbols for undefined, weak, unversioned references
from the old binaries?

-- 
H.J.

  reply	other threads:[~2021-05-05 18:19 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 13:44 Florian Weimer
2021-05-05 14:10 ` Adhemerval Zanella
2021-05-05 15:30   ` Florian Weimer
2021-05-05 15:53   ` H.J. Lu
2021-05-05 16:01     ` Florian Weimer
2021-05-05 16:55       ` Adhemerval Zanella
2021-05-05 17:19         ` Florian Weimer
2021-05-05 17:52           ` H.J. Lu
2021-05-05 17:56             ` Florian Weimer
2021-05-05 18:06           ` Adhemerval Zanella
2021-05-05 18:16             ` Florian Weimer
2021-05-05 18:18               ` H.J. Lu [this message]
2021-05-05 18:28                 ` Florian Weimer
2021-05-05 18:30                   ` H.J. Lu
2021-05-05 18:48                     ` Florian Weimer
2021-05-05 18:50                       ` H.J. Lu
2021-05-05 19:08                         ` Florian Weimer
2021-05-05 19:32                           ` H.J. Lu
2021-05-05 19:53                             ` Florian Weimer
2021-05-05 19:03 ` Andreas Schwab
2021-05-05 19:10   ` Florian Weimer
2021-05-05 20:48     ` H.J. Lu
2021-05-05 20:53       ` H.J. Lu
2021-05-06  9:17         ` Florian Weimer
2021-05-06 12:08           ` H.J. Lu
2021-05-06 12:50             ` Florian Weimer
2021-05-06 12:58               ` Adhemerval Zanella
2021-05-06 13:15               ` H.J. Lu
2021-05-07 14:46 ` Florian Weimer
2021-05-07 16:40   ` H.J. Lu
2021-05-10 13:48     ` Florian Weimer
2021-05-10 14:02       ` H.J. Lu
2021-05-10 14:08         ` Florian Weimer
2021-05-11  0:04           ` 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='CAMe9rOr91o0vU5=NjVxc7CwJHrmrNhuzXh6uhCAuaCpUP4jGpg@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@linux-m68k.org \
    /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).