public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: "H.J. Lu" <hjl.tools@gmail.com>,
	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 15:06:51 -0300	[thread overview]
Message-ID: <3740a7af-3315-9de9-f680-af7e659b4b4e@linaro.org> (raw)
In-Reply-To: <87eeeldrp4.fsf@oldenburg.str.redhat.com>



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. 

> 
> That's why I think we need to tell the two symbols apart.  There are of
> course many ways to encode the difference.  A name-based check seemed
> the most straight-forward approach to me.  It is an implementation
> detail.  With link editor support or binary rewriting, we could come up
> with alternative approaches (e.g., a bitmap containing a bit for each
> symbol table entry).  I'm not sure if that would result in code size
> savings though.
> 
> Thanks,
> Florian
> 

  parent reply	other threads:[~2021-05-05 18:06 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 [this message]
2021-05-05 18:16             ` Florian Weimer
2021-05-05 18:18               ` H.J. Lu
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=3740a7af-3315-9de9-f680-af7e659b4b4e@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.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).