mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: Dmitry Samersoff <dms@samersoff.net>
Cc: musl@lists.openwall.com, Rich Felker <dalias@libc.org>,
	Alexander Scherbatiy <alexander.scherbatiy@bell-sw.com>,
	Markus Wichmann <nullplan@gmx.net>
Subject: Re: [musl] Shared library loading
Date: Thu, 28 May 2020 20:53:25 +0200	[thread overview]
Message-ID: <20200528185325.GF26190@port70.net> (raw)
In-Reply-To: <a11d2224-cc3f-1731-6a40-c99e07a63239@samersoff.net>

* Dmitry Samersoff <dms@samersoff.net> [2020-05-27 21:10:18 +0300]:

> Hello Alexander,
> 
> > The "b" library loading works on my Ubuntu 19.10 and fails on Alpine
> > 3.11.6 with message: > dlopen failed: Error loading shared library
> > liba.so: No such file or
> > directory (needed by /root/load-lib-sample/bin/b/libb.so)
> > Should it work on Alpine with musl libc as well?
> 
> 1. You explicitly load library with a path (.../liba.so)
> 
> 2. You are explicitly loading another library (.../libb.so)
> 
> 3. Linker find liba.so in the appropriate section of libb.so and attempts to
> load it from syspath (LD_LIBRARY_PATH etc)
> 
> 4. Linker doesn't find it. Musl return error on this step but glibc and BSD
> go further.
> 
> 5. Linker compares short names of already loaded library and the required
> one

this step sounds like implementation specific heuristic
that is not mandated by any spec, so relying on it is
non-portable (and in this case can be dangerous: an
unrelated library may be used because of a name collision)

in principle a dynamic linker can continue even if it
didn't find a library with similar name at all, but that
would be dangerous too.

> 
> 6. It matches, so Linker decides to resolve
> 
> I didn't find any specification that dictates one or other behavior, so it
> could not be considered as a bug.

i think if there is no spec you should not rely on this
behaviour, i.e. it is a portability bug.

  reply	other threads:[~2020-05-28 18:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21 11:27 Alexander Scherbatiy
2020-05-21 15:21 ` Markus Wichmann
2020-05-22 18:07   ` Alexander Scherbatiy
2020-05-22 18:25     ` Rich Felker
2020-05-23 14:12       ` Florian Weimer
2020-05-23 16:05         ` Rich Felker
2020-05-25 17:26       ` Alexander Scherbatiy
2020-05-25 17:46         ` Rich Felker
2020-05-27 18:10           ` Dmitry Samersoff
2020-05-28 18:53             ` Szabolcs Nagy [this message]
2020-05-28 19:20             ` Jeffrey Walton
2020-05-28 19:29               ` Rich Felker
2020-06-04 19:37           ` Alexander Scherbatiy
2020-06-04 19:48             ` Rich Felker

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=20200528185325.GF26190@port70.net \
    --to=nsz@port70.net \
    --cc=alexander.scherbatiy@bell-sw.com \
    --cc=dalias@libc.org \
    --cc=dms@samersoff.net \
    --cc=musl@lists.openwall.com \
    --cc=nullplan@gmx.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).