views:

229

answers:

1

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++.

+1  A: 

One thing you can try is running objdump -T on your binary.

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.

jilles
Thanks, jilles. It works. One more question, how to get location in code from which dynamic symbol is called? I mean, for example, if 'objdump -T' returns some entry, say GLIBCXX_3.4.9 ***Insert_***, how to understand which functions in sources use this symbol?
Shcheklein
hmm, I don't really know a better solution than running objdump -t over all the .o files and checking which ones contain references to the function. It seems that this can be done better as the linker knows where an unresolved symbol was used.
jilles
Ok, thanks. Anyway it's another question ...
Shcheklein