The linker can presumably do this, so is there a command-line tool to list functions in object files and tell me the names of functions and their signatures?
For a shared library, you have to use:
nm -D /path/to/libwhatever.so.<num>
Without the -D
, nm
dumps debug symbols; -D
refers to the dynamic symbols that are actually used for dynamic linking. From Ubuntu 12 session:
$ nm /lib/i386-linux-gnu/libc.so.6
nm: /lib/i386-linux-gnu/libc.so.6: no symbols
$ nm -D /lib/i386-linux-gnu/libc.so.6 | tail
0011fc20 T xdr_wrapstring
001202c0 T xdrmem_create
00115540 T xdrrec_create
001157f0 T xdrrec_endofrecord
00115740 T xdrrec_eof
00115690 T xdrrec_skiprecord
00120980 T xdrstdio_create
00120c70 T xencrypt
0011d330 T xprt_register
0011d450 T xprt_unregister
On this system libc.so
is stripped of debug symbols, so nm
shows nothing; but of course there are symbols for the dynamic linking mechanism revealed by nm -D
.
For a .a
archive or .o
object file, just nm
. The symbols are the symbols; if these files are stripped, these objects cannot be used for linking.
As covered in this similar question:
Exported sumbols are indicated by a
T
. Required symbols that must be loaded from other shared objects have aU
. Note that the symbol table does not include just functions, but exported variables as well.
Or if you only want to see exported symbols, add the
--defined-only
flag. eg:nm -D --defined-only /lib/libtest.so
you can do nm Linux.so
and it'll show the functions and variables inside the .so file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With