This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ld and GNU/Linux ld.so disagree on dependent library search order (?)
On Mon, Feb 06, 2006 at 12:42:52PM -0500, Jeremy Brown wrote:
> Ian Lance Taylor <ian@airs.com> writes:
> > ld and ld.so should use the same search path for shared libraries.
> > Anything else is a bug. It sounds like you have found a bug, or else
> > the ld.so behaviour has changed.
>
> Certainly both seem to be behaving as they are documented to; it's
> just that they are documented as behaving differently.
>
> At the bottom of this email is a sequence of commands that illustrates
> the problem on my Fedora core 3 x86_64 box. It relies on the implicit
> dependency of libgnome-2 on libxml2. It needs to be run as root,
> because it adjusts (and then resets) ld.so.conf.
>
> Here's the most interesting part of the output. At this point,
> libxml2 has been copied into /usr/lib/test, and /usr/lib/test is the
> first entry in /etc/ld.so.conf.
>
> 1 sh-3.00# gcc -Xlinker -verbose foo.c -o foo -lgnome-2 2>&1 | grep libxml2
> 2 libxml2.so.2 needed by /usr/lib64/libgnomevfs-2.so.0
> 3 found libxml2.so.2 at /usr/lib64/libxml2.so.2
> 4 sh-3.00# ldd foo | grep libxml2
> 5 libxml2.so.2 => /usr/lib/test/libxml2.so.2 (0x00002aaaac16b000)
> 6 sh-3.00# LD_DEBUG=libs ./foo 2>&1 | grep libxml2
> 7 24661: find library=libxml2.so.2 [0]; searching
> 8 24661: trying file=/usr/lib/test/libxml2.so.2
> 9 24661: calling init: /usr/lib/test/libxml2.so.2
> 10 24661: calling fini: /usr/lib/test/libxml2.so.2 [0]
>
> Note that at line 3, the linker reports finding libxml2 at
> /usr/lib64/libxml2, while at line 5, ldd finds it in /usr/lib/test/ As
> another check, lines 8-10 show that ld.so also finds it in
> /usr/lib/test
>
> As I said, this is consistent with the way both ld and ld.so are
> documented, but very, very annoying. My opinion is that ld is doing
> the wrong thing here: it should favor paths in /etc/ld.so.conf ahead
> of hard-coded system paths.
>
> Should I report this as a bug?
>
> Thanks for your time,
> Jeremy
>
Please open a bug report with a testcase. I will look into it.
Thanks.
H.J.