]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man8/ld.so.8
ld.so.8: Remove text with ancient libc4 and Linux libc details
[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 2016-05-09 "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 The names
166 .IR ORIGIN ,
167 .IR LIB ,
168 and
169 .IR PLATFORM
170 are interpreted as for the
171 .BR LD_LIBRARY_PATH
172 environment variable.
173 .TP
174 .BI \-\-inhibit\-rpath " list"
175 Ignore RPATH and RUNPATH information in object names in
176 .IR list .
177 This option is ignored when running in secure-execution mode (see below).
178 .TP
179 .BI \-\-audit " list"
180 Use objects named in
181 .I list
182 as auditors.
183 .SH ENVIRONMENT
184 Various environment variables influence the operation of the dynamic linker.
185 .\"
186 .SS Secure-execution mode
187 For security reasons,
188 the effects of some environment variables are voided or modified if
189 the dynamic linker determines that the binary should be
190 run in secure-execution mode.
191 This determination is made by checking whether the
192 .B AT_SECURE
193 entry in the auxiliary vector (see
194 .BR getauxval (3))
195 has a nonzero value.
196 This entry may have a nonzero value for various reasons, including:
197 .IP * 3
198 The process's real and effective user IDs differ,
199 or the real and effective group IDs differ.
200 This typically occurs as a result of executing
201 a set-user-ID or set-group-ID program.
202 .IP *
203 A process with a non-root user ID executed a binary that
204 conferred permitted or effective capabilities.
205 .IP *
206 A nonzero value may have been set by a Linux Security Module.
207 .\"
208 .SS Environment variables
209 Among the more important environment variables are the following:
210 .TP
211 .BR LD_ASSUME_KERNEL " (glibc since 2.2.3)"
212 Each shared object can inform the dynamic linker of the minimum kernel ABI
213 version that it requires.
214 (This requirement is encoded in an ELF note section that is viewable via
215 .IR "readelf\ \-n"
216 as a section labeled
217 .BR NT_GNU_ABI_TAG .)
218 At run time,
219 the dynamic linker determines the ABI version of the running kernel and
220 will reject loading shared objects that specify minimum ABI versions
221 that exceed that ABI version.
222
223 .BR LD_ASSUME_KERNEL
224 can be used to
225 cause the dynamic linker to assume that it is running on a system with
226 a different kernel ABI version.
227 For example, the following command line causes the
228 dynamic linker to assume it is running on Linux 2.2.5 when loading
229 the shared objects required by
230 .IR myprog :
231
232 .in +4n
233 .nf
234 $ \fBLD_ASSUME_KERNEL=2.2.5 ./myprog\fP
235 .fi
236 .in
237
238 On systems that provide multiple versions of a shared object
239 (in different directories in the search path) that have
240 different minimum kernel ABI version requirements,
241 .BR LD_ASSUME_KERNEL
242 can be used to select the version of the object that is used
243 (dependent on the directory search order).
244 Historically, the most common use of the
245 .BR LD_ASSUME_KERNEL
246 feature was to manually select the older
247 LinuxThreads POSIX threads implementation on systems that provided both
248 LinuxThreads and NPTL
249 (which latter was typically the default on such systems);
250 see
251 .BR pthreads (7).
252 .TP
253 .BR LD_BIND_NOW " (libc5; glibc since 2.1.1)"
254 If set to a nonempty string,
255 causes the dynamic linker to resolve all symbols
256 at program startup instead of deferring function call resolution to the point
257 when they are first referenced.
258 This is useful when using a debugger.
259 .TP
260 .B LD_LIBRARY_PATH
261 A list of directories in which to search for
262 ELF libraries at execution-time.
263 The items in the list are separated by either colons or semicolons.
264 Similar to the
265 .B PATH
266 environment variable.
267 This variable is ignored in secure-execution mode.
268
269 Within the pathnames specified in
270 .BR LD_LIBRARY_PATH ,
271 the dynamic linker expands the strings
272 .IR $ORIGIN ,
273 .IR $LIB ,
274 and
275 .IR $PLATFORM
276 (or the versions using curly braces around the names)
277 as described above in
278 .IR "Rpath token expansion" .
279 Thus, for example,
280 the following would cause a library to be searched for in either the
281 .I lib
282 or
283 .I lib64
284 subdirectory below the directory containing the program to be executed:
285
286 $ \fBLD_LIBRARY_PATH='$ORIGIN/$LIB' prog\fP
287
288 (Note the use of single quotes, which prevent expansion of
289 .I ORIGIN
290 and
291 .I LIB
292 as shell variables!)
293 .TP
294 .B LD_PRELOAD
295 A list of additional, user-specified, ELF shared
296 objects to be loaded before all others.
297 The items of the list can be separated by spaces or colons.
298 This can be used to selectively override functions in other shared objects.
299 The objects are searched for using the rules given under DESCRIPTION.
300 In secure-execution mode,
301 preload pathnames containing slashes are ignored,
302 and shared objects in the standard search directories are loaded
303 only if the set-user-ID mode bit is enabled on the shared object file.
304
305 Within the pathnames specified in
306 .BR LD_PRELOAD ,
307 the dynamic linker understands the strings
308 .IR $ORIGIN ,
309 .IR $LIB ,
310 and
311 .IR $PLATFORM
312 (or the versions using curly braces around the names)
313 as described above in
314 .IR "Rpath token expansion" .
315 .\" Tested with the following:
316 .\"
317 .\" LD_PRELOAD='$LIB/libmod.so' LD_LIBRARY_PATH=. ./prog
318 .\"
319 .\" which will reload the libmod.so in 'lib' or 'lib64', using it
320 .\" in preference to the version in '.'.
321 .TP
322 .BR LD_TRACE_LOADED_OBJECTS " (ELF only)"
323 If set (to any value), causes the program to list its dynamic
324 dependencies, as if run by
325 .BR ldd (1),
326 instead of running normally.
327 .LP
328 Then there are lots of more or less obscure variables,
329 many obsolete or only for internal use.
330 .TP
331 .BR LD_AOUT_LIBRARY_PATH " (libc5)"
332 Version of
333 .B LD_LIBRARY_PATH
334 for a.out binaries only.
335 Old versions of ld\-linux.so.1 also supported
336 .BR LD_ELF_LIBRARY_PATH .
337 .TP
338 .BR LD_AOUT_PRELOAD " (libc5)"
339 Version of
340 .B LD_PRELOAD
341 for a.out binaries only.
342 Old versions of ld\-linux.so.1 also supported
343 .BR LD_ELF_PRELOAD .
344 .TP
345 .BR LD_AUDIT " (glibc since 2.4)"
346 A colon-separated list of user-specified, ELF shared objects
347 to be loaded before all others in a separate linker namespace
348 (i.e., one that does not intrude upon the normal symbol bindings that
349 would occur in the process).
350 These objects can be used to audit the operation of the dynamic linker.
351 .B LD_AUDIT
352 is ignored in secure-execution mode.
353
354 The dynamic linker will notify the audit
355 shared objects at so-called auditing checkpoints\(emfor example,
356 loading a new shared object, resolving a symbol,
357 or calling a symbol from another shared object\(emby
358 calling an appropriate function within the audit shared object.
359 For details, see
360 .BR rtld-audit (7).
361 The auditing interface is largely compatible with that provided on Solaris,
362 as described in its
363 .IR "Linker and Libraries Guide" ,
364 in the chapter
365 .IR "Runtime Linker Auditing Interface" .
366 .TP
367 .BR LD_BIND_NOT " (glibc since 2.1.95)"
368 If this environment variable is set to a nonempty string,
369 do not update the GOT (global offset table) and PLT (procedure linkage table)
370 after resolving a symbol.
371 .TP
372 .BR LD_DEBUG " (glibc since 2.1)"
373 Output verbose debugging information about the dynamic linker.
374 If set to
375 .BR all ,
376 print all debugging information,
377 Setting this variable to
378 .BR help
379 does not run the specified program,
380 and displays a help message about which categories can be specified in this
381 environment variable.
382 The categories are:
383 .RS
384 .TP 12
385 .I bindings
386 Display information about which definition each symbol is bound to.
387 .TP
388 .I files
389 Display progress for input file.
390 .TP
391 .I libs
392 Display library search paths.
393 .TP
394 .I reloc
395 Display relocation processing.
396 .TP
397 .I scopes
398 Display scope information.
399 .TP
400 .I statistics
401 Display relocation statistics.
402 .TP
403 .I symbols
404 Display search paths for each symbol look-up.
405 .TP
406 .I unused
407 Determine unused DSOs.
408 .TP
409 .I versions
410 Display version dependencies.
411 .RE
412 .IP
413 The value in
414 .BR LD_DEBUG
415 can specify multiple categories, separated by colons, commas,
416 or (if the value is quoted) spaces.
417
418 Since glibc 2.3.4,
419 .B LD_DEBUG
420 is ignored in secure-execution mode, unless the file
421 .IR /etc/suid\-debug
422 exists (the content of the file is irrelevant).
423 .TP
424 .BR LD_DEBUG_OUTPUT " (glibc since 2.1)"
425 File in which
426 .B LD_DEBUG
427 output should be written.
428 The default is standard error.
429 .B LD_DEBUG_OUTPUT
430 is ignored in secure-execution mode.
431 .TP
432 .BR LD_DYNAMIC_WEAK " (glibc since 2.1.91)"
433 If this environment variable is defined (with any value),
434 allow weak symbols to be overridden (reverting to old glibc behavior).
435 .\" See weak handling
436 .\" https://www.sourceware.org/ml/libc-hacker/2000-06/msg00029.html
437 .\" To: GNU libc hacker <libc-hacker at sourceware dot cygnus dot com>
438 .\" Subject: weak handling
439 .\" From: Ulrich Drepper <drepper at redhat dot com>
440 .\" Date: 07 Jun 2000 20:08:12 -0700
441 .\" Reply-To: drepper at cygnus dot com (Ulrich Drepper)
442 Since glibc 2.3.4,
443 .B LD_DYNAMIC_WEAK
444 is ignored in secure-execution mode.
445 .TP
446 .BR LD_HWCAP_MASK " (glibc since 2.1)"
447 Mask for hardware capabilities.
448 .TP
449 .BR LD_KEEPDIR " (a.out only; libc5)"
450 Don't ignore the directory in the names of a.out libraries to be loaded.
451 Use of this option is strongly discouraged.
452 .TP
453 .BR LD_NOWARN " (a.out only; libc5)"
454 Suppress warnings about a.out libraries with incompatible minor
455 version numbers.
456 .TP
457 .BR LD_ORIGIN_PATH " (glibc since 2.1)"
458 Path where the binary is found.
459 Since glibc 2.4,
460 .B LD_ORIGIN_PATH
461 is ignored in secure-execution mode.
462 .\" Only used if $ORIGIN can't be determined by normal means
463 .\" (from the origin path saved at load time, or from /proc/self/exe)?
464 .TP
465 .BR LD_POINTER_GUARD " (glibc from 2.4 to 2.22)"
466 Set to 0 to disable pointer guarding.
467 Any other value enables pointer guarding, which is also the default.
468 Pointer guarding is a security mechanism whereby some pointers to code
469 stored in writable program memory (return addresses saved by
470 .BR setjmp (3)
471 or function pointers used by various glibc internals) are mangled
472 semi-randomly to make it more difficult for an attacker to hijack
473 the pointers for use in the event of a buffer overrun or
474 stack-smashing attack.
475 Since glibc 2.23,
476 .\" commit a014cecd82b71b70a6a843e250e06b541ad524f7
477 .B LD_POINTER_GUARD
478 can no longer be used to disable pointer guarding,
479 which is now always enabled.
480 .TP
481 .BR LD_PROFILE " (glibc since 2.1)"
482 The name of a (single) shared object to be profiled,
483 specified either as a pathname or a soname.
484 Profiling output is appended to the file whose name is:
485 "\fI$LD_PROFILE_OUTPUT\fP/\fI$LD_PROFILE\fP.profile".
486 .TP
487 .BR LD_PROFILE_OUTPUT " (glibc since 2.1)"
488 Directory where
489 .B LD_PROFILE
490 output should be written.
491 If this variable is not defined, or is defined as an empty string,
492 then the default is
493 .IR /var/tmp .
494 .B LD_PROFILE_OUTPUT
495 is ignored in secure-execution mode; instead
496 .IR /var/profile
497 is always used.
498 .TP
499 .BR LD_SHOW_AUXV " (glibc since 2.1)"
500 If this environment variable is defined (with any value),
501 show the auxiliary array passed up from the kernel (see also
502 .BR getauxval (3)).
503 Since glibc 2.3.5,
504 .B LD_SHOW_AUXV
505 is ignored in secure-execution mode.
506 .TP
507 .BR LD_TRACE_PRELINKING " (glibc since 2.4)"
508 If this environment variable is defined (with any value),
509 trace prelinking of the object whose name is assigned to
510 this environment variable.
511 (Use
512 .BR ldd (1)
513 to get a list of the objects that might be traced.)
514 If the object name is not recognized,
515 .\" (This is what seems to happen, from experimenting)
516 then all prelinking activity is traced.
517 .TP
518 .BR LD_USE_LOAD_BIAS " (glibc since 2.3.3)"
519 .\" http://sources.redhat.com/ml/libc-hacker/2003-11/msg00127.html
520 .\" Subject: [PATCH] Support LD_USE_LOAD_BIAS
521 .\" Jakub Jelinek
522 By default (i.e., if this variable is not defined),
523 executables and prelinked
524 shared objects will honor base addresses of their dependent shared objects
525 and (nonprelinked) position-independent executables (PIEs)
526 and other shared objects will not honor them.
527 If
528 .B LD_USE_LOAD_BIAS
529 is defined with the value 1, both executables and PIEs
530 will honor the base addresses.
531 If
532 .B LD_USE_LOAD_BIAS
533 is defined with the value 0,
534 neither executables nor PIEs will honor the base addresses.
535 This variable is ignored in secure-execution mode.
536 .TP
537 .BR LD_VERBOSE " (glibc since 2.1)"
538 If set to a nonempty string,
539 output symbol versioning information about the
540 program if the
541 .B LD_TRACE_LOADED_OBJECTS
542 environment variable has been set.
543 .TP
544 .BR LD_WARN " (ELF only; glibc since 2.1.3)
545 If set to a nonempty string, warn about unresolved symbols.
546 .TP
547 .BR LD_PREFER_MAP_32BIT_EXEC " (x86-64 only; glibc since 2.23)"
548 According to the Intel Silvermont software optimization guide, for 64-bit
549 applications, branch prediction performance can be negatively impacted
550 when the target of a branch is more than 4GB away from the branch.
551 If this environment variable is set (to any value),
552 .BR ld.so
553 will first try to map executable pages using the
554 .BR mmap (2)
555 .BR MAP_32BIT
556 flag, and fall back to mapping without that flag if that attempt fails.
557 NB: MAP_32BIT will map to the low 2GB (not 4GB) of the address space.
558 Because
559 .B MAP_32BIT
560 reduces the address range available for address space layout
561 randomization (ASLR),
562 .B LD_PREFER_MAP_32BIT_EXEC
563 is always disabled in secure-execution mode.
564 .TP
565 .BR LDD_ARGV0 " (libc5)"
566 .IR argv [0]
567 to be used by
568 .BR ldd (1)
569 when none is present.
570 .SH FILES
571 .PD 0
572 .TP
573 .I /lib/ld.so
574 a.out dynamic linker/loader
575 .TP
576 .IR /lib/ld\-linux.so. { 1 , 2 }
577 ELF dynamic linker/loader
578 .TP
579 .I /etc/ld.so.cache
580 File containing a compiled list of directories in which to search for
581 shared objects and an ordered list of candidate shared objects.
582 .TP
583 .I /etc/ld.so.preload
584 File containing a whitespace-separated list of ELF shared objects to
585 be loaded before the program.
586 .TP
587 .B lib*.so*
588 shared objects
589 .PD
590 .SH NOTES
591 .SS Hardware capabilities
592 Some shared objects are compiled using hardware-specific instructions which do
593 not exist on every CPU.
594 Such objects should be installed in directories whose names define the
595 required hardware capabilities, such as
596 .IR /usr/lib/sse2/ .
597 The dynamic linker checks these directories against the hardware of the
598 machine and selects the most suitable version of a given shared object.
599 Hardware capability directories can be cascaded to combine CPU features.
600 The list of supported hardware capability names depends on the CPU.
601 The following names are currently recognized:
602 .TP
603 .B Alpha
604 ev4, ev5, ev56, ev6, ev67
605 .TP
606 .B MIPS
607 loongson2e, loongson2f, octeon, octeon2
608 .TP
609 .B PowerPC
610 4xxmac, altivec, arch_2_05, arch_2_06, booke, cellbe, dfp, efpdouble, efpsingle,
611 fpu, ic_snoop, mmu, notb, pa6t, power4, power5, power5+, power6x, ppc32, ppc601,
612 ppc64, smt, spe, ucache, vsx
613 .TP
614 .B SPARC
615 flush, muldiv, stbar, swap, ultra3, v9, v9v, v9v2
616 .TP
617 .B s390
618 dfp, eimm, esan3, etf3enh, g5, highgprs, hpage, ldisp, msa, stfle,
619 z900, z990, z9-109, z10, zarch
620 .TP
621 .B x86 (32-bit only)
622 acpi, apic, clflush, cmov, cx8, dts, fxsr, ht, i386, i486, i586, i686, mca, mmx,
623 mtrr, pat, pbe, pge, pn, pse36, sep, ss, sse, sse2, tm
624 .SH SEE ALSO
625 .BR ld (1),
626 .BR ldd (1),
627 .BR pldd (1),
628 .BR sprof (1),
629 .BR dlopen (3),
630 .BR getauxval (3),
631 .BR capabilities (7),
632 .BR rtld-audit (7),
633 .BR ldconfig (8),
634 .BR sln (8)
635 .\" .SH AUTHORS
636 .\" ld.so: David Engel, Eric Youngdale, Peter MacDonald, Hongjiu Lu, Linus
637 .\" Torvalds, Lars Wirzenius and Mitch D'Souza
638 .\" ld-linux.so: Roland McGrath, Ulrich Drepper and others.
639 .\"
640 .\" In the above, (libc5) stands for David Engel's ld.so/ld-linux.so.