2008年2月24日星期日

dynamic lib in linux

/etc/ld.so.conf
dynamic libs config file


command : ldconfig
Each time after changing that file, run 'ldconfig' to flush config data.


command : ldd
Check which lib has been linked by an executable.
example : ldd a.out


libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00986000)
libc.so.6 => /lib/tls/libc.so.6 (0x0081c000)
/lib/ld-linux.so.2 (0x007fe000)


command : objdump
Print out many useful information about an executable file.
example : objdump -p a.out


a.out:     文件格式 elf32-i386

程序头:
    PHDR off    0x00000034 vaddr 0x08048034 paddr 0x08048034 align 2**2
         filesz 0x000000e0 memsz 0x000000e0 flags r-x
  INTERP off    0x00000114 vaddr 0x08048114 paddr 0x08048114 align 2**0
         filesz 0x00000013 memsz 0x00000013 flags r--
    LOAD off    0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12
    ....
动态节:
  NEEDED      libpthread.so.0
  NEEDED      libc.so.6
    ....

版本引用:
  required from libpthread.so.0:
    0x0d696910 0x00 04 GLIBC_2.0
    0x0d696911 0x00 03 GLIBC_2.1
  required from libc.so.6:
    0x0d696910 0x00 02 GLIBC_2.0

没有评论: