Linux 应用调试技术/动态链接器
外观
- ldd -d -r /path/to/binary
- 一个用于可视化库及其依赖关系的脚本。
- 二进制文件分析工具
- tldd
找出哪个动态库来自符号
$ LD_DEBUG_OUTPUT=sym.log LD_DEBUG=bindings /bin/ls
$ cat sym.log.7688 | grep malloc
7688: binding file /lib/i686/cmov/libc.so.6 [0] to /lib/i686/cmov/libc.so.6 [0]: normal symbol `__malloc_initialize_hook' [GLIBC_2.0]
7688: binding file /lib/i686/cmov/libc.so.6 [0] to /bin/ls [0]: normal symbol `malloc' [GLIBC_2.0]
7688: binding file /lib/i686/cmov/libc.so.6 [0] to /lib/i686/cmov/libc.so.6 [0]: normal symbol `__malloc_hook' [GLIBC_2.0]
7688: binding file /lib/ld-linux.so.2 [0] to /lib/i686/cmov/libc.so.6 [0]: normal symbol `malloc' [GLIBC_2.0]
7688: binding file /lib/i686/cmov/libc.so.6 [0] to /lib/i686/cmov/libc.so.6 [0]: normal symbol `malloc' [GLIBC_2.0]
7688: binding file /bin/ls [0] to /lib/i686/cmov/libc.so.6 [0]: normal symbol `malloc' [GLIBC_2.0]
$ LD_DEBUG=help /bin/ls
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.
- man 8 ld.so
- libc 符号可见性和链接
- 它在授予应用程序程序的任何凭据下运行;因此,例如,如果正在执行一个 set-user-ID-root 程序,动态链接器将以 root 的有效用户 ID 运行。