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