ldd 函式庫工具

  1. Linux 放置函式庫之目錄:
    [dywang@dyw219 make1]$ ll -d /lib{,64} /usr/lib{,64}
    dr-xr-xr-x.  12 root root  4096 Nov 29 18:10 /lib
    dr-xr-xr-x.  10 root root 12288 Sep 29  2018 /lib64
    dr-xr-xr-x.  33 root root  4096 Nov 29 18:10 /usr/lib
    dr-xr-xr-x. 146 root root 77824 Feb 14 03:33 /usr/lib64
    
  2. ldd 輔助說明
    [dywang@dyw219 make1]$ ldd --help
    Usage: ldd [OPTION]... FILE...
          --help              print this help and exit
          --version           print version information and exit
      -d, --data-relocs       process data relocations
      -r, --function-relocs   process data and function relocations
      -u, --unused            print unused direct dependencies
      -v, --verbose           print all information
    
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/libc/bugs.html>.
    
  3. 找出執行檔 main 使用的那些動態函式庫?
    [dywang@dyw219 make1]$ ldd main
    	linux-vdso.so.1 =>  (0x00007ffe741f9000)
    	libc.so.6 => /lib64/libc.so.6 (0x000000394aa00000)
    	/lib64/ld-linux-x86-64.so.2 (0x000055836ce6b000)
    
  4. 再找出函式 /lib64/libc.so.6 的相關其他函式庫。
    [dywang@dyw219 make1]$ ldd /lib64/libc.so.6 
    	/lib64/ld-linux-x86-64.so.2 (0x0000558d8c22f000)
    	linux-vdso.so.1 =>  (0x00007ffd3d158000)