关于LD_DEBUG

原文地址:http://blog.csdn.net/wshn13/article/details/7549151

 

LD_DEBUG 是 glibc 中的 loader 为了方便自身调试而设置的一个环境变量。通过设置这个环境变量,可以方便的看到 loader 的加载过程。 

LD_DEBUG=help ./main

Valid options for the LD_DEBUG environment variable are:


  libs        display library search paths
  reloc       display relocation processing
  files       display progress for input file
  symbols     display symbol table processing
  bindings    display information about symbol binding
  versions    display version dependencies
  all         all previous options combined
  statistics  display relocation statistics
  unused      determined unused DSOs
  help        display this help message and exit


To direct the debugging output into a file instead of standard output
a filename can be specified using the LD_DEBUG_OUTPUT environment variable.


用法 root@wshn$LD_DEBUG=libs ./main

4452:find library=libc.so.6 [0]; searching
      4452: search cache=/etc/ld.so.cache
      4452:  trying file=/lib/i386-linux-gnu/libc.so.6
      4452:
      4452:
      4452: calling init: /lib/i386-linux-gnu/libc.so.6
      4452:
      4452:
      4452: initialize program: ./main
      4452:
      4452:
      4452: transferring control: ./main
      4452:
Hello
      4452:
      4452: calling fini: ./main [0]
      4452:
      4452:
      4452: calling fini: /lib/i386-linux-gnu/libc.so.6 [0]
      4452:

LD_DEBUG的可选参数在help里面可以看见其复用形式

LD_DEBUG=libs,symbols ./main


输出log保存可以使用LD_DEBUG=all LD_DEBUG_OUTPUT=log  ./main  会生成一个output指定文件名加进程号结尾的文件

例如:log.4476

内容:太长就不贴了 

 

 

 

你可能感兴趣的:(关于LD_DEBUG)