2004-11-03 13:51:07 +00:00
|
|
|
.\" This is in the public domain
|
2009-01-12 09:58:14 +00:00
|
|
|
.TH LD.SO 8 2009-01-12 "GNU" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
ld.so, ld-linux.so* \- dynamic linker/loader
|
2007-05-18 16:06:42 +00:00
|
|
|
.SH SYNOPSIS
|
2008-04-18 20:38:02 +00:00
|
|
|
The dynamic linker can be run either indirectly by running some
|
2008-03-19 08:37:35 +00:00
|
|
|
dynamically linked program or library (in which case no command-line options
|
2007-05-18 16:06:42 +00:00
|
|
|
to the dynamic linker can be passed and, in the ELF case, the dynamic linker
|
|
|
|
which is stored in the
|
|
|
|
.B .interp
|
|
|
|
section of the program is executed) or directly by running:
|
|
|
|
.P
|
|
|
|
.I /lib/ld-linux.so.*
|
|
|
|
[OPTIONS] [PROGRAM [ARGUMENTS]]
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
The programs
|
|
|
|
.B ld.so
|
|
|
|
and
|
|
|
|
.B ld-linux.so*
|
|
|
|
find and load the shared libraries needed by a program, prepare
|
|
|
|
the program to run, and then run it.
|
|
|
|
.LP
|
|
|
|
Linux binaries require dynamic linking (linking at run time)
|
|
|
|
unless the
|
|
|
|
.B \-static
|
|
|
|
option was given to
|
2007-06-23 07:56:56 +00:00
|
|
|
.BR ld (1)
|
2004-11-03 13:51:07 +00:00
|
|
|
during compilation.
|
|
|
|
.LP
|
|
|
|
The program
|
|
|
|
.B ld.so
|
|
|
|
handles a.out binaries, a format used long ago;
|
|
|
|
.B ld-linux.so*
|
2005-11-02 13:55:25 +00:00
|
|
|
handles ELF (\fI/lib/ld-linux.so.1\fP for libc5, \fI/lib/ld-linux.so.2\fP
|
2004-11-03 13:51:07 +00:00
|
|
|
for glibc2), which everybody has been using for years now.
|
2007-06-08 09:56:56 +00:00
|
|
|
Otherwise both have the same behavior, and use the same
|
2004-11-03 13:51:07 +00:00
|
|
|
support files and programs
|
|
|
|
.BR ldd (1),
|
|
|
|
.BR ldconfig (8)
|
|
|
|
and
|
|
|
|
.IR /etc/ld.so.conf .
|
|
|
|
.LP
|
|
|
|
The shared libraries needed by the program are searched for
|
2008-04-18 20:38:02 +00:00
|
|
|
in the following order:
|
|
|
|
.IP o 3
|
|
|
|
(ELF only) Using the directories specified in the
|
|
|
|
DT_RPATH dynamic section attribute
|
2004-11-03 13:51:07 +00:00
|
|
|
of the binary if present and DT_RUNPATH attribute does not exist.
|
|
|
|
Use of DT_RPATH is deprecated.
|
|
|
|
.IP o
|
|
|
|
Using the environment variable
|
|
|
|
.BR LD_LIBRARY_PATH .
|
2007-04-12 22:42:49 +00:00
|
|
|
Except if the executable is a set-user-ID/set-group-ID binary,
|
2005-07-18 14:25:42 +00:00
|
|
|
in which case it is ignored.
|
2004-11-03 13:51:07 +00:00
|
|
|
.IP o
|
2008-04-18 20:38:02 +00:00
|
|
|
(ELF only) Using the directories specified in the
|
|
|
|
DT_RUNPATH dynamic section attribute
|
2004-11-03 13:51:07 +00:00
|
|
|
of the binary if present.
|
|
|
|
.IP o
|
|
|
|
From the cache file
|
2007-09-20 16:26:31 +00:00
|
|
|
.I /etc/ld.so.cache
|
2004-11-03 13:51:07 +00:00
|
|
|
which contains a compiled list of candidate libraries previously found
|
2007-04-12 22:42:49 +00:00
|
|
|
in the augmented library path.
|
2008-04-18 20:38:02 +00:00
|
|
|
If, however, the binary was linked with the
|
2005-07-06 07:41:37 +00:00
|
|
|
.B \-z nodeflib
|
2004-11-03 13:51:07 +00:00
|
|
|
linker option, libraries in the default library paths are skipped.
|
|
|
|
.IP o
|
|
|
|
In the default path
|
2005-11-02 13:55:25 +00:00
|
|
|
.IR /lib ,
|
2004-11-03 13:51:07 +00:00
|
|
|
and then
|
2005-11-02 13:55:25 +00:00
|
|
|
.IR /usr/lib .
|
2008-04-18 20:38:02 +00:00
|
|
|
If the binary was linked with the
|
2005-07-06 07:41:37 +00:00
|
|
|
.B \-z nodeflib
|
2004-11-03 13:51:07 +00:00
|
|
|
linker option, this step is skipped.
|
2007-05-26 11:55:36 +00:00
|
|
|
.SS $ORIGIN and rpath
|
|
|
|
.PP
|
|
|
|
.B ld.so
|
|
|
|
understands the string
|
|
|
|
.I $ORIGIN
|
2007-06-21 22:55:04 +00:00
|
|
|
(or equivalently
|
2007-05-26 11:55:36 +00:00
|
|
|
.IR ${ORIGIN} )
|
|
|
|
in an rpath specification (DT_RPATH or DT_RUNPATH) to mean
|
2007-05-27 16:38:26 +00:00
|
|
|
the directory containing the application executable.
|
2007-05-26 11:55:36 +00:00
|
|
|
Thus, an application located in
|
|
|
|
.I somedir/app
|
|
|
|
could be compiled with
|
2008-06-09 15:49:35 +00:00
|
|
|
.I gcc -Wl,-rpath,\(aq$ORIGIN/../lib\(aq
|
2007-05-26 11:55:36 +00:00
|
|
|
so that it finds an associated shared library in
|
|
|
|
.I somedir/lib
|
2007-06-21 22:55:04 +00:00
|
|
|
no matter where
|
|
|
|
.I somedir
|
2007-05-26 11:55:36 +00:00
|
|
|
is located in the directory hierarchy.
|
|
|
|
This facilitates the creation of "turn-key" applications that
|
|
|
|
do not need to be installed into special directories,
|
|
|
|
but can instead be unpacked into any directory
|
|
|
|
and still find their own shared libraries.
|
2007-06-21 22:55:04 +00:00
|
|
|
.\" ld.so also understands $LIB, with the same meaning as $ORIGIN/lib,
|
2007-05-26 11:55:36 +00:00
|
|
|
.\" it appears.
|
|
|
|
.\"
|
|
|
|
.\" There is also $PLATFORM. This is a kind of wildcard
|
|
|
|
.\" of directories related at AT_HWCAP. To get an idea of the
|
|
|
|
.\" places that $PLATFORM would match, look at the output of the
|
|
|
|
.\" following:
|
|
|
|
.\"
|
|
|
|
.\" mkdir /tmp/d
|
|
|
|
.\" LD_LIBRARY_PATH=/tmp/d strace -e open /bin/date 2>&1 | grep /tmp/d
|
|
|
|
.\"
|
|
|
|
.\" ld.so lets names be abbreviated, so $O will work for $ORIGIN;
|
|
|
|
.\" Don't do this!!
|
2007-05-16 05:06:47 +00:00
|
|
|
.SH OPTIONS
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2005-07-06 07:41:37 +00:00
|
|
|
.B \-\-list
|
2004-11-03 13:51:07 +00:00
|
|
|
List all dependencies and how they are resolved.
|
|
|
|
.TP
|
2005-07-06 07:41:37 +00:00
|
|
|
.B \-\-verify
|
2004-11-03 13:51:07 +00:00
|
|
|
Verify that program is dynamically linked and this dynamic linker can handle
|
|
|
|
it.
|
|
|
|
.TP
|
2005-07-06 07:41:37 +00:00
|
|
|
.B \-\-library\-path PATH
|
2004-11-03 13:51:07 +00:00
|
|
|
Override
|
|
|
|
.B LD_LIBRARY_PATH
|
|
|
|
environment variable setting (see below).
|
|
|
|
.TP
|
2005-07-06 07:41:37 +00:00
|
|
|
.B \-\-inhibit\-rpath LIST
|
2007-05-26 10:42:50 +00:00
|
|
|
Ignore RPATH and RUNPATH information in object names in LIST.
|
2008-10-28 02:15:56 +00:00
|
|
|
This option is ignored if
|
|
|
|
.B ld.so
|
|
|
|
is set-user-ID or set-group-ID.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH ENVIRONMENT
|
|
|
|
There are four important environment variables.
|
|
|
|
.TP
|
2008-10-27 22:23:21 +00:00
|
|
|
.B LD_BIND_NOW
|
|
|
|
(libc5; glibc since 2.1.1)
|
|
|
|
If set to a non-empty 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.
|
|
|
|
This is useful when using a debugger.
|
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B LD_LIBRARY_PATH
|
|
|
|
A colon-separated list of directories in which to search for
|
|
|
|
ELF libraries at execution-time.
|
2007-04-12 22:42:49 +00:00
|
|
|
Similar to the
|
2004-11-03 13:51:07 +00:00
|
|
|
.B PATH
|
|
|
|
environment variable.
|
|
|
|
.TP
|
|
|
|
.B LD_PRELOAD
|
2007-04-12 22:42:49 +00:00
|
|
|
A whitespace-separated list of additional, user-specified, ELF shared
|
2004-11-03 13:51:07 +00:00
|
|
|
libraries to be loaded before all others.
|
|
|
|
This can be used to selectively override functions in other shared libraries.
|
2005-07-18 14:25:42 +00:00
|
|
|
For set-user-ID/set-group-ID ELF binaries,
|
|
|
|
only libraries in the standard search
|
|
|
|
directories that are also set-user-ID will be loaded.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B LD_TRACE_LOADED_OBJECTS
|
|
|
|
(ELF only)
|
2008-04-18 20:38:02 +00:00
|
|
|
If set to a non-empty string, causes the program to list its dynamic library
|
2004-11-03 13:51:07 +00:00
|
|
|
dependencies, as if run by
|
|
|
|
.BR ldd (1),
|
|
|
|
instead of running normally.
|
|
|
|
.LP
|
|
|
|
Then there are lots of more or less obscure variables,
|
|
|
|
many obsolete or only for internal use.
|
|
|
|
.TP
|
2008-10-27 22:23:21 +00:00
|
|
|
.B LD_AOUT_LIBRARY_PATH
|
|
|
|
(libc5)
|
|
|
|
Version of
|
|
|
|
.B LD_LIBRARY_PATH
|
|
|
|
for a.out binaries only.
|
|
|
|
Old versions of ld\-linux.so.1 also supported
|
|
|
|
.BR LD_ELF_LIBRARY_PATH .
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2008-10-27 22:23:21 +00:00
|
|
|
.B LD_AOUT_PRELOAD
|
|
|
|
(libc5)
|
|
|
|
Version of
|
|
|
|
.B LD_PRELOAD
|
|
|
|
for a.out binaries only.
|
|
|
|
Old versions of ld\-linux.so.1 also supported
|
|
|
|
.BR LD_ELF_PRELOAD .
|
2009-01-12 06:10:46 +00:00
|
|
|
.TP
|
|
|
|
.B LD_AUDIT
|
|
|
|
(glibc since 2.4)
|
|
|
|
A colon-separated list of user-specified, ELF shared objects
|
|
|
|
to be loaded before all others in a separate linker namespace
|
|
|
|
(i.e., one that does not intrude upon the normal symbol bindings that
|
|
|
|
would occur in the process).
|
|
|
|
These libraries can be used to audit the operation of the dynamic linker.
|
|
|
|
.B LD_AUDIT
|
|
|
|
is ignored for set-user-ID/set-group-ID binaries.
|
|
|
|
|
|
|
|
The dynamic linker will notify the audit
|
|
|
|
libraries at so-called auditing checkpoints\(emfor example,
|
|
|
|
loading a new library, resolving a symbol,
|
|
|
|
or calling a symbol from another shared object\(emby
|
|
|
|
calling an appropriate function within the audit library.
|
|
|
|
For details, see
|
|
|
|
.BR rtld-audit (7).
|
|
|
|
The auditing interface is largely compatible with that provided on Solaris,
|
|
|
|
as described in its
|
|
|
|
.IR "Linker and Libraries Guide" ,
|
|
|
|
in the chapter
|
|
|
|
.IR "Runtime Linker Auditing Interface" .
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B LD_BIND_NOT
|
|
|
|
(glibc since 2.1.95)
|
|
|
|
Do not update the GOT (global offset table) and PLT (procedure linkage table)
|
|
|
|
after resolving a symbol.
|
|
|
|
.TP
|
|
|
|
.B LD_DEBUG
|
|
|
|
(glibc since 2.1)
|
|
|
|
Output verbose debugging information about the dynamic linker.
|
|
|
|
If set to
|
|
|
|
.B all
|
|
|
|
prints all debugging information it has, if set to
|
|
|
|
.B help
|
|
|
|
prints a help message about which categories can be specified in this
|
|
|
|
environment variable.
|
2008-10-27 19:13:11 +00:00
|
|
|
Since glibc 2.3.4,
|
|
|
|
.B LD_DEBUG
|
|
|
|
is ignored for set-user-ID/set-group-ID binaries.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B LD_DEBUG_OUTPUT
|
|
|
|
(glibc since 2.1)
|
|
|
|
File where
|
|
|
|
.B LD_DEBUG
|
|
|
|
output should be fed into, default is standard output.
|
2007-06-22 20:40:07 +00:00
|
|
|
.B LD_DEBUG_OUTPUT
|
|
|
|
is ignored for set-user-ID/set-group-ID binaries.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2008-10-27 22:23:21 +00:00
|
|
|
.B LD_DYNAMIC_WEAK
|
|
|
|
(glibc since 2.1.91)
|
|
|
|
Allow weak symbols to be overridden (reverting to old glibc behavior).
|
|
|
|
For security reasons, since glibc 2.3.4,
|
|
|
|
.B LD_DYNAMIC_WEAK
|
|
|
|
is ignored for set-user-ID/set-group-ID binaries.
|
|
|
|
.TP
|
|
|
|
.B LD_HWCAP_MASK
|
2004-11-03 13:51:07 +00:00
|
|
|
(glibc since 2.1)
|
2008-10-27 22:23:21 +00:00
|
|
|
Mask for hardware capabilities.
|
|
|
|
.TP
|
|
|
|
.B LD_KEEPDIR
|
|
|
|
(a.out only)(libc5)
|
|
|
|
Don't ignore the directory in the names of a.out libraries to be loaded.
|
|
|
|
Use of this option is strongly discouraged.
|
|
|
|
.TP
|
|
|
|
.B LD_NOWARN
|
|
|
|
(a.out only)(libc5)
|
|
|
|
Suppress warnings about a.out libraries with incompatible minor
|
|
|
|
version numbers.
|
|
|
|
.TP
|
|
|
|
.B LD_ORIGIN_PATH
|
|
|
|
(glibc since 2.1)
|
|
|
|
Path where the binary is found (for non-set-user-ID programs).
|
|
|
|
For security reasons, since glibc 2.4,
|
|
|
|
.B LD_ORIGIN_PATH
|
|
|
|
is ignored for set-user-ID/set-group-ID binaries.
|
|
|
|
.\" Only used if $ORIGIN can't be determined by normal means
|
|
|
|
.\" (from the origin path saved at load time, or from /proc/self/exe)?
|
2009-01-12 09:57:06 +00:00
|
|
|
.TP
|
|
|
|
.B LD_POINTER_GUARD
|
|
|
|
(glibc since 2.4)
|
|
|
|
Set to 0 to disable pointer guarding.
|
|
|
|
Any other value enables pointer guarding, which is also the default.
|
|
|
|
Pointer guarding is a security mechanism whereby some pointers to code
|
|
|
|
stored in writable program memory (return addresses saved by
|
|
|
|
.BR setjmp (3)
|
|
|
|
or function pointers used by various glibc internals) are mangled
|
|
|
|
semi-randomly to make it more difficult for an attacker to hijack
|
|
|
|
the pointers for use in the event of a buffer overrun or
|
|
|
|
stack-smashing attack.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B LD_PROFILE
|
|
|
|
(glibc since 2.1)
|
2008-10-28 01:02:28 +00:00
|
|
|
Shared object to be profiled,
|
|
|
|
specified either as a pathname or a soname.
|
|
|
|
Profiling output is written to the file whose name is:
|
|
|
|
"\fI$LD_PROFILE_OUTPUT\fP/\fI$LD_PROFILE\fP.profile".
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B LD_PROFILE_OUTPUT
|
|
|
|
(glibc since 2.1)
|
2008-10-28 01:02:28 +00:00
|
|
|
Directory where
|
2004-11-03 13:51:07 +00:00
|
|
|
.B LD_PROFILE
|
2008-10-28 01:02:28 +00:00
|
|
|
output should be written.
|
|
|
|
If this variable is not defined, or is defined as an empty string,
|
|
|
|
then the default is
|
|
|
|
.IR /var/tmp .
|
2007-06-22 20:40:07 +00:00
|
|
|
.B LD_PROFILE_OUTPUT
|
2008-10-28 01:02:28 +00:00
|
|
|
is ignored for set-user-ID and set-group-ID programs,
|
|
|
|
which always use
|
|
|
|
.IR /var/profile .
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B LD_SHOW_AUXV
|
|
|
|
(glibc since 2.1)
|
|
|
|
Show auxiliary array passed up from the kernel.
|
2008-10-27 20:26:59 +00:00
|
|
|
For security reasons, since glibc 2.3.5,
|
|
|
|
.B LD_SHOW_AUXV
|
|
|
|
is ignored for set-user-ID/set-group-ID binaries.
|
2008-10-28 02:38:35 +00:00
|
|
|
.\" FIXME
|
|
|
|
.\" Document LD_TRACE_PRELINKING (e.g.: LD_TRACE_PRELINKING=libx1.so ./prog)
|
|
|
|
.\" Since glibc 2.3
|
|
|
|
.\" Also enables DL_DEBUG_PRELINK
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2008-10-27 22:23:21 +00:00
|
|
|
.B LD_USE_LOAD_BIAS
|
|
|
|
.\" http://sources.redhat.com/ml/libc-hacker/2003-11/msg00127.html
|
|
|
|
.\" Subject: [PATCH] Support LD_USE_LOAD_BIAS
|
|
|
|
.\" Jakub Jelinek
|
|
|
|
By default (i.e., if this variable is not defined)
|
|
|
|
executables and prelinked
|
|
|
|
shared objects will honor base addresses of their dependent libraries
|
|
|
|
and (non-prelinked) position-independent executables (PIEs)
|
|
|
|
and other shared objects will not honor them.
|
|
|
|
If
|
|
|
|
.B LD_USE_LOAD_BIAS
|
|
|
|
is defined wit the value, both executables and PIEs
|
|
|
|
will honor the base addresses.
|
|
|
|
If
|
|
|
|
.B LD_USE_LOAD_BIAS
|
|
|
|
is defined with the value 0,
|
|
|
|
neither executables nor PIEs will honor the base addresses.
|
|
|
|
This variable is ignored by set-user-ID and set-group-ID programs.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2008-10-27 22:23:21 +00:00
|
|
|
.B LD_VERBOSE
|
2004-11-03 13:51:07 +00:00
|
|
|
(glibc since 2.1)
|
2008-10-27 22:23:21 +00:00
|
|
|
If set to a non-empty string,
|
|
|
|
output symbol versioning information about the
|
|
|
|
program if querying information about the program (i.e., either
|
|
|
|
.B LD_TRACE_LOADED_OBJECTS
|
|
|
|
has been set, or
|
|
|
|
.B \-\-list
|
|
|
|
or
|
|
|
|
.B \-\-verify
|
|
|
|
options have been given to the dynamic linker).
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2008-10-27 22:23:21 +00:00
|
|
|
.B LD_WARN
|
|
|
|
(ELF only)(glibc since 2.1.3)
|
|
|
|
If set to a non-empty string, warn about unresolved symbols.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B LDD_ARGV0
|
|
|
|
(libc5)
|
|
|
|
.IR argv [0]
|
|
|
|
to be used by
|
|
|
|
.BR ldd (1)
|
|
|
|
when none is present.
|
|
|
|
.SH FILES
|
|
|
|
.PD 0
|
|
|
|
.TP
|
2005-11-02 13:55:25 +00:00
|
|
|
.I /lib/ld.so
|
2004-11-03 13:51:07 +00:00
|
|
|
a.out dynamic linker/loader
|
|
|
|
.TP
|
2005-11-02 13:55:25 +00:00
|
|
|
.IR /lib/ld\-linux.so. { 1 , 2 }
|
2004-11-03 13:51:07 +00:00
|
|
|
ELF dynamic linker/loader
|
|
|
|
.TP
|
2005-11-02 13:55:25 +00:00
|
|
|
.I /etc/ld.so.cache
|
2004-11-03 13:51:07 +00:00
|
|
|
File containing a compiled list of directories in which to search for
|
|
|
|
libraries and an ordered list of candidate libraries.
|
|
|
|
.TP
|
2005-11-02 13:55:25 +00:00
|
|
|
.I /etc/ld.so.preload
|
2004-11-03 13:51:07 +00:00
|
|
|
File containing a whitespace separated list of ELF shared libraries to
|
|
|
|
be loaded before the program.
|
|
|
|
.TP
|
|
|
|
.B lib*.so*
|
|
|
|
shared libraries
|
|
|
|
.PD
|
|
|
|
.SH NOTES
|
|
|
|
The
|
|
|
|
.B ld.so
|
|
|
|
functionality is available for executables compiled using libc version
|
|
|
|
4.4.3 or greater.
|
|
|
|
ELF functionality is available since Linux 1.1.52 and libc5.
|
|
|
|
.SH SEE ALSO
|
|
|
|
.BR ldd (1),
|
2009-01-12 19:47:47 +00:00
|
|
|
.BR rtld-audit (7),
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR ldconfig (8)
|
|
|
|
.\" .SH AUTHORS
|
|
|
|
.\" ld.so: David Engel, Eric Youngdale, Peter MacDonald, Hongjiu Lu, Linus
|
|
|
|
.\" Torvalds, Lars Wirzenius and Mitch D'Souza
|
|
|
|
.\" ld-linux.so: Roland McGrath, Ulrich Drepper and others.
|
|
|
|
.\"
|
|
|
|
.\" In the above, (libc5) stands for David Engel's ld.so/ld-linux.so.
|