View file call status under Linux system Shell command

  

ldd /full/path/conmmand


1, first ldd is not an executable program, but just a shell script


2, ldd can display the executable module's dependency, the principle is to set a series of environment variables, as follows: LD_TRACE_LOADED_OBJECTS, LD_WARN, LD_BIND_NOW, LD_LIBRARY_VERSION, LD_VERBOSE and so on. When the LD_TRACE_LOADED_OBJECTS environment variable is not empty, when any executable program is running, it will only display the module's dependency, and the program does not actually execute. Otherwise you can test it in the shell terminal, as follows:


(1) export LD_TRACE_LOADED_OBJECTS=1

(2) Execute any program, such as ls, etc. The running result


3, ldd shows the working principle of the executable module's dependency, the essence of which is achieved by ld-linux.so (elf dynamic library loader). We know that the ld-linux.so module will work before the executable module program and gain control, so when the above environment variables are set, ld-linux.so chooses to display the dependency of the executable module.


4, you can actually execute the ld-linux.so module directly, such as: /lib/ld-linux.so.2 --list program (this is equivalent to ldd program) ldd command usage (Excerpt from ldd --help) Name ldd - Print Shared Library Dependencies


Outline ldd [options]... File...


Describe ldd output in A shared library required for each program or shared library specified on the command line.


Options

--version

Printing the version number of ldd

-v --verbose

Printing all information For example, including version information for symbols

-d --data-relocs

Performing symbol redeployment and reporting missing target objects (applicable only to ELF format)

-r --function-relocs

Re-deploy target objects and functions and report missing target objects and functions (only for ELF format)

--help Usage information


Note:

The standard version of ldd is provided with glibc2. Libc5 was previously available with older versions and still exists in some systems. The long option is not supported in the libc5 version. On the other hand, the glibc2 version does not support the -V option, only the equivalent --version option.


If the given library name in the command line contains '/', the libc5 version of this program will use it as the library name; otherwise it will search the library in the standard location. Run a shared library in the current directory, prefix "./".


Error:

ldd cannot work on shared libraries in a.out format.


ldd doesn't work on some very old a.out programs, which were created before the ldd compiler was released. If you use ldd on this type of program, the program will try to run argc = 0, the result is unpredictable.

Copyright © Windows knowledge All Rights Reserved