1. LD_DBUG环境变量的使用可以查看可执行文件在启动时的动态加载共享库的过程
LD_DEBUG 自带命令帮助,方法是 LD_DEBUG=help xxx (任意可执行命令程序),例如 'LD_DEBUG=help ls’ 就可以输入环境便令LD_DEBUG的使用帮助
#查看LD_DEBUG环境变量的使用帮助
LD_DEBUG=help ls
帮助信息
root@xx:/home # LD_DEBUG=help 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
scopes display scope information
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@xx:/home #
2. 查看链接的文件
查看LD_DEBUG=files
查看程序执行需要的文件和链接库
root@xx:/home # LD_DEBUG=files ls
20397:
20397: file=libmdm.so [0]; needed by ls [0]
20397: file=libmdm.so [0]; generating link map
20397: dynamic: 0x0000007f8e331d40 base: 0x0000007f8e2d1000 size: 0x000000000009b000
20397: entry: 0x0000007f8e2dbaa0 phdr: 0x0000007f8e2d1040 phnum: 6
20397:
3. 查看链接libs
查看LD_DEBUG=libs
查看程序执行需要链接库
root@xx/home # LD_DEBUG=libs ls
20717: find library=libmdm.so [0]; searching
20717: search cache=/etc/ld.so.cache
20717: search path=/lib64/tls/aarch64:/lib64/tls:/lib64/aarch64:/lib64:/usr/lib64/tls/aarch64:/usr/lib64/tls:/usr/lib64/aarch64:/usr/lib64 (system search path)
20717: trying file=/lib64/tls/aarch64/libmdm.so
20717: trying file=/lib64/tls/libmdm.so
20717: trying file=/lib64/aarch64/libmdm.so
20717: trying file=/lib64/libmdm.so