From: Rich Felker <dalias@libc.org>
To: Alexander Scherbatiy <alexander.scherbatiy@bell-sw.com>
Cc: musl@lists.openwall.com, Markus Wichmann <nullplan@gmx.net>
Subject: Re: [musl] Shared library loading
Date: Thu, 4 Jun 2020 15:48:49 -0400 [thread overview]
Message-ID: <20200604194848.GR1079@brightrain.aerifal.cx> (raw)
In-Reply-To: <c0bb87c2-2d46-8f11-f27f-95ee4d433c62@bell-sw.com>
On Thu, Jun 04, 2020 at 10:37:40PM +0300, Alexander Scherbatiy wrote:
> On 25.05.2020 20:46, Rich Felker wrote:
>
> >On Mon, May 25, 2020 at 08:26:51PM +0300, Alexander Scherbatiy wrote:
> >> What is the suggested way in musl to load $libdir/myapp/libfoo.so
> >>from a custom directory so libbar.so can find it?
> >Probably putting the dir in your application's rpath (or in the rpath
> >of libbar). dlopen is not a tool for (effectively) adding additional
> >directories to the library search path.
>
> OpenJDK can have several jvm variants (like server, client, minimal).
> Each of variants contains its own version of libjvm.so lib.
> jdk/bin/java
> jdk/lib/server/libjvm.so
> jdk/lib/client/libjvm.so
> jdk/lib/minimal/libjvm.so
>
> When java is executed it first loads libjvm.so for the requested variant
> using dlopen() with RTLD_NOW | RTLD_GLOBAL flags [1] and then
> loads libraries from jdk/lib dir with dlopen() and RTLD_LAZY flag.
>
> To make it works with musl JDK implements workaround where
> it puts libjvm.so into LD_LIBRARY_PATH [2] and re-executes itself.
>
> Is there a better way to handle the case where an application
> with several lib variants can load common libraries
> without changing LD_LIBRARY_PATH?
>
> [1] https://hg.openjdk.java.net/portola/portola/file/7ff60204a181/src/java.base/unix/native/libjli/java_md_solinux.c#l590
> [2] https://hg.openjdk.java.net/portola/portola/file/7ff60204a181/src/java.base/unix/native/libjli/java_md_solinux.c#l244
One way to do it would be to make dummy libraries libjvm_server.so,
libjvm_client.so, and libjvm_minimal.so that contain no code or data
but just a DT_NEEDED reference to libjvm.so and an appropriate
DT_RUNPATH to find it.
Rich
prev parent reply other threads:[~2020-06-04 19:49 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
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 [this message]
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=20200604194848.GR1079@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=alexander.scherbatiy@bell-sw.com \
--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).