|
|
Message-ID: <87tsz32vy6.fsf@alyssa.is>
Date: Sun, 09 Nov 2025 14:10:25 +0100
From: Alyssa Ross <hi@...ssa.is>
To: Vivian Wang <wangruikang@...as.ac.cn>
Cc: musl@...ts.openwall.com, matthewcroughan <matt@...ughan.sh>
Subject: Re: [PATCH] ldso: Use rpath of dso of caller in dlopen
Vivian Wang <wangruikang@...as.ac.cn> writes:
> Grab the return address using an arch-specific wrapper dlopen calling a
> generic __dlopen (analogous to dlsym and __dlsym), and use it to find
> the dso to use as needed_by for load_library in __dlopen. This way, when
> a dso calls dlopen, the library is searched from *this* dso's rpath.
>
> This feature is used by shared libraries that dlopen on demand other
> shared libraries found in nonstandard paths.
>
> This makes the behavior of DT_RUNPATH match glibc better. Also, since we
> already use this behavior with libraries loaded with DT_NEEDED, adding
> support for dlopen makes it more consistent.
>
> By coincidence, both __dlsym and __dlopen take three arguments, the last
> of which is the return address. Therefore all of the arch-specific
> src/ldso/*/dlopen.s is just the corresponding dlsym.s with "dlsym"
> replaced by "dlopen".
>
> ---
> I am not subscribed to the mailing list, so please cc on reply. Thanks.
>
> I have primarily tested this on aarch64. I'm not sure whether this
> approach makes sense. Please advise.
>
> One observation is that musl falls back to using rpath entries from the
> entire needed_by chain, so this change in behavior shouldn't break
> existing working use cases.
Delightful to have just come across this issue myself and then discover
that a fix has already been proposed. :)
Fixes dlopen() from RUNPATH from a shared library for me on x86_64.
Tested-by: Alyssa Ross <hi@...ssa.is>
Download attachment "signature.asc" of type "application/pgp-signature" (228 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.