Re: ldd and library dependency



Laurenz Albe wrote:
Frank Hamersley <terabitemightbe@xxxxxxxxxxx> wrote:

My issue is similar only in that library selection is not as I would expect in that libraries from /lib/tls are selected by ldd rather than the /lib instances that I require.

As I did not know the answer right away, I investigated and here is the
result, which I get from

http://people.redhat.com/drepper/assumekernel.html

which I found with a web search.

Some shared libraries contain an OS ABI tag, that is a section that
tells the dynamic loader which kernel version is required to run this
library.

On RedHat systems you can see it with

eu-readelf -n /lib/libm-2.3.2.so

on other systems you can use

objdump -s -j .note.ABI-tag /lib/tls/libm-2.3.2.so

to get a slightly less readable version (bytes 21, 25, and 29 from
the section contain the version numbers).

On my RedHat system, there are some libraries that have versions in
/lib, /lib/i686 and /lib/tls (which stands for Thread-Local Storage),
among them libc, and the OS ABI versions of the libraries increase in
that order (2.2.5, 2.4.1 and 2.4.20, respectively).

The loader chooses the library with the highest ABI version less or equal
to the kernel version.

If for some reason you need to use an older ABI version (that is, load the
library form one of the other directories), you can use the environment
variable LD_ASSUME_KERNEL to tell the loader which kernel version to assume.

So if you insist in loading from /lib (I hope that you have good reasons),
you should set LD_ASSUME_KERNEL to something between 2.2.5 and 2.4.0
(if the numbers on your system are the same as on my system).

Yours,
Laurenz Albe

Brilliant treatise Albe - on investigation this describes my issue down to a tee! You can confirm the /etc/ld.so.cache contents with the ldconfig -p command which exposes the ABI numbers too. Furthermore it shows the various paths that ldconfig scans when building a new cache.

For instance the libpthread was one of my problem libs ...

[root@TERASERV ~]# ldconfig -p | fgrep libpthread
libpthread.so.0 (libc6, hwcap: 0x8000000000000000, OS ABI: Linux 2.4.20) => /lib/tls/libpthread.so.0
libpthread.so.0 (libc6, hwcap: 0x8000000000000, OS ABI: Linux 2.4.1) => /lib/i686/libpthread.so.0
libpthread.so.0 (libc6, OS ABI: Linux 2.2.5) => /lib/libpthread.so.0
[root@TERASERV ~]#

The switch in ldconfig that shows how the tls and i686 paths are discovered seems to be ...

-n Only process directories specified on the command line. Don't process the trusted directories (/lib and /usr/lib) nor those specified in /etc/ld.so.conf. Implies -N.

What it doesn't quite spell out but quite reasonably does is search all subdirectories in the "trusted" paths and include them in the cache. Thereafter the ABI behaviour kicks and and given my CentOS kernel is 2.6 the 2.4.20 version gets the nod! Interestingly this was the old RH7.3 kernel version I was running so I expect this library might have been in use back then. If so, it worked OK on that kernel but not this one!

As I expected I should prolly .rpm in later versions of the tls and i686 libraries from the CentOS yum site and see where that leads! Will report here then.

Cheers, Frank.
.



Relevant Pages

  • Re: [RFC][PATCH 2.6.13-rc6] add Dell Systems Management Base Driver (dcdbas) with sysfs support
    ... You've just created a little interface so you can diddle ... hardware directly from userspace. ... > of what we can put into the kernel to enable our whole managment stack. ... their own proprietary libraries. ...
    (Linux-Kernel)
  • Re: [Bulk] Re: [Bulk] Re: [opensuse] OT: Developer jobs (was defrag)
    ... directory structure let the kernel do faster name lookup. ... (e.g. gnome libraries vs kde ... So the cost of writing code pages to disk doesn't make sense. ... memory mapped, isn't that expensive. ...
    (SuSE)
  • Re: Do 32 bit apps run in x86_64?
    ... do 32 bit apps run in 64 bit Linux? ... 64 bit Linux kernels have full support for 32 bit applications. ... A 32 bit application cannot load 64 bit libraries, ... older kernel you can use VMware Server which is the most stable VM ...
    (comp.os.linux.misc)
  • Re: Dll Hell
    ... but I don't know how intelligent OS/2 is ... in terms of memory allocation when one has multiple copies of the same ... that depends on decisions made by the kernel designers as to ... libraries, ...
    (comp.os.os2.apps)
  • Re: FC1 -> FC2 Update: DISASTER!!! - (not really)
    ... > to services to be started on system startup.) ... > then reinstalled from another repo libraries and all. ... Some X library problems fixed by reinstalling X libs. ... after the second kernel update. ...
    (Fedora)