I've built a simple program like this:
g++ application.cpp -o application.exe
and then executed the command;
ldd application.exe
...
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
...
I want to list all the symbols of the libc
library:
nm /lib/x86_64-linux-gnu/libc.so.6
nm: /lib/x86_64-linux-gnu/libc.so.6: no symbols
nm --defined-only /lib/x86_64-linux-gnu/libc.so.6
nm: /lib/x86_64-linux-gnu/libc.so.6: no symbols
Why nm
reports no symbols? If libc.so.6
is not a library, but some kind of a link to the actual library, then how can I find the actual library?
By default, nm
reads the .symtab
section in ELF objects, which is optional in non-relocatable objects. With the -D
/--dynamic
option, you can instruct nm
to read the dynamic symbol table (which are the symbols actually used at run time). You may also want to use --with-symbol-versions
because glibc uses symbol versioning extensively.
Alternatively, you can use eu-readelf --symbols=.dynsym
or objdump -Tw
. (readelf -sDW
does not include symbol versioning information.)