×

Search anything:

List symbols in a .so file

Internship at OpenGenus

Get this book -> Problems on Array: For Interviews and Competitive Programming

In this article, we have presented different commands which can be used to list all or specific symbols in a given shared object .so file. This involve different commands with nm, objdump and readelf.

Table of contents:

  1. 4 commands with nm
  2. objdump command
  3. readelf command

The different commands to list different symbols in a given shared object (.so) file are as follows:

4 commands with nm

  • To see all symbols in a given so file:
nm --demangle --dynamic <lib.so>

nm is a tool that comes with binutils. To install binutils, use the following steps.

  • To see only symbols that are defined in an .so file (skipping the undefined symbols), use:
nm --demangle --dynamic --defined-only <lib.so>
  • To see only symbols which are available for linking (internal linkage), use:
nm --demangle --dynamic --extern-only <lib.so>
  • To see symbols which are defined and available for linking, use:
nm --demangle --dynamic --defined-only --extern-only <lib.so>
  • To find a specific symbol in the above list, use grep with the command like:
nm --demangle --dynamic --defined-only --extern-only <lib.so> | grep <search>

objdump command

To get the list of symbols in a given .so file using objdump command, use the following:

objdump -TC <lib.so>

readelf command

If the shared object .so file is in ELF format, one can use readelf command as follows to list the symbols:

readelf -Ws <lib.so>

This will list all symbols including the ones in shared objects referenced by the current .so file. To get the symbols in the current .so file, we need to check the information in the 7th column which can be extracted using awk command as follows:

readelf -Ws <lib.so> | awk '{print $8}';

With these commands presented in this article at OpenGenus, you must have a complete idea of how to list the different symbols in a given .so file. You can use this information for debugging "symbol not found" error.

Geoffrey Ziskovin

Geoffrey Ziskovin

Geoffrey Ziskovin is an American Software Developer and Author with an experience of over 30 years. He started his career with Haskell and has interviewed over 700 candidates for Fortune 500 companies

Read More

Improved & Reviewed by:


OpenGenus Foundation OpenGenus Foundation
List symbols in a .so file
Share this