LD_DEBUG = help ./a.out
Vaild option for LD_DEBUG | |
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 statistic |
unused | determined unused DSOs |
help | display this help message and exit |
LD_DEBUG=libs ./a.out
17315: find library=libc.so.6 [0]; searching 17315: search cache=/etc/ld.so.cache 17315: trying file=/lib/tls/i686/cmov/libc.so.6 17315: 17315: 17315: calling init: /lib/tls/i686/cmov/libc.so.6 17315: 17315: 17315: initialize program: ./a.out 17315: 17315: 17315: transferring control: ./a.out 17315: 17315: 17315: calling fini: ./a.out [0] 17315: 17315: 17315: calling fini: /lib/tls/i686/cmov/libc.so.6 [0] 17315:From above result, it will find the file "ld.so.conf" to know where the standard library is located.
In this case, the library I only use is glibc. So it is a simple code.
But it is handy tool if your program is very complex and you want to know which library is linked.
gcc --share b.c -o libb.so gcc -o a{,.c} -lb -L.Then you should export libary PATH "LD_LIBRARY_PATH"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH;./The program will be executed successfully.
You can try LD_DEBUG again and the loader will search additional path "./" you assigned and load the specific library to memory.
沒有留言:
張貼留言