public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Alessandro Carminati <alessandro.carminati@gmail.com>
To: libc-help@sourceware.org
Subject: Fwd: MIPSEL GLIBC sem_init() not shared
Date: Fri, 12 Mar 2021 12:37:00 +0100	[thread overview]
Message-ID: <CAPp5cGRtKiBv2nWrDFtWv90OHmodX4WavqzBOhyQGOqCff_Mbg@mail.gmail.com> (raw)
In-Reply-To: <CAPp5cGTfu38orQNtDRXrxenPDKYbJgEmFHjcw8QspURmCkZL0Q@mail.gmail.com>

On Fri, Mar 12, 2021 at 11:49 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Alessandro Carminati via Libc-help:
>
> > But looking at the liba.so dependencies, I've been surprised by the
> > fact that the library depends only on the main libc library
> > (libc.so.6) and has no dependency on libpthread.so.0 where the actual
> > sem_* symbols are implemented.
> >
> > $ /lib/ld-2.31.so --list /usr/lib/liba.so
> >         linux-vdso.so.1 (0x7ffaa000)
> >         libc.so.6 => /lib/libc.so.6 (0x77ddc000)
> >         /lib/ld-2.31.so (0x77f8a000)
> >
> > I guess this might be related to my problem, but I have no clue how to
> > link these two facts. How the liba.so could be compiled and linked
> > using symbols its dependencies do not provide?
>
> This is called underlinking.  It produces invalid objects.
>
> > How to force the GNU linker to link against sem_init@@GLIBC_2.2
> > instead of sem_init@GLIBC_2.0?
>
> Just link with -lpthread, it will add the symbol version and call the
> right function.
>
> We are working on changes to glibc that makes it much less likely that
> such underlink can happen, so hopefully such difficult-to-debug problems
> will become a non-issue at some point in the future.
>
> Thanks,
> Florian
>
Yes, it was just as you said. Underlinking. My fault. I knew it was
related, but I put the -lptread in the wrong place.
Thanks for the answer, it resolved the main issue.

If I can, I'd like to ask you a couple of questions about the same scenario.
This time was the port on MIPSEL, but before this port, I compiled
successfully (without -lpthread) on two other architectures: ARM32 and
x64.
Which is the mechanism why in other architecture, the libpthread was
included and in MIPS it didn't?

I understand that because the libpthread is a dependency of the
executable that also depends on liba.so, at runtime, the dynamic
linker has been able to resolve the sem_init call.
My question is, why it resolved the call picking the
sem_init@GLIBC_2.0 instead of sem_init@@GLIBC_2.2?

  parent reply	other threads:[~2021-03-12 11:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12  9:31 Alessandro Carminati
2021-03-12 10:49 ` Florian Weimer
     [not found]   ` <CAPp5cGTfu38orQNtDRXrxenPDKYbJgEmFHjcw8QspURmCkZL0Q@mail.gmail.com>
2021-03-12 11:37     ` Alessandro Carminati [this message]
2021-03-12 12:17       ` Fwd: " Florian Weimer
2021-03-12 13:41         ` Alessandro Carminati
2021-03-12 16:04           ` Florian Weimer
2021-03-13  6:53             ` Alessandro Carminati
2021-03-13  7:05               ` 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=CAPp5cGRtKiBv2nWrDFtWv90OHmodX4WavqzBOhyQGOqCff_Mbg@mail.gmail.com \
    --to=alessandro.carminati@gmail.com \
    --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).