Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2315290
  • 博文数量: 527
  • 博客积分: 10343
  • 博客等级: 上将
  • 技术积分: 5565
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-26 23:05
文章分类

全部博文(527)

文章存档

2014年(4)

2012年(13)

2011年(19)

2010年(91)

2009年(136)

2008年(142)

2007年(80)

2006年(29)

2005年(13)

我的朋友

分类: LINUX

2010-06-23 10:32:25

在碰到一个 LD_PRELOAD指定的so不能被正确载入时,额外的信息很难获取, 比如, 不能用gdb调试, 不能用strace跟踪, so不能正确载入并不会阻止程序的执行.

在man ld.so时, 看到了LD_DEBUG 环境变量, 于是指定了
LD_DEBUG=1 LD_PRELOAD=my_preload.so test

程序输出:
warning: debug option `1' unknown, try LD_DEBUG=help

这段warning信息应是由ld.so 输出的, 用help替换了上面的1之后, 程序没被执行, 代之以输出了如下的帮助信息:

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.

这种形式的帮助还真是头一回见. 试了all之后, 程序输出了大量的信息(送到stderr), 估计日后再碰到动态库加载失败的情况时, 这些信息能有所帮助.
阅读(928) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~