I have a shared object (dll). How do I find out what all symbols are exported from that?
-
1All symbols in the object are exported - even the "internal" functions. You just have to declare them to the compiler so that they'll be ready for the linker. This is usually done with a header file, like Ryan Fox said below. – Chris Lutz Aug 06 '09 at 08:27
-
10Chris Lutz is mistaken: not all symbols are exported from relocatable object files, much less from shared libraries. – Employed Russian Aug 09 '09 at 04:20
-
http://en.wikipedia.org/wiki/Nm_%28Unix%29 – pauljwilliams Aug 06 '09 at 08:25
-
Does this answer your question? [How do I list the symbols in a .so file](https://stackoverflow.com/questions/34732/how-do-i-list-the-symbols-in-a-so-file) – George Hawkins Jan 30 '21 at 13:15
9 Answers
Do you have a "shared object" (usually a shared library on AIX), a UNIX shared library, or a Windows DLL? These are all different things, and your question conflates them all :-(
- For an AIX shared object, use
dump -Tv /path/to/foo.o
. - For an ELF shared library, use
readelf -Ws --dyn-syms /path/to/libfoo.so
, or (if you have GNU nm)nm -D /path/to/libfoo.so
. - For a non-ELF UNIX shared library, please state which UNIX you are interested in.
- For a Windows DLL, use
dumpbin /EXPORTS foo.dll
.

- 199,314
- 34
- 295
- 362
-
9In GNU/Linux no such an utility «dumpbin». And the question is tagged as linux. – Hi-Angel Aug 31 '14 at 16:08
-
3Very helpful, good to have such overview. `nm` also works on MacOSX, except the `-D` option. Or `brew install binutils` and use the GNU version via `gnm`. For GNU `nm`, `--demangle` is also useful. Also `gobjdump`. – Albert Dec 24 '14 at 12:43
-
Actually, you can work both with shared libraries, dlls, and object filles from a single utility just fine, [see this answer](https://stackoverflow.com/a/46772557/2388257). – Hi-Angel Oct 16 '17 at 14:27
-
The question is tagged `linux` so I think it is safe to say @chappar has a Linux shared library. – jww Aug 26 '18 at 19:13
-
I suppose there is no API to do this in runtime, right? I've found that on windows you have GetProcAddress() but you can't use it without actually executing the library (which is very dangerous if the parent app has too much access rights). – Pablo Ariel Oct 11 '18 at 13:21
-
-
-
objdump is another good one on linux.

- 2,547
- 1
- 19
- 12
-
-
1As covered nicely in this [SO answer](https://stackoverflow.com/a/34796/245602), one would use it like so... `objdump -TC /path/to/libfoo.so`. – George Hawkins Jan 30 '21 at 13:13
If it is a Windows DLL file and your OS is Linux then use winedump:
$ winedump -j export pcre.dll
Contents of pcre.dll: 229888 bytes
Exports table:
Name: pcre.dll
Characteristics: 00000000
TimeDateStamp: 53BBA519 Tue Jul 8 10:00:25 2014
Version: 0.00
Ordinal base: 1
# of functions: 31
# of Names: 31
Addresses of functions: 000375C8
Addresses of name ordinals: 000376C0
Addresses of names: 00037644
Entry Pt Ordn Name
0001FDA0 1 pcre_assign_jit_stack
000380B8 2 pcre_callout
00009030 3 pcre_compile
...

- 19,221
- 20
- 87
- 122
On *nix check nm. On windows use the program Dependency Walker

- 253
- 2
- 8
-
4Specifically, `nm --defined-only -g something.so` will print the symbols that are both defined in the library and extern symbols, which is probably what the OP wants. – David Grayson Jul 24 '15 at 00:19
see man nm
GNU nm lists the symbols from object files objfile.... If no object files are listed as arguments, nm assumes the file a.out.

- 95,432
- 20
- 163
- 226
-
8btw: for shared objects you need the -D/--dynamic option. e.g. nm -D libmagic.so – VolkerK Aug 06 '09 at 08:28
-
3`nm: /usr/lib/i386-linux-gnu/libtemplates_parser.so.11.6: no symbols`. `readelf` or `-D` flag works. – Janus Troelsen Feb 27 '13 at 18:52
The cross-platform way (not only cross-platform itself, but also working, at the very least, with both *.so
and *.dll
) is using reverse-engineering framework radare2. E.g.:
$ rabin2 -s glew32.dll | head -n 5
[Symbols]
vaddr=0x62afda8d paddr=0x0005ba8d ord=000 fwd=NONE sz=0 bind=GLOBAL type=FUNC name=glew32.dll___GLEW_3DFX_multisample
vaddr=0x62afda8e paddr=0x0005ba8e ord=001 fwd=NONE sz=0 bind=GLOBAL type=FUNC name=glew32.dll___GLEW_3DFX_tbuffer
vaddr=0x62afda8f paddr=0x0005ba8f ord=002 fwd=NONE sz=0 bind=GLOBAL type=FUNC name=glew32.dll___GLEW_3DFX_texture_compression_FXT1
vaddr=0x62afdab8 paddr=0x0005bab8 ord=003 fwd=NONE sz=0 bind=GLOBAL type=FUNC name=glew32.dll___GLEW_AMD_blend_minmax_factor
As a bonus, rabin2
recognizes C++ name mangling, for example (and also with .so
file):
$ rabin2 -s /usr/lib/libabw-0.1.so.1.0.1 | head -n 5
[Symbols]
vaddr=0x00027590 paddr=0x00027590 ord=124 fwd=NONE sz=430 bind=GLOBAL type=FUNC name=libabw::AbiDocument::isFileFormatSupported
vaddr=0x0000a730 paddr=0x0000a730 ord=125 fwd=NONE sz=58 bind=UNKNOWN type=FUNC name=boost::exception::~exception
vaddr=0x00232680 paddr=0x00032680 ord=126 fwd=NONE sz=16 bind=UNKNOWN type=OBJECT name=typeinfoforboost::exception_detail::clone_base
vaddr=0x00027740 paddr=0x00027740 ord=127 fwd=NONE sz=235 bind=GLOBAL type=FUNC name=libabw::AbiDocument::parse
Works with object files too:
$ g++ test.cpp -c -o a.o
$ rabin2 -s a.o | head -n 5
Warning: Cannot initialize program headers
Warning: Cannot initialize dynamic strings
Warning: Cannot initialize dynamic section
[Symbols]
vaddr=0x08000149 paddr=0x00000149 ord=006 fwd=NONE sz=1 bind=LOCAL type=OBJECT name=std::piecewise_construct
vaddr=0x08000149 paddr=0x00000149 ord=007 fwd=NONE sz=1 bind=LOCAL type=OBJECT name=std::__ioinit
vaddr=0x080000eb paddr=0x000000eb ord=017 fwd=NONE sz=73 bind=LOCAL type=FUNC name=__static_initialization_and_destruction_0
vaddr=0x08000134 paddr=0x00000134 ord=018 fwd=NONE sz=21 bind=LOCAL type=FUNC name=_GLOBAL__sub_I__Z4funcP6Animal

- 4,933
- 8
- 63
- 86
You can use gnu objdump. objdump -p your.dll
. Then pan to the .edata
section contents and you'll find the exported functions under [Ordinal/Name Pointer] Table
.

- 151
- 1
- 4
Usually, you would also have a header file that you include in your code to access the symbols.

- 10,103
- 5
- 38
- 48