2015年4月20日 星期一

Linux Shared Library Informantion

1.get .so file info
(http://unix.stackexchange.com/questions/58846/viewing-linux-library-executable-version-info)

Get all Info
readelf -a -W elffile

Example :
readelf -a -W  libmysqlclient.so.16


readelf -d  /path/to/library.so |grep SONAME

Example :
readelf -d libmysqlclient.so.16 | grep SONAME
 0x000000000000000e (SONAME)             Library soname: [libmysqlclient.so.16]


2. check dependencies

ldd  /path/to/library.so

Example:
ldd libmysqlclient.so.16
        linux-vdso.so.1 =>  (0x00007fff9ebae000)
        libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f47b438b000)
        libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f47b4171000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f47b3eed000)
        libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007f47b3c81000)
        libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007f47b38a0000)
        libz.so.1 => /lib64/libz.so.1 (0x00007f47b368a000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f47b32f6000)
        libfreebl3.so => /lib64/libfreebl3.so (0x00007f47b307c000)
        libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f47b2e38000)
        libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f47b2b52000)
        libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f47b294d000)
        libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f47b2721000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f47b251d000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f47b4951000)
        libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f47b2311000)
        libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f47b210e000)
        libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f47b1ef4000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f47b1cd6000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f47b1ab7000)

3. Static、Shared Dynamic and Loadable Libraries
(http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html)

  1. Static libraries (.a): Library of object code which is linked with, and becomes part of the application.
  2. Dynamically linked shared object libraries (.so): There is only one form of this library but it can be used in two ways.
    1. Dynamically linked at run time but statically aware. The libraries must be available during compile/link phase. The shared objects are not included into the executable component but are tied to the execution.
    2. Dynamically loaded/unloaded and linked during execution (i.e. browser plug-in) using the dynamic linking loader system functions.