Multiple values for LD_LIBRARY_PATH in LD_DEBUG outputs
Jeffrey Walton
noloader@gmail.com
Sun Sep 8 23:58:14 GMT 2024
On Sun, Sep 8, 2024 at 7:05 PM Nima Hamidi <nimaa.hamidi@gmail.com> wrote:
>
> Thanks for your response.
>
> I don’t think you’re right about LD_LIBRARY_PATH. I do see cases where the variable is colon separated, but that appears once in “search path=“ with multiple “trying” lines following it. The issue is I see multiple “search path=“ with different values for a single “find library=“.
>
> Re linking, I don’t have much control over the build process. I’m trying to better understand what I’m seeing.
You might want to take a look at Drepper's SHared Library HowTo at
<https://www.cs.dartmouth.edu/~sergey/cs108/ABI/UlrichDrepper-How-To-Write-Shared-Libraries.pdf>.
The document explains the runtime link-loader behavior.
Jeff
> On Sep 8, 2024 at 5:51 PM -0500, Jeffrey Walton <noloader@gmail.com>, wrote:
>
> On Sun, Sep 8, 2024 at 5:35 PM Nima Hamidi via Libc-help
> <libc-help@sourceware.org> wrote:
>
>
> Hello all,
>
> I’m debugging a DSO loading issue, and I’ve set LD_DEBUG=libs prior to running my binary. In the output, I see chunks of output of the form:
>
> find library=libfoo.so [0] searching
> search path=<path-1> (LD_LIBRARY_PATH)
> trying file=<path-1>/libfoo.so
> search path=<path-2> (RPATH from file libbar.so)
> trying file=<path-2>/libfoo.so
> search path=<path-3> (LD_LIBRARY_PATH)
> trying file=<path-3>/libfoo.so
> search path=<path-4> (RPATH from file libbar.so)
> trying file=<path-4>/libfoo.so
>
> Why do I see multiple (LD_LIBRARY_PATH) in this chunk? Would you not expect to see one? And would you not expect that to match my LD_LIBRARY_PATH output (which is not the case)? Same question about RPATH corresponding to each individual DSO.
>
>
> There's two parts to the answer.
>
> LD_LIBRARY_PATH=<path_1>:<path_2>:...;
>
> First, you are seeing the directory walk of path_1, path_2, ..., path_n.
>
> Second, you also need to link with -Wl,--enable-new-dtags. The option
> enables RUNPATHs, and RUNPATHs allow LD_LIBRARY_PATH overrides.
> Without the option, you would merely have a RPATH, and a RPATH does
> not allow overrides.
>
> Jeff
More information about the Libc-help
mailing list