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