An example usage of LD_DEBUG looks like this:
LD_DEBUG=libs is just an assignment - so how it works (prints result) in bash ?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
LD_DEBUG in that context is an environment variable that you've assigned the value of
libs to. This on its own does does nothing except put
LD_DEBUG into the environment of the command you just started.
When you start a dynamically linked executable on of the first things that happens is the dynamic linker
ld.so(8) does runtime linking and symbol resolution. The code in the dynamic linker that does this can read environment variables, as can any compiled code. This program reads this environment variable and many others and modifies its behavior based upon them. The man page details all of the environment variables that effect the dynamic linker.
LD_DEBUG is evaluated in ld.so.1 (the dynamic linker that is called from the ELF binary)
Check the man page for the dynamic linker at:
Nothing is done in the shell, everything is done "by" the executed binary.
BTW: the command
ldd does nothing special, it just sets some LD_* variables and then tries to start the command. If no options are specified, ldd just sets
and the related sourcecode.