public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
To: Ryan Burn via Libc-help <libc-help@sourceware.org>
Subject: Re: Trouble with portable linking
Date: Thu, 17 Dec 2020 21:14:39 +0100	[thread overview]
Message-ID: <87lfdwdwb4.fsf@mid.deneb.enyo.de> (raw)
In-Reply-To: <CACqP_wyc_RU8uMsRaPgrER-yWb4DqdT=wT35wOG6H6pmpWL9BQ@mail.gmail.com> (Ryan Burn via Libc-help's message of "Thu, 17 Dec 2020 11:57:35 -0800")

* Ryan Burn via Libc-help:

> Hello, I'm trying to link a portable shared library binary. I've
> followed the practice recommended here
> (https://stackoverflow.com/questions/4032373/linking-against-an-old-version-of-libc-to-provide-greater-application-coverage/20065096#20065096)
> where I explicitly link to portable versions of symbols, and it's
> worked well for me. But the recent change where pthread_getattr_np
> moved from libpthread to libc is causing me trouble:
>
> https://stackoverflow.com/questions/65336219/how-to-link-so-that-pthread-getattr-np-will-be-resolved
>
> When my portable binary is loaded on an older system where
> pthread_getattr_np is still in libpthread, loading fails to resolve
> the symbol. Could anyone suggest how I can work around this?

If you want to be compatible with glibc versions that check the
embedded soname in symbol versions (which is not visible in the @
syntax), you need to build a stub library that defines the required
symbol versions in the right shared object.  There is no way to
achieve this with .symver directives.

Alternatively, you could convince more distributions to backport
commit f0b2132b35248c1f4a80f62a2c38cddcc802aa8c ("ld.so: Support
moving versioned symbols between sonames [BZ #24741]").

> Also, is there a reason why the portable versioned symbol
> pthread_getattr_np@GLIBC_2.2.5 moved from libpthread to libc? Why not
> keep pthread_getattr_np@GLIBC_2.2.5 in libpthread and have the newer
> symbol in libc?

We would have to create an internal alias in libc and export for use
in libpthread.  The additional function call seemed unnecessary.
IFUNC resolvers are not usable for such forwarders because they must
not depend on relocations, and the symbol reference to libc.so.6 is
such a dependency.

  reply	other threads:[~2020-12-17 20:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17 19:57 Ryan Burn
2020-12-17 20:14 ` Florian Weimer [this message]
2020-12-17 20:47   ` Ryan Burn
2020-12-17 20:55     ` Florian Weimer
2020-12-17 21:08       ` Ryan Burn
2020-12-18  7:48         ` Florian Weimer

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=87lfdwdwb4.fsf@mid.deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    --cc=libc-help@sourceware.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).