List available functions in a shared library .so file


Recently, we wanted to see if a certain function call was available in a shared library (.so).

To do so we used the command nm.
nm lists symbols from object files.

We used the command nm -D /libs/mylib.so.1.
The parameter -D (or --dynamic) displays the dynamic symbols rather than the normal symbols.  (This is only meaningful for dynamic objects, such as certain types of shared libraries.)

We got a huge list which was similar to this

...
000000000000e6e0 T sudo_SHA512Update
000000000000eb20 T sudo_sig2str
000000000000b970 T sudo_strlcat
000000000000b910 T sudo_strlcpy
0000000000006f60 T sudo_strsplit_v1
00000000000070a0 T sudo_strtobool_v1
0000000000007330 T sudo_strtoid_v1
0000000000007570 T sudo_strtomode_v1
000000000000bb20 T sudo_strtonum
000000000000ac20 T sudo_term_cbreak_v1
000000000000adb0 T sudo_term_copy_v1
000000000021339c B sudo_term_erase
00000000002133a0 B sudo_term_kill
000000000000a920 T sudo_term_noecho_v1
000000000000aa80 T sudo_term_raw_v1
000000000000a860 T sudo_term_restore_v1
00000000000052a0 T sudo_vfatal_nodebug_v1
00000000000052d0 T sudo_vfatalx_nodebug_v1
0000000000005480 T sudo_vwarn_nodebug_v1
00000000000054b0 T sudo_vwarnx_nodebug_v1
00000000000055c0 T sudo_warn_gettext_v1
00000000000052f0 T sudo_warn_nodebug_v1
00000000000055a0 T sudo_warn_set_conversation_v1
...

We filtered out all elements that had the value T or t on the second column as those objects are symbol in the text (code) section and we found the function call we wanted there!

This post is also available in: Greek

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.