[ldd]
ldd prints the shared libraries required by each program or shared library specified on the command line.
类似Windows下depends.exe.
[ld]- The GNU linker
1. ld combines a number of object and archive files, relocates their data and ties up symbol references. Usually the last step in compiling a program is to run ld.
2. ld -o <output> /lib/crt0.o hello.o -lc
Tells ld to produce a file called output as the result of linking the file /lib/crt0.o with hello.o and the library libc.a, which will come from the standard search directories.
3. If the linker is being invoked indirectly, via a compiler driver(e.g. gcc) then all the linker command line options should be prefixed by -W1.
gcc -Wl, --start-group foo.o bar.o -Wl, --end-group
gcc foo.o bar.o -Wl, -eENTRY -Wl, -Map=a.map
4. -rpath=dir
Add a directory to the runtime library search path. This is used when linking an ELF executable with shared objects.
5. --no-undefined
Report unresolved symbol references from regular object files.
6. --[no-]allow-shlib-undefined
Allows or disallows undefined symbols in shared libraries.
7. --unresolved-symbols=method: Determine how to handle unresolved symbols. Four values for method:
1) ignore-all: Do not report any unresolved symbols.
2) report-all: Report all unresolved symbols. This is the default.
3) ignore-in-object-files: Report unresolved symbols that are contained in shared libraries, but ignore them if they come from regular object files.
4) ignore-in-shared-libs: Report unresolved symbols that come from regular object files, but ignore them if they come from shared libraries. This can be useful when creating a dynamic binary and it is known that all the shared libraries that it should be referencing are included on the linker's command line.
The behavior for shared libraries on their own can also be controlled by the --[no-]allow-shlib-undefined option.
[ld.so ld-linux.so]- Dynamic linker/loader http://linux.die.net/man/8/ld.so
The program ld.so and ld-linux.so find and load the shared libraries needed by a program, prepare the program to run, and then run it. Linux libraries require dynamic linking(linking at runtime) unless the -static option was given to ld, during compilation.
The program ld.so handles a.out binaries, a format used long ago; ld-linux.so handles ELF, which everybody has been using for years now. Otherwise both have the same behavior, and use the same support files and programs ldd, ldconfig and /etc/ld.so.conf.
5. Environment variables:
1) LD_BIND_NOW: If set to a nonempty string, causes the dynamic linker to resolve all symbols at program startup instead of deferring function call resolution to the point when they are first referenced. Useful when using a debugger.
2) LD_LIBRARY_PATH: A colon-separated list of directories in which to search for ELF libraries at execution-time.
3) LD_PRELOAD: A whitespace-sperated list of additional, user-specified, ELF shared libraries to be loaded before all others.
4) LD_TRACE_LOADED_OBJECTS: (ELF only) If set to a nonempty string ,causes the program to list its dynamic library dependencies, as if run by ldd, instead of running mormally.
5) LD_DEBUG: Output verbose debugging information about the dynamic linker. If set to all, prints all debugging information it has, if set to help, prints a help message about which categories can be specified in this environment variable.
[Reference]
Linux Man Page & Linux Doc