]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man8/ld.so.8
adjtimex.2: SEE ALSO: Add adjtimex(8)
[thirdparty/man-pages.git] / man8 / ld.so.8
CommitLineData
2d6c6dd1 1.\" %%%LICENSE_START(PUBLIC_DOMAIN)
fea681da 2.\" This is in the public domain
2d6c6dd1 3.\" %%%LICENSE_END
6a717e5e 4.\"
d4284a60 5.TH LD.SO 8 2013-07-15 "GNU" "Linux Programmer's Manual"
fea681da
MK
6.SH NAME
7ld.so, ld-linux.so* \- dynamic linker/loader
a1d5f77c 8.SH SYNOPSIS
cd6dddf6 9The dynamic linker can be run either indirectly by running some
76c44d83 10dynamically linked program or library (in which case no command-line options
a1d5f77c
MK
11to the dynamic linker can be passed and, in the ELF case, the dynamic linker
12which is stored in the
13.B .interp
14section of the program is executed) or directly by running:
15.P
16.I /lib/ld-linux.so.*
17[OPTIONS] [PROGRAM [ARGUMENTS]]
fea681da
MK
18.SH DESCRIPTION
19The programs
20.B ld.so
21and
22.B ld-linux.so*
23find and load the shared libraries needed by a program, prepare
24the program to run, and then run it.
25.LP
26Linux binaries require dynamic linking (linking at run time)
27unless the
28.B \-static
29option was given to
f19a0f03 30.BR ld (1)
fea681da
MK
31during compilation.
32.LP
33The program
34.B ld.so
35handles a.out binaries, a format used long ago;
36.B ld-linux.so*
8478ee02 37handles ELF (\fI/lib/ld-linux.so.1\fP for libc5, \fI/lib/ld-linux.so.2\fP
fea681da 38for glibc2), which everybody has been using for years now.
d9bfdb9c 39Otherwise both have the same behavior, and use the same
fea681da
MK
40support files and programs
41.BR ldd (1),
42.BR ldconfig (8)
43and
44.IR /etc/ld.so.conf .
45.LP
15d116d5
MK
46When resolving library dependencies,
47the dynamic linker first inspects each dependency
48string to see if it contains a slash (this can occur if
49a library pathname containing slashes was specified at link time).
50If a slash is found, then the dependency string is interpreted as
51a (relative or absolute) pathname,
52and the library is loaded using that pathname.
53.LP
54If a library dependency does not contain a slash,
55then it is searched for in the following order:
cd6dddf6
MK
56.IP o 3
57(ELF only) Using the directories specified in the
58DT_RPATH dynamic section attribute
fea681da
MK
59of the binary if present and DT_RUNPATH attribute does not exist.
60Use of DT_RPATH is deprecated.
61.IP o
62Using the environment variable
63.BR LD_LIBRARY_PATH .
c13182ef 64Except if the executable is a set-user-ID/set-group-ID binary,
880f5b4b 65in which case it is ignored.
fea681da 66.IP o
cd6dddf6
MK
67(ELF only) Using the directories specified in the
68DT_RUNPATH dynamic section attribute
fea681da
MK
69of the binary if present.
70.IP o
71From the cache file
de6d7600 72.IR /etc/ld.so.cache ,
fea681da 73which contains a compiled list of candidate libraries previously found
c13182ef 74in the augmented library path.
cd6dddf6 75If, however, the binary was linked with the
4d9b6984 76.B \-z nodeflib
fea681da 77linker option, libraries in the default library paths are skipped.
de1f0d47
JN
78Libraries installed in hardware capability directories (see below)
79are preferred to other libraries.
fea681da
MK
80.IP o
81In the default path
8478ee02 82.IR /lib ,
fea681da 83and then
8478ee02 84.IR /usr/lib .
cd6dddf6 85If the binary was linked with the
4d9b6984 86.B \-z nodeflib
fea681da 87linker option, this step is skipped.
eeb25d47 88.SS Rpath token expansion
0a216931
MK
89.PP
90.B ld.so
eeb25d47
MK
91understands certain strings in an rpath specification (DT_RPATH or DT_RUNPATH); those strings are substituted as follows
92.TP
93.IR $ORIGIN " (or equivalently " ${ORIGIN} )
8a94e783 94This expands to
b9679a55 95the directory containing the application executable.
0a216931
MK
96Thus, an application located in
97.I somedir/app
98could be compiled with
eeb25d47
MK
99
100 gcc -Wl,-rpath,\(aq$ORIGIN/../lib\(aq
101
0a216931
MK
102so that it finds an associated shared library in
103.I somedir/lib
988db661
MK
104no matter where
105.I somedir
0a216931
MK
106is located in the directory hierarchy.
107This facilitates the creation of "turn-key" applications that
108do not need to be installed into special directories,
109but can instead be unpacked into any directory
110and still find their own shared libraries.
909df276
MK
111.TP
112.IR $LIB " (or equivalently " ${LIB} )
113This expands to
114.I lib
115or
116.I lib64
117depending on the architecture
118(e.g., on x86-64, it expands to
119.IR lib64
120and
121on x86-32, it expands to
122.IR lib ).
3f2f2461
MK
123.TP
124.IR $PLATFORM " (or equivalently " ${PLATFORM} )
125This expands to a string corresponding to the processor type
126of the host system (e.g., "x86_64").
127On some architectures, the Linux kernel doesn't provide a platform
128string to the dynamic linker.
129The value of this string is taken from the
130.BR AT_PLATFORM
131value in the auxiliary vector (see
132.BR getauxval (3)).
133.\" To get an idea of the places that $PLATFORM would match,
134.\" look at the output of the following:
0a216931 135.\"
3f2f2461
MK
136.\" mkdir /tmp/d
137.\" LD_LIBRARY_PATH=/tmp/d strace -e open /bin/date 2>&1 | grep /tmp/d
0a216931
MK
138.\"
139.\" ld.so lets names be abbreviated, so $O will work for $ORIGIN;
140.\" Don't do this!!
9d4869b3 141.SH OPTIONS
fea681da 142.TP
4d9b6984 143.B \-\-list
fea681da
MK
144List all dependencies and how they are resolved.
145.TP
4d9b6984 146.B \-\-verify
fea681da
MK
147Verify that program is dynamically linked and this dynamic linker can handle
148it.
149.TP
4d9b6984 150.B \-\-library\-path PATH
9ebe3f2b 151Use PATH instead of
fea681da
MK
152.B LD_LIBRARY_PATH
153environment variable setting (see below).
154.TP
4d9b6984 155.B \-\-inhibit\-rpath LIST
602d4983 156Ignore RPATH and RUNPATH information in object names in LIST.
282849d8
MK
157This option is ignored if
158.B ld.so
159is set-user-ID or set-group-ID.
608dce1f 160.TP
6b1d5829
MK
161.B \-\-audit LIST
162Use objects named in LIST as auditors.
de1f0d47
JN
163.SH HARDWARE CAPABILITIES
164Some libraries are compiled using hardware-specific instructions which do
165not exist on every CPU.
166Such libraries should be installed in directories whose names define the
167required hardware capabilities, such as
168.IR /usr/lib/sse2/ .
169The dynamic linker checks these directories against the hardware of the
170machine and selects the most suitable version of a given library.
171Hardware capability directories can be cascaded to combine CPU features.
172The list of supported hardware capability names depends on the CPU.
173The following names are currently recognized:
174.TP
175.B Alpha
176ev4, ev5, ev56, ev6, ev67
177.TP
178.B MIPS
179loongson2e, loongson2f, octeon, octeon2
180.TP
181.B PowerPC
1824xxmac, altivec, arch_2_05, arch_2_06, booke, cellbe, dfp, efpdouble, efpsingle,
183fpu, ic_snoop, mmu, notb, pa6t, power4, power5, power5+, power6x, ppc32, ppc601,
184ppc64, smt, spe, ucache, vsx
185.TP
186.B SPARC
187flush, muldiv, stbar, swap, ultra3, v9, v9v, v9v2
188.TP
189.B s390
190dfp, eimm, esan3, etf3enh, g5, highgprs, hpage, ldisp, msa, stfle,
191z900, z990, z9-109, z10, zarch
192.TP
de1f0d47
JN
193.B x86 (32-bit only)
194acpi, apic, clflush, cmov, cx8, dts, fxsr, ht, i386, i486, i586, i686, mca, mmx,
195mtrr, pat, pbe, pge, pn, pse36, sep, ss, sse, sse2, tm
fea681da
MK
196.SH ENVIRONMENT
197There are four important environment variables.
198.TP
eeb25d47
MK
199.B LD_ASSUME_KERNEL
200(glibc since 2.2.3)
201Each shared library can inform the dynamic linker of the minimum kernel ABI
202version that it requires.
ef74d4ad
MK
203(This requirement is encoded in an ELF note section that is viewable via
204.IR "readelf\ \-n"
205as a section labeled
206.BR NT_GNU_ABI_TAG .)
eeb25d47
MK
207At run time,
208the dynamic linker determines the ABI version of the running kernel and
209will reject loading shared libraries that specify minimum ABI versions
210that exceed that ABI version.
211
212.BR LD_ASSUME_KERNEL
213can be used to
214cause the dynamic linker to assume that it is running on a system with
215a different kernel ABI version.
216For example, the following command line causes the
217dynamic linker to assume it is running on Linux 2.2.5 when loading
218the shared libraries required by
219.IR myprog :
220
221.in +4n
222.nf
223$ \fBLD_ASSUME_KERNEL=2.2.5 ./myprog\fP
224.fi
225.in
226
227On systems that provide multiple versions of a shared library
228(in different directories in the search path) that have
229different minimum kernel ABI version requirements,
230.BR LD_ASSUME_KERNEL
231can be used to select the version of the library that is used
232(dependent on the directory search order).
233Historically, the most common use of the
8a94e783 234.BR LD_ASSUME_KERNEL
eeb25d47
MK
235feature was to manually select the older
236LinuxThreads POSIX threads implementation on systems that provided both
237LinuxThreads and NPTL
260c8fcd
MK
238(which latter was typically the default on such systems);
239see
240.BR pthreads (7).
eeb25d47 241.TP
d4284a60
MK
242.B LD_BIND_NOT
243(glibc since 2.2)
244Don't update the Global Offset Table (GOT) and Procedure Linkage Table (PLT)
245when resolving a symbol.
246.TP
e1725521
MK
247.B LD_BIND_NOW
248(libc5; glibc since 2.1.1)
aa796481 249If set to a nonempty string,
e1725521
MK
250causes the dynamic linker to resolve all symbols
251at program startup instead of deferring function call resolution to the point
252when they are first referenced.
253This is useful when using a debugger.
254.TP
fea681da
MK
255.B LD_LIBRARY_PATH
256A colon-separated list of directories in which to search for
257ELF libraries at execution-time.
c13182ef 258Similar to the
fea681da
MK
259.B PATH
260environment variable.
d9839d46 261Ignored in set-user-ID and set-group-ID programs.
fea681da
MK
262.TP
263.B LD_PRELOAD
df7ef267 264A list of additional, user-specified, ELF shared
fea681da 265libraries to be loaded before all others.
df7ef267 266The items of the list can be separated by spaces or colons.
fea681da 267This can be used to selectively override functions in other shared libraries.
eb58a74c 268The libraries are searched for using the rules given under DESCRIPTION.
880f5b4b 269For set-user-ID/set-group-ID ELF binaries,
eb58a74c
MK
270preload pathnames containing slashes are ignored,
271and libraries in the standard search directories are loaded
272only if the set-user-ID permission bit is enabled on the library file.
fea681da 273.TP
fea681da
MK
274.B LD_TRACE_LOADED_OBJECTS
275(ELF only)
aa796481 276If set to a nonempty string, causes the program to list its dynamic library
fea681da
MK
277dependencies, as if run by
278.BR ldd (1),
279instead of running normally.
280.LP
281Then there are lots of more or less obscure variables,
282many obsolete or only for internal use.
283.TP
e1725521
MK
284.B LD_AOUT_LIBRARY_PATH
285(libc5)
286Version of
287.B LD_LIBRARY_PATH
288for a.out binaries only.
289Old versions of ld\-linux.so.1 also supported
290.BR LD_ELF_LIBRARY_PATH .
fea681da 291.TP
e1725521
MK
292.B LD_AOUT_PRELOAD
293(libc5)
294Version of
295.B LD_PRELOAD
296for a.out binaries only.
297Old versions of ld\-linux.so.1 also supported
298.BR LD_ELF_PRELOAD .
54eb2620
PB
299.TP
300.B LD_AUDIT
301(glibc since 2.4)
302A colon-separated list of user-specified, ELF shared objects
303to be loaded before all others in a separate linker namespace
304(i.e., one that does not intrude upon the normal symbol bindings that
305would occur in the process).
306These libraries can be used to audit the operation of the dynamic linker.
307.B LD_AUDIT
308is ignored for set-user-ID/set-group-ID binaries.
309
310The dynamic linker will notify the audit
311libraries at so-called auditing checkpoints\(emfor example,
312loading a new library, resolving a symbol,
313or calling a symbol from another shared object\(emby
314calling an appropriate function within the audit library.
315For details, see
316.BR rtld-audit (7).
317The auditing interface is largely compatible with that provided on Solaris,
318as described in its
319.IR "Linker and Libraries Guide" ,
320in the chapter
321.IR "Runtime Linker Auditing Interface" .
fea681da
MK
322.TP
323.B LD_BIND_NOT
324(glibc since 2.1.95)
325Do not update the GOT (global offset table) and PLT (procedure linkage table)
326after resolving a symbol.
327.TP
328.B LD_DEBUG
329(glibc since 2.1)
330Output verbose debugging information about the dynamic linker.
331If set to
332.B all
333prints all debugging information it has, if set to
334.B help
335prints a help message about which categories can be specified in this
336environment variable.
e4c14bd9
MK
337Since glibc 2.3.4,
338.B LD_DEBUG
339is ignored for set-user-ID/set-group-ID binaries.
fea681da
MK
340.TP
341.B LD_DEBUG_OUTPUT
342(glibc since 2.1)
70e26d29 343File in which
fea681da 344.B LD_DEBUG
70e26d29
MK
345output should be written.
346The default is standard output.
097585ed
MK
347.B LD_DEBUG_OUTPUT
348is ignored for set-user-ID/set-group-ID binaries.
fea681da 349.TP
e1725521
MK
350.B LD_DYNAMIC_WEAK
351(glibc since 2.1.91)
352Allow weak symbols to be overridden (reverting to old glibc behavior).
353For security reasons, since glibc 2.3.4,
354.B LD_DYNAMIC_WEAK
355is ignored for set-user-ID/set-group-ID binaries.
356.TP
357.B LD_HWCAP_MASK
fea681da 358(glibc since 2.1)
e1725521
MK
359Mask for hardware capabilities.
360.TP
361.B LD_KEEPDIR
362(a.out only)(libc5)
363Don't ignore the directory in the names of a.out libraries to be loaded.
364Use of this option is strongly discouraged.
365.TP
366.B LD_NOWARN
367(a.out only)(libc5)
368Suppress warnings about a.out libraries with incompatible minor
369version numbers.
370.TP
371.B LD_ORIGIN_PATH
372(glibc since 2.1)
373Path where the binary is found (for non-set-user-ID programs).
374For security reasons, since glibc 2.4,
375.B LD_ORIGIN_PATH
376is ignored for set-user-ID/set-group-ID binaries.
377.\" Only used if $ORIGIN can't be determined by normal means
378.\" (from the origin path saved at load time, or from /proc/self/exe)?
7b0cacbb
PB
379.TP
380.B LD_POINTER_GUARD
381(glibc since 2.4)
382Set to 0 to disable pointer guarding.
383Any other value enables pointer guarding, which is also the default.
384Pointer guarding is a security mechanism whereby some pointers to code
385stored in writable program memory (return addresses saved by
386.BR setjmp (3)
387or function pointers used by various glibc internals) are mangled
388semi-randomly to make it more difficult for an attacker to hijack
389the pointers for use in the event of a buffer overrun or
390stack-smashing attack.
fea681da
MK
391.TP
392.B LD_PROFILE
393(glibc since 2.1)
8a7f3759
MK
394Shared object to be profiled,
395specified either as a pathname or a soname.
396Profiling output is written to the file whose name is:
397"\fI$LD_PROFILE_OUTPUT\fP/\fI$LD_PROFILE\fP.profile".
fea681da
MK
398.TP
399.B LD_PROFILE_OUTPUT
400(glibc since 2.1)
8a7f3759 401Directory where
fea681da 402.B LD_PROFILE
8a7f3759
MK
403output should be written.
404If this variable is not defined, or is defined as an empty string,
405then the default is
406.IR /var/tmp .
097585ed 407.B LD_PROFILE_OUTPUT
8a7f3759
MK
408is ignored for set-user-ID and set-group-ID programs,
409which always use
410.IR /var/profile .
fea681da 411.TP
fea681da
MK
412.B LD_SHOW_AUXV
413(glibc since 2.1)
414Show auxiliary array passed up from the kernel.
ca2bcde1
MK
415For security reasons, since glibc 2.3.5,
416.B LD_SHOW_AUXV
417is ignored for set-user-ID/set-group-ID binaries.
bd6de82f
MK
418.\" FIXME
419.\" Document LD_TRACE_PRELINKING (e.g.: LD_TRACE_PRELINKING=libx1.so ./prog)
420.\" Since glibc 2.3
421.\" Also enables DL_DEBUG_PRELINK
fea681da 422.TP
e1725521
MK
423.B LD_USE_LOAD_BIAS
424.\" http://sources.redhat.com/ml/libc-hacker/2003-11/msg00127.html
425.\" Subject: [PATCH] Support LD_USE_LOAD_BIAS
426.\" Jakub Jelinek
427By default (i.e., if this variable is not defined)
428executables and prelinked
429shared objects will honor base addresses of their dependent libraries
24b74457 430and (nonprelinked) position-independent executables (PIEs)
e1725521
MK
431and other shared objects will not honor them.
432If
433.B LD_USE_LOAD_BIAS
434is defined wit the value, both executables and PIEs
435will honor the base addresses.
436If
437.B LD_USE_LOAD_BIAS
438is defined with the value 0,
439neither executables nor PIEs will honor the base addresses.
440This variable is ignored by set-user-ID and set-group-ID programs.
fea681da 441.TP
e1725521 442.B LD_VERBOSE
fea681da 443(glibc since 2.1)
aa796481 444If set to a nonempty string,
e1725521 445output symbol versioning information about the
2216fac7 446program if the
e1725521 447.B LD_TRACE_LOADED_OBJECTS
2216fac7 448environment variable has been set.
fea681da 449.TP
e1725521
MK
450.B LD_WARN
451(ELF only)(glibc since 2.1.3)
aa796481 452If set to a nonempty string, warn about unresolved symbols.
fea681da
MK
453.TP
454.B LDD_ARGV0
455(libc5)
456.IR argv [0]
457to be used by
458.BR ldd (1)
459when none is present.
460.SH FILES
461.PD 0
462.TP
8478ee02 463.I /lib/ld.so
fea681da
MK
464a.out dynamic linker/loader
465.TP
8478ee02 466.IR /lib/ld\-linux.so. { 1 , 2 }
fea681da
MK
467ELF dynamic linker/loader
468.TP
8478ee02 469.I /etc/ld.so.cache
fea681da
MK
470File containing a compiled list of directories in which to search for
471libraries and an ordered list of candidate libraries.
472.TP
8478ee02 473.I /etc/ld.so.preload
24d989e5 474File containing a whitespace-separated list of ELF shared libraries to
fea681da 475be loaded before the program.
fea681da
MK
476.TP
477.B lib*.so*
478shared libraries
479.PD
480.SH NOTES
481The
482.B ld.so
483functionality is available for executables compiled using libc version
4844.4.3 or greater.
485ELF functionality is available since Linux 1.1.52 and libc5.
486.SH SEE ALSO
487.BR ldd (1),
9105e83d 488.BR sln (1),
45fa8fcb 489.BR getauxval (3),
c18ecec9 490.BR rtld-audit (7),
fea681da
MK
491.BR ldconfig (8)
492.\" .SH AUTHORS
493.\" ld.so: David Engel, Eric Youngdale, Peter MacDonald, Hongjiu Lu, Linus
494.\" Torvalds, Lars Wirzenius and Mitch D'Souza
495.\" ld-linux.so: Roland McGrath, Ulrich Drepper and others.
496.\"
497.\" In the above, (libc5) stands for David Engel's ld.so/ld-linux.so.