Viewing dynamic executable dependencies

Large dynamically linked executables can have a LOT of dependencies, which are resolved by the runtime linker when a program is executed. To see which libraries an executable and the executable’s shared dependencies depend on, the ldd utility can be used:

$ ldd /usr/sbin/metastat

        libmeta.so.1 =>  /lib/libmeta.so.1
        libc.so.1 =>     /lib/libc.so.1
        libnsl.so.1 =>   /lib/libnsl.so.1
        libadm.so.1 =>   /lib/libadm.so.1
        libdevid.so.1 =>         /lib/libdevid.so.1
        libgen.so.1 =>   /lib/libgen.so.1
        libefi.so.1 =>   /lib/libefi.so.1
        libdevinfo.so.1 =>       /lib/libdevinfo.so.1
        libscf.so.1 =>   /lib/libscf.so.1
        libmp.so.2 =>    /lib/libmp.so.2
        libmd5.so.1 =>   /lib/libmd5.so.1
        libuuid.so.1 =>  /lib/libuuid.so.1
        libnvpair.so.1 =>        /lib/libnvpair.so.1
        libdoor.so.1 =>  /lib/libdoor.so.1
        libuutil.so.1 =>         /lib/libuutil.so.1
        libsocket.so.1 =>        /lib/libsocket.so.1
        libm.so.2 =>     /lib/libm.so.2
        /platform/SUNW,Ultra-5_10/lib/libc_psr.so.1
        /platform/SUNW,Ultra-5_10/lib/libmd5_psr.so.1

To view just the shared libraries that the executable depends on, the elfdump “-d” (dump the contents of the dynamic symbol table) option can be used:

$ /usr/ccs/bin/elfdump -d /usr/sbin/metastat | grep NEEDED

       [0]  NEEDED           0x867             libmeta.so.1
       [1]  NEEDED           0x884             libc.so.1

In the examples above, metastat only requires two libraries, but those two libraries have numerous dependencies.

Leave a Reply

Your email address will not be published. Required fields are marked *