Multiple values for LD_LIBRARY_PATH in LD_DEBUG outputs
Jeffrey Walton
noloader@gmail.com
Sun Sep 8 22:51:17 GMT 2024
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