How to find shared library dependencies for a executable in Linux

Published on in Category Linux


Finding shared library dependencies of a executable is very simple using readelf tool which comes with compiler.

If you want to find the dependent for cross platform then you should use the readelf that came with the toolchain. You will need to prefix the platform tupel with -read elf, example for ARM platform the read elf tool will be like arm-linux-gnueabi-readelf

In the below log, NEEDED shows the executable dependent shared library.

$ readelf -d filename
 Dynamic section at offset 0x88bbc contains 25 entries:
 Tag Type Name/Value
 [symple_highlight color="yellow"]0x00000001 (NEEDED) Shared library: [libdl.so.2][/symple_highlight]
 0x00000001 (NEEDED) Shared library: [libpthread.so.0]
 0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
 0x00000001 (NEEDED) Shared library: [libm.so.6]
 0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
 0x00000001 (NEEDED) Shared library: [libc.so.6]
 0x0000000c (INIT) 0x8067cc0
 0x0000000d (FINI) 0x80b5d1c
 0x00000004 (HASH) 0x8048168
 0x00000005 (STRTAB) 0x805631c
 0x00000006 (SYMTAB) 0x804c83c
 0x0000000a (STRSZ) 66424 (bytes)
 0x0000000b (SYMENT) 16 (bytes)
 0x00000015 (DEBUG) 0x0
 0x00000003 (PLTGOT) 0x80d1cb0
 0x00000002 (PLTRELSZ) 512 (bytes)
 0x00000014 (PLTREL) REL
 0x00000017 (JMPREL) 0x8067ac0
 0x00000011 (REL) 0x8067aa0
 0x00000012 (RELSZ) 32 (bytes)
 0x00000013 (RELENT) 8 (bytes)
 0x6ffffffe (VERNEED) 0x80679f0
 0x6fffffff (VERNEEDNUM) 4
 0x6ffffff0 (VERSYM) 0x80666940
 x00000000 (NULL) 0x0

From the above output now we have found out the dependencies are _libdl.so.2, libpthread.so.0, libstdc++.so.6, libm.so.6, libgccs.so.1, libc.so.6



TAGS: linux gcc

Share on: Email Facebook Twitter


View/Write Comments