- Original text: https://linuxtools-rst.readthedocs.io/zh_CN/latest/tool/ldd.html
- ldd
- Function: Used to view shared libraries needed by a program to run, often used to solve problems that a program cannot run because it lacks a library file.
Example: look at the library that test programs run on:
/opt/app/todeav1/test$ldd test
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000039a7e00000)
libm.so.6 => /lib64/libm.so.6 (0x0000003996400000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000039a5600000)
libc.so.6 => /lib64/libc.so.6 (0x0000003995800000)
/lib64/ld-linux-x86-64.so.2 (0x0000003995400000)
- Column 1: what libraries should the program rely on?
- The second column: the library corresponding to the library needed by the system.
- The third column: the beginning address of the library load.
Through the above information, we can get the following information:
- By comparing the first and second columns, we can analyze whether the libraries that the program depends on match what the system actually provides.
- By looking at the third column, we can see where the symbols in the current library start in the address space of the corresponding process
If a library is not found, this command can quickly locate the problem.
annotation
Principle: LDD is not an executable program, but a shell script; LDD shows the working principle of the dependency of the executable module, the essence of which is realized by ld-linux.so (the loader of the elf dynamic library). Ld-linux.sThe O module works prior to the executable module program and gains control, so ld-linux.so selects dependency to display the executable module when those environment variables are set.