Re: ldd and library dependency



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
.



Relevant Pages

  • Re: Why C is really a bad programming language
    ... |> library for the old ABI, and use a new library for a new ABI (ABI's might ... | another it is not feasible or acceptable to recompile it with the ... | headers for the new library. ... A system can allow for multiple ABIs by having libraries for each (in ...
    (comp.lang.c)
  • Re: Linking with ld instead of g++
    ... Gcc maintainers try to keep stable ABI ... Static linking doesn't buy anything much against OS hackers, ... a security hole in libraries (and those security holes are not few ... the last time I saw hacked C libraries was with SunOS 4.x; ...
    (comp.unix.programmer)
  • Re: good c compiler
    ... ABI for the platforms he is targeting. ... Same problem in reverse if the library is compiled with MSVC and the header refers to long double, although way round you can fix it by changing the header. ... Note that I'm NOT saying Jabob's decision is bad or unreasonable, just something the users of his compiler need to be aware of IF their code will be linked with code compiled with other compilers. ... I was not talking about libraries written BY MS, I was talking about libraries build USING MSVC. ...
    (comp.lang.c)
  • Re: What is an ABI?
    ... An ABI is a set of rules specifying how a binary executable should ... exchange information with some service (e.g., ... then the compiler generates different code for operations such as ... PIC is needed for shared libraries, ...
    (comp.unix.programmer)
  • Re: ldd and library dependency
    ... Laurenz Albe wrote: ... expect in that libraries from /lib/tls are selected by ldd rather than the /lib instances that I require. ... Some shared libraries contain an OS ABI tag, ... to the kernel version. ...
    (comp.os.linux.setup)