]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man8/ld.so.8
ld.so.8: Correct documentation of $ORIGIN
[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.\"
bc65e772 5.TH LD.SO 8 2014-10-02 "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.
2b9b829d 39Otherwise, both have the same behavior, and use the same
fea681da
MK
40support files and programs
41.BR ldd (1),
9af134cd 42.BR ldconfig (8),
fea681da
MK
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
d3acae56 95the directory containing the program or shared library.
0a216931
MK
96Thus, an application located in
97.I somedir/app
98could be compiled with
eeb25d47 99
5c977011 100 gcc \-Wl,\-rpath,\(aq$ORIGIN/../lib\(aq
eeb25d47 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
495dadb7
CD
150.B \-\-inhibit-cache
151Do not use /etc/ld.so.cache.
152.TP
4d9b6984 153.B \-\-library\-path PATH
9ebe3f2b 154Use PATH instead of
fea681da
MK
155.B LD_LIBRARY_PATH
156environment variable setting (see below).
157.TP
4d9b6984 158.B \-\-inhibit\-rpath LIST
602d4983 159Ignore RPATH and RUNPATH information in object names in LIST.
282849d8
MK
160This option is ignored if
161.B ld.so
162is set-user-ID or set-group-ID.
608dce1f 163.TP
6b1d5829
MK
164.B \-\-audit LIST
165Use objects named in LIST as auditors.
de1f0d47
JN
166.SH HARDWARE CAPABILITIES
167Some libraries are compiled using hardware-specific instructions which do
168not exist on every CPU.
169Such libraries should be installed in directories whose names define the
170required hardware capabilities, such as
171.IR /usr/lib/sse2/ .
172The dynamic linker checks these directories against the hardware of the
173machine and selects the most suitable version of a given library.
174Hardware capability directories can be cascaded to combine CPU features.
175The list of supported hardware capability names depends on the CPU.
176The following names are currently recognized:
177.TP
178.B Alpha
179ev4, ev5, ev56, ev6, ev67
180.TP
181.B MIPS
182loongson2e, loongson2f, octeon, octeon2
183.TP
184.B PowerPC
1854xxmac, altivec, arch_2_05, arch_2_06, booke, cellbe, dfp, efpdouble, efpsingle,
186fpu, ic_snoop, mmu, notb, pa6t, power4, power5, power5+, power6x, ppc32, ppc601,
187ppc64, smt, spe, ucache, vsx
188.TP
189.B SPARC
190flush, muldiv, stbar, swap, ultra3, v9, v9v, v9v2
191.TP
192.B s390
193dfp, eimm, esan3, etf3enh, g5, highgprs, hpage, ldisp, msa, stfle,
194z900, z990, z9-109, z10, zarch
195.TP
de1f0d47
JN
196.B x86 (32-bit only)
197acpi, apic, clflush, cmov, cx8, dts, fxsr, ht, i386, i486, i586, i686, mca, mmx,
198mtrr, pat, pbe, pge, pn, pse36, sep, ss, sse, sse2, tm
fea681da 199.SH ENVIRONMENT
6f6a4840 200Among the more important environment variables are the following:
fea681da 201.TP
eeb25d47
MK
202.B LD_ASSUME_KERNEL
203(glibc since 2.2.3)
204Each shared library can inform the dynamic linker of the minimum kernel ABI
205version that it requires.
ef74d4ad
MK
206(This requirement is encoded in an ELF note section that is viewable via
207.IR "readelf\ \-n"
208as a section labeled
209.BR NT_GNU_ABI_TAG .)
eeb25d47
MK
210At run time,
211the dynamic linker determines the ABI version of the running kernel and
212will reject loading shared libraries that specify minimum ABI versions
213that exceed that ABI version.
214
215.BR LD_ASSUME_KERNEL
216can be used to
217cause the dynamic linker to assume that it is running on a system with
218a different kernel ABI version.
219For example, the following command line causes the
220dynamic linker to assume it is running on Linux 2.2.5 when loading
221the shared libraries required by
222.IR myprog :
223
224.in +4n
225.nf
226$ \fBLD_ASSUME_KERNEL=2.2.5 ./myprog\fP
227.fi
228.in
229
230On systems that provide multiple versions of a shared library
231(in different directories in the search path) that have
232different minimum kernel ABI version requirements,
233.BR LD_ASSUME_KERNEL
234can be used to select the version of the library that is used
235(dependent on the directory search order).
236Historically, the most common use of the
8a94e783 237.BR LD_ASSUME_KERNEL
eeb25d47
MK
238feature was to manually select the older
239LinuxThreads POSIX threads implementation on systems that provided both
240LinuxThreads and NPTL
260c8fcd
MK
241(which latter was typically the default on such systems);
242see
243.BR pthreads (7).
eeb25d47 244.TP
d4284a60
MK
245.B LD_BIND_NOT
246(glibc since 2.2)
247Don't update the Global Offset Table (GOT) and Procedure Linkage Table (PLT)
248when resolving a symbol.
249.TP
e1725521
MK
250.B LD_BIND_NOW
251(libc5; glibc since 2.1.1)
aa796481 252If set to a nonempty string,
e1725521
MK
253causes the dynamic linker to resolve all symbols
254at program startup instead of deferring function call resolution to the point
255when they are first referenced.
256This is useful when using a debugger.
257.TP
fea681da
MK
258.B LD_LIBRARY_PATH
259A colon-separated list of directories in which to search for
260ELF libraries at execution-time.
c13182ef 261Similar to the
fea681da
MK
262.B PATH
263environment variable.
d9839d46 264Ignored in set-user-ID and set-group-ID programs.
fea681da
MK
265.TP
266.B LD_PRELOAD
df7ef267 267A list of additional, user-specified, ELF shared
fea681da 268libraries to be loaded before all others.
df7ef267 269The items of the list can be separated by spaces or colons.
fea681da 270This can be used to selectively override functions in other shared libraries.
eb58a74c 271The libraries are searched for using the rules given under DESCRIPTION.
880f5b4b 272For set-user-ID/set-group-ID ELF binaries,
eb58a74c
MK
273preload pathnames containing slashes are ignored,
274and libraries in the standard search directories are loaded
275only if the set-user-ID permission bit is enabled on the library file.
fea681da 276.TP
fea681da
MK
277.B LD_TRACE_LOADED_OBJECTS
278(ELF only)
aa796481 279If set to a nonempty string, causes the program to list its dynamic library
fea681da
MK
280dependencies, as if run by
281.BR ldd (1),
282instead of running normally.
283.LP
284Then there are lots of more or less obscure variables,
285many obsolete or only for internal use.
286.TP
e1725521
MK
287.B LD_AOUT_LIBRARY_PATH
288(libc5)
289Version of
290.B LD_LIBRARY_PATH
291for a.out binaries only.
292Old versions of ld\-linux.so.1 also supported
293.BR LD_ELF_LIBRARY_PATH .
fea681da 294.TP
e1725521
MK
295.B LD_AOUT_PRELOAD
296(libc5)
297Version of
298.B LD_PRELOAD
299for a.out binaries only.
300Old versions of ld\-linux.so.1 also supported
301.BR LD_ELF_PRELOAD .
54eb2620
PB
302.TP
303.B LD_AUDIT
304(glibc since 2.4)
305A colon-separated list of user-specified, ELF shared objects
306to be loaded before all others in a separate linker namespace
307(i.e., one that does not intrude upon the normal symbol bindings that
308would occur in the process).
309These libraries can be used to audit the operation of the dynamic linker.
310.B LD_AUDIT
311is ignored for set-user-ID/set-group-ID binaries.
312
313The dynamic linker will notify the audit
314libraries at so-called auditing checkpoints\(emfor example,
315loading a new library, resolving a symbol,
316or calling a symbol from another shared object\(emby
317calling an appropriate function within the audit library.
318For details, see
319.BR rtld-audit (7).
320The auditing interface is largely compatible with that provided on Solaris,
321as described in its
322.IR "Linker and Libraries Guide" ,
323in the chapter
324.IR "Runtime Linker Auditing Interface" .
fea681da
MK
325.TP
326.B LD_BIND_NOT
327(glibc since 2.1.95)
328Do not update the GOT (global offset table) and PLT (procedure linkage table)
329after resolving a symbol.
330.TP
331.B LD_DEBUG
332(glibc since 2.1)
333Output verbose debugging information about the dynamic linker.
334If set to
335.B all
336prints all debugging information it has, if set to
337.B help
338prints a help message about which categories can be specified in this
339environment variable.
e4c14bd9
MK
340Since glibc 2.3.4,
341.B LD_DEBUG
342is ignored for set-user-ID/set-group-ID binaries.
fea681da
MK
343.TP
344.B LD_DEBUG_OUTPUT
345(glibc since 2.1)
70e26d29 346File in which
fea681da 347.B LD_DEBUG
70e26d29 348output should be written.
a3e50dc1 349The default is standard error.
097585ed
MK
350.B LD_DEBUG_OUTPUT
351is ignored for set-user-ID/set-group-ID binaries.
fea681da 352.TP
e1725521
MK
353.B LD_DYNAMIC_WEAK
354(glibc since 2.1.91)
355Allow weak symbols to be overridden (reverting to old glibc behavior).
356For security reasons, since glibc 2.3.4,
357.B LD_DYNAMIC_WEAK
358is ignored for set-user-ID/set-group-ID binaries.
359.TP
360.B LD_HWCAP_MASK
fea681da 361(glibc since 2.1)
e1725521
MK
362Mask for hardware capabilities.
363.TP
364.B LD_KEEPDIR
365(a.out only)(libc5)
366Don't ignore the directory in the names of a.out libraries to be loaded.
367Use of this option is strongly discouraged.
368.TP
369.B LD_NOWARN
370(a.out only)(libc5)
371Suppress warnings about a.out libraries with incompatible minor
372version numbers.
373.TP
374.B LD_ORIGIN_PATH
375(glibc since 2.1)
376Path where the binary is found (for non-set-user-ID programs).
377For security reasons, since glibc 2.4,
378.B LD_ORIGIN_PATH
379is ignored for set-user-ID/set-group-ID binaries.
380.\" Only used if $ORIGIN can't be determined by normal means
381.\" (from the origin path saved at load time, or from /proc/self/exe)?
7b0cacbb
PB
382.TP
383.B LD_POINTER_GUARD
384(glibc since 2.4)
385Set to 0 to disable pointer guarding.
386Any other value enables pointer guarding, which is also the default.
387Pointer guarding is a security mechanism whereby some pointers to code
388stored in writable program memory (return addresses saved by
389.BR setjmp (3)
390or function pointers used by various glibc internals) are mangled
391semi-randomly to make it more difficult for an attacker to hijack
392the pointers for use in the event of a buffer overrun or
393stack-smashing attack.
fea681da
MK
394.TP
395.B LD_PROFILE
396(glibc since 2.1)
7c7a7df3 397The name of a (single) shared object to be profiled,
8a7f3759 398specified either as a pathname or a soname.
c64ea262 399Profiling output is appended to the file whose name is:
8a7f3759 400"\fI$LD_PROFILE_OUTPUT\fP/\fI$LD_PROFILE\fP.profile".
fea681da
MK
401.TP
402.B LD_PROFILE_OUTPUT
403(glibc since 2.1)
8a7f3759 404Directory where
fea681da 405.B LD_PROFILE
8a7f3759
MK
406output should be written.
407If this variable is not defined, or is defined as an empty string,
408then the default is
409.IR /var/tmp .
097585ed 410.B LD_PROFILE_OUTPUT
8a7f3759
MK
411is ignored for set-user-ID and set-group-ID programs,
412which always use
413.IR /var/profile .
fea681da 414.TP
fea681da
MK
415.B LD_SHOW_AUXV
416(glibc since 2.1)
417Show auxiliary array passed up from the kernel.
ca2bcde1
MK
418For security reasons, since glibc 2.3.5,
419.B LD_SHOW_AUXV
420is ignored for set-user-ID/set-group-ID binaries.
bd6de82f
MK
421.\" FIXME
422.\" Document LD_TRACE_PRELINKING (e.g.: LD_TRACE_PRELINKING=libx1.so ./prog)
bea08fec
MK
423.\" Available since glibc 2.3
424.\" Also enables DL_DEBUG_PRELINK
fea681da 425.TP
e1725521
MK
426.B LD_USE_LOAD_BIAS
427.\" http://sources.redhat.com/ml/libc-hacker/2003-11/msg00127.html
428.\" Subject: [PATCH] Support LD_USE_LOAD_BIAS
429.\" Jakub Jelinek
430By default (i.e., if this variable is not defined)
431executables and prelinked
432shared objects will honor base addresses of their dependent libraries
24b74457 433and (nonprelinked) position-independent executables (PIEs)
e1725521
MK
434and other shared objects will not honor them.
435If
436.B LD_USE_LOAD_BIAS
437is defined wit the value, both executables and PIEs
438will honor the base addresses.
439If
440.B LD_USE_LOAD_BIAS
441is defined with the value 0,
442neither executables nor PIEs will honor the base addresses.
443This variable is ignored by set-user-ID and set-group-ID programs.
fea681da 444.TP
e1725521 445.B LD_VERBOSE
fea681da 446(glibc since 2.1)
aa796481 447If set to a nonempty string,
e1725521 448output symbol versioning information about the
2216fac7 449program if the
e1725521 450.B LD_TRACE_LOADED_OBJECTS
2216fac7 451environment variable has been set.
fea681da 452.TP
e1725521
MK
453.B LD_WARN
454(ELF only)(glibc since 2.1.3)
aa796481 455If set to a nonempty string, warn about unresolved symbols.
fea681da
MK
456.TP
457.B LDD_ARGV0
458(libc5)
459.IR argv [0]
460to be used by
461.BR ldd (1)
462when none is present.
463.SH FILES
464.PD 0
465.TP
8478ee02 466.I /lib/ld.so
fea681da
MK
467a.out dynamic linker/loader
468.TP
8478ee02 469.IR /lib/ld\-linux.so. { 1 , 2 }
fea681da
MK
470ELF dynamic linker/loader
471.TP
8478ee02 472.I /etc/ld.so.cache
fea681da
MK
473File containing a compiled list of directories in which to search for
474libraries and an ordered list of candidate libraries.
475.TP
8478ee02 476.I /etc/ld.so.preload
24d989e5 477File containing a whitespace-separated list of ELF shared libraries to
fea681da 478be loaded before the program.
fea681da
MK
479.TP
480.B lib*.so*
481shared libraries
482.PD
483.SH NOTES
484The
485.B ld.so
486functionality is available for executables compiled using libc version
4874.4.3 or greater.
488ELF functionality is available since Linux 1.1.52 and libc5.
489.SH SEE ALSO
6b432477 490.BR ld (1),
fea681da 491.BR ldd (1),
1a7735bb 492.BR pldd (1),
cf28f98a 493.BR sprof (1),
639c8860 494.BR dlopen (3),
45fa8fcb 495.BR getauxval (3),
c18ecec9 496.BR rtld-audit (7),
4d96fe33
MK
497.BR ldconfig (8),
498.BR sln (8)
fea681da
MK
499.\" .SH AUTHORS
500.\" ld.so: David Engel, Eric Youngdale, Peter MacDonald, Hongjiu Lu, Linus
501.\" Torvalds, Lars Wirzenius and Mitch D'Souza
502.\" ld-linux.so: Roland McGrath, Ulrich Drepper and others.
503.\"
504.\" In the above, (libc5) stands for David Engel's ld.so/ld-linux.so.