Shcheklein
Shcheklein

Reputation: 6349

How to determine version of glibc (glibcxx) binary will depend on?

It's well known that glibc (and, as far as I know, glibstd++ also) uses symbol versioning mechanism. (For the details refer: How can I link to a specific glibc version.)

The question is how to determine exact versions of GLIBC and GLIBCXX will be chosen by linker for names from libc and libstdc++? For example, how to get something like this:

time -> time@GLIBC_2_5
...
gethostbyname -> gethostbyname@GLIBC_2_3

Why do we need this? It seems to me that it can be useful if you want to minimize required versions of glibc/libstdc++.

Upvotes: 18

Views: 30504

Answers (2)

张馆长
张馆长

Reputation: 1859

objdump -T  bin-file | grep -Eo 'GLIBC_\S+' | sort -u

Upvotes: 6

jilles
jilles

Reputation: 11252

One thing you can try is running objdump -T on your binary. For example, here's how to see that the /usr/sbin/nordvpnd binary on my system depends on GLIBC version at least 2.18:

$ objdump -T /usr/sbin/nordvpnd | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -Vu      
2.2.5
2.3
2.3.2
2.3.3
2.3.4
2.4
2.7
2.8
2.9
2.10
2.14
2.15
2.16
2.17
2.18

If you are considering linking to older versions of symbols, be aware that these older versions may depend on older, different structures or other definitions as well. To avoid this, compile and link with older, matching header files and libraries.

Upvotes: 33

Related Questions