1 .\" %%%LICENSE_START(PUBLIC_DOMAIN)
2 .\" This is in the public domain
5 .TH LD.SO 8 2016-05-09 "GNU" "Linux Programmer's Manual"
7 ld.so, ld-linux.so* \- dynamic linker/loader
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
15 section of the program is executed) or directly by running:
18 [OPTIONS] [PROGRAM [ARGUMENTS]]
24 find and load the shared objects (shared libraries) needed by a program,
25 prepare the program to run, and then run it.
27 Linux binaries require dynamic linking (linking at run time)
36 handles a.out binaries, a format used long ago;
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
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.
55 If a shared object dependency does not contain a slash,
56 then it is searched for in the following order:
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.
63 Using the environment variable
65 (unless the executable is being run in secure-execution mode; see below).
66 in which case it is ignored.
68 (ELF only) Using the directories specified in the
69 DT_RUNPATH dynamic section attribute
70 of the binary if present.
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
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.
86 (On some 64-bit architectures, the default paths for 64-bit shared objects are
90 If the binary was linked with the
92 linker option, this step is skipped.
93 .SS Rpath token expansion
96 understands certain strings in an rpath specification (DT_RPATH or DT_RUNPATH); those strings are substituted as follows
98 .IR $ORIGIN " (or equivalently " ${ORIGIN} )
100 the directory containing the program or shared object.
101 Thus, an application located in
103 could be compiled with
105 gcc \-Wl,\-rpath,\(aq$ORIGIN/../lib\(aq
107 so that it finds an associated shared object in
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.
117 .IR $LIB " (or equivalently " ${LIB} )
122 depending on the architecture
123 (e.g., on x86-64, it expands to
126 on x86-32, it expands to
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
136 value in the auxiliary vector (see
138 .\" To get an idea of the places that $PLATFORM would match,
139 .\" look at the output of the following:
142 .\" LD_LIBRARY_PATH=/tmp/d strace -e open /bin/date 2>&1 | grep /tmp/d
144 .\" ld.so lets names be abbreviated, so $O will work for $ORIGIN;
149 List all dependencies and how they are resolved.
152 Verify that program is dynamically linked and this dynamic linker can handle
157 .IR /etc/ld.so.cache .
159 .BI \-\-library\-path " path"
164 environment variable setting (see below).
170 are interpreted as for the
172 environment variable.
174 .BI \-\-inhibit\-rpath " list"
175 Ignore RPATH and RUNPATH information in object names in
177 This option is ignored when running in secure-execution mode (see below).
179 .BI \-\-audit " list"
184 Various environment variables influence the operation of the dynamic linker.
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
193 entry in the auxiliary vector (see
196 This entry may have a nonzero value for various reasons, including:
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.
203 A process with a non-root user ID executed a binary that
204 conferred permitted or effective capabilities.
206 A nonzero value may have been set by a Linux Security Module.
208 .SS Environment variables
209 Among the more important environment variables are the following:
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
217 .BR NT_GNU_ABI_TAG .)
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.
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
234 $ \fBLD_ASSUME_KERNEL=2.2.5 ./myprog\fP
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,
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
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);
254 (libc5; glibc since 2.1.1)
255 If set to a nonempty string,
256 causes the dynamic linker to resolve all symbols
257 at program startup instead of deferring function call resolution to the point
258 when they are first referenced.
259 This is useful when using a debugger.
262 A list of directories in which to search for
263 ELF libraries at execution-time.
264 The items in the list are separated by either colons or semicolons.
267 environment variable.
268 This variable is ignored in secure-execution mode.
270 Within the pathnames specified in
271 .BR LD_LIBRARY_PATH ,
272 the dynamic linker expands the strings
277 (or the versions using curly braces around the names)
278 as described above in
279 .IR "Rpath token expansion" .
281 the following would cause a library to be searched for in either the
285 subdirectory below the directory containing the program to be executed:
287 $ \fBLD_LIBRARY_PATH='$ORIGIN/$LIB' prog\fP
289 (Note the use of single quotes, which prevent expansion of
296 A list of additional, user-specified, ELF shared
297 objects to be loaded before all others.
298 The items of the list can be separated by spaces or colons.
299 This can be used to selectively override functions in other shared objects.
300 The objects are searched for using the rules given under DESCRIPTION.
301 In secure-execution mode,
302 preload pathnames containing slashes are ignored,
303 and shared objects in the standard search directories are loaded
304 only if the set-user-ID mode bit is enabled on the shared object file.
306 Within the pathnames specified in
308 the dynamic linker understands the strings
313 (or the versions using curly braces around the names)
314 as described above in
315 .IR "Rpath token expansion" .
316 .\" Tested with the following:
318 .\" LD_PRELOAD='$LIB/libmod.so' LD_LIBRARY_PATH=. ./prog
320 .\" which will reload the libmod.so in 'lib' or 'lib64', using it
321 .\" in preference to the version in '.'.
323 .B LD_TRACE_LOADED_OBJECTS
325 If set (to any value), causes the program to list its dynamic
326 dependencies, as if run by
328 instead of running normally.
330 Then there are lots of more or less obscure variables,
331 many obsolete or only for internal use.
333 .B LD_AOUT_LIBRARY_PATH
337 for a.out binaries only.
338 Old versions of ld\-linux.so.1 also supported
339 .BR LD_ELF_LIBRARY_PATH .
345 for a.out binaries only.
346 Old versions of ld\-linux.so.1 also supported
351 A colon-separated list of user-specified, ELF shared objects
352 to be loaded before all others in a separate linker namespace
353 (i.e., one that does not intrude upon the normal symbol bindings that
354 would occur in the process).
355 These objects can be used to audit the operation of the dynamic linker.
357 is ignored in secure-execution mode.
359 The dynamic linker will notify the audit
360 shared objects at so-called auditing checkpoints\(emfor example,
361 loading a new shared object, resolving a symbol,
362 or calling a symbol from another shared object\(emby
363 calling an appropriate function within the audit shared object.
366 The auditing interface is largely compatible with that provided on Solaris,
368 .IR "Linker and Libraries Guide" ,
370 .IR "Runtime Linker Auditing Interface" .
374 If this environment variable is set to a nonempty string,
375 do not update the GOT (global offset table) and PLT (procedure linkage table)
376 after resolving a symbol.
380 Output verbose debugging information about the dynamic linker.
383 print all debugging information,
384 Setting this variable to
386 does not run the specified program,
387 and displays a help message about which categories can be specified in this
388 environment variable.
393 Display information about which definition each symbol is bound to.
396 Display progress for input file.
399 Display library search paths.
402 Display relocation processing.
405 Display scope information.
408 Display relocation statistics.
411 Display search paths for each symbol look-up.
414 Determine unused DSOs.
417 Display version dependencies.
422 can specify multiple categories, separated by colons, commas,
423 or (if the value is quoted) spaces.
427 is ignored in secure-execution mode, unless the file
429 exists (the content of the file is irrelevant).
435 output should be written.
436 The default is standard error.
438 is ignored in secure-execution mode.
442 If this environment variable is defined (with any value),
443 allow weak symbols to be overridden (reverting to old glibc behavior).
444 .\" See weak handling
445 .\" https://www.sourceware.org/ml/libc-hacker/2000-06/msg00029.html
446 .\" To: GNU libc hacker <libc-hacker at sourceware dot cygnus dot com>
447 .\" Subject: weak handling
448 .\" From: Ulrich Drepper <drepper at redhat dot com>
449 .\" Date: 07 Jun 2000 20:08:12 -0700
450 .\" Reply-To: drepper at cygnus dot com (Ulrich Drepper)
453 is ignored in secure-execution mode.
457 Mask for hardware capabilities.
461 Don't ignore the directory in the names of a.out libraries to be loaded.
462 Use of this option is strongly discouraged.
466 Suppress warnings about a.out libraries with incompatible minor
471 Path where the binary is found.
474 is ignored in secure-execution mode.
475 .\" Only used if $ORIGIN can't be determined by normal means
476 .\" (from the origin path saved at load time, or from /proc/self/exe)?
479 (glibc from 2.4 to 2.22)
480 Set to 0 to disable pointer guarding.
481 Any other value enables pointer guarding, which is also the default.
482 Pointer guarding is a security mechanism whereby some pointers to code
483 stored in writable program memory (return addresses saved by
485 or function pointers used by various glibc internals) are mangled
486 semi-randomly to make it more difficult for an attacker to hijack
487 the pointers for use in the event of a buffer overrun or
488 stack-smashing attack.
490 .\" commit a014cecd82b71b70a6a843e250e06b541ad524f7
492 can no longer be used to disable pointer guarding,
493 which is now always enabled.
497 The name of a (single) shared object to be profiled,
498 specified either as a pathname or a soname.
499 Profiling output is appended to the file whose name is:
500 "\fI$LD_PROFILE_OUTPUT\fP/\fI$LD_PROFILE\fP.profile".
506 output should be written.
507 If this variable is not defined, or is defined as an empty string,
511 is ignored in secure-execution mode; instead
517 If this environment variable is defined (with any value),
518 show the auxiliary array passed up from the kernel (see also
522 is ignored in secure-execution mode.
524 .B LD_TRACE_PRELINKING
526 If this environment variable is defined (with any value),
527 trace prelinking of the object whose name is assigned to
528 this environment variable.
531 to get a list of the objects that might be traced.)
532 If the object name is not recognized,
533 .\" (This is what seems to happen, from experimenting)
534 then all prelinking activity is traced.
537 .\" http://sources.redhat.com/ml/libc-hacker/2003-11/msg00127.html
538 .\" Subject: [PATCH] Support LD_USE_LOAD_BIAS
540 By default (i.e., if this variable is not defined),
541 executables and prelinked
542 shared objects will honor base addresses of their dependent shared objects
543 and (nonprelinked) position-independent executables (PIEs)
544 and other shared objects will not honor them.
547 is defined with the value 1, both executables and PIEs
548 will honor the base addresses.
551 is defined with the value 0,
552 neither executables nor PIEs will honor the base addresses.
553 This variable is ignored in secure-execution mode.
557 If set to a nonempty string,
558 output symbol versioning information about the
560 .B LD_TRACE_LOADED_OBJECTS
561 environment variable has been set.
564 (ELF only)(glibc since 2.1.3)
565 If set to a nonempty string, warn about unresolved symbols.
567 .B LD_PREFER_MAP_32BIT_EXEC
568 (x86-64 only)(glibc since 2.23)
569 According to the Intel Silvermont software optimization guide, for 64-bit
570 applications, branch prediction performance can be negatively impacted
571 when the target of a branch is more than 4GB away from the branch.
572 If this environment variable is set (to any value),
574 will first try to map executable pages using the
577 flag, and fall back to mapping without that flag if that attempt fails.
578 NB: MAP_32BIT will map to the low 2GB (not 4GB) of the address space.
581 reduces the address range available for address space layout
582 randomization (ASLR),
583 .B LD_PREFER_MAP_32BIT_EXEC
584 is always disabled in secure-execution mode.
591 when none is present.
596 a.out dynamic linker/loader
598 .IR /lib/ld\-linux.so. { 1 , 2 }
599 ELF dynamic linker/loader
602 File containing a compiled list of directories in which to search for
603 shared objects and an ordered list of candidate shared objects.
605 .I /etc/ld.so.preload
606 File containing a whitespace-separated list of ELF shared objects to
607 be loaded before the program.
615 functionality is available for executables compiled using libc version
617 ELF functionality is available since Linux 1.1.52 and libc5.
618 .SS Hardware capabilities
619 Some shared objects are compiled using hardware-specific instructions which do
620 not exist on every CPU.
621 Such objects should be installed in directories whose names define the
622 required hardware capabilities, such as
624 The dynamic linker checks these directories against the hardware of the
625 machine and selects the most suitable version of a given shared object.
626 Hardware capability directories can be cascaded to combine CPU features.
627 The list of supported hardware capability names depends on the CPU.
628 The following names are currently recognized:
631 ev4, ev5, ev56, ev6, ev67
634 loongson2e, loongson2f, octeon, octeon2
637 4xxmac, altivec, arch_2_05, arch_2_06, booke, cellbe, dfp, efpdouble, efpsingle,
638 fpu, ic_snoop, mmu, notb, pa6t, power4, power5, power5+, power6x, ppc32, ppc601,
639 ppc64, smt, spe, ucache, vsx
642 flush, muldiv, stbar, swap, ultra3, v9, v9v, v9v2
645 dfp, eimm, esan3, etf3enh, g5, highgprs, hpage, ldisp, msa, stfle,
646 z900, z990, z9-109, z10, zarch
649 acpi, apic, clflush, cmov, cx8, dts, fxsr, ht, i386, i486, i586, i686, mca, mmx,
650 mtrr, pat, pbe, pge, pn, pse36, sep, ss, sse, sse2, tm
658 .BR capabilities (7),
663 .\" ld.so: David Engel, Eric Youngdale, Peter MacDonald, Hongjiu Lu, Linus
664 .\" Torvalds, Lars Wirzenius and Mitch D'Souza
665 .\" ld-linux.so: Roland McGrath, Ulrich Drepper and others.
667 .\" In the above, (libc5) stands for David Engel's ld.so/ld-linux.so.