1 .\" %%%LICENSE_START(PUBLIC_DOMAIN)
2 .\" This is in the public domain
5 .TH LD.SO 8 2014-07-08 "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 library (in which case no command-line options
11 to the dynamic linker can be passed and, in the ELF case, the dynamic linker
12 which is stored in the
14 section of the program is executed) or directly by running:
17 [OPTIONS] [PROGRAM [ARGUMENTS]]
23 find and load the shared libraries needed by a program, prepare
24 the program to run, and then run it.
26 Linux binaries require dynamic linking (linking at run time)
35 handles a.out binaries, a format used long ago;
37 handles ELF (\fI/lib/ld-linux.so.1\fP for libc5, \fI/lib/ld-linux.so.2\fP
38 for glibc2), which everybody has been using for years now.
39 Otherwise, both have the same behavior, and use the same
40 support files and programs
46 When resolving library dependencies,
47 the dynamic linker first inspects each dependency
48 string to see if it contains a slash (this can occur if
49 a library pathname containing slashes was specified at link time).
50 If a slash is found, then the dependency string is interpreted as
51 a (relative or absolute) pathname,
52 and the library is loaded using that pathname.
54 If a library dependency does not contain a slash,
55 then it is searched for in the following order:
57 (ELF only) Using the directories specified in the
58 DT_RPATH dynamic section attribute
59 of the binary if present and DT_RUNPATH attribute does not exist.
60 Use of DT_RPATH is deprecated.
62 Using the environment variable
64 Except if the executable is a set-user-ID/set-group-ID binary,
65 in which case it is ignored.
67 (ELF only) Using the directories specified in the
68 DT_RUNPATH dynamic section attribute
69 of the binary if present.
72 .IR /etc/ld.so.cache ,
73 which contains a compiled list of candidate libraries previously found
74 in the augmented library path.
75 If, however, the binary was linked with the
77 linker option, libraries in the default library paths are skipped.
78 Libraries installed in hardware capability directories (see below)
79 are preferred to other libraries.
85 If the binary was linked with the
87 linker option, this step is skipped.
88 .SS Rpath token expansion
91 understands certain strings in an rpath specification (DT_RPATH or DT_RUNPATH); those strings are substituted as follows
93 .IR $ORIGIN " (or equivalently " ${ORIGIN} )
95 the directory containing the application executable.
96 Thus, an application located in
98 could be compiled with
100 gcc \-Wl,\-rpath,\(aq$ORIGIN/../lib\(aq
102 so that it finds an associated shared library in
106 is located in the directory hierarchy.
107 This facilitates the creation of "turn-key" applications that
108 do not need to be installed into special directories,
109 but can instead be unpacked into any directory
110 and still find their own shared libraries.
112 .IR $LIB " (or equivalently " ${LIB} )
117 depending on the architecture
118 (e.g., on x86-64, it expands to
121 on x86-32, it expands to
124 .IR $PLATFORM " (or equivalently " ${PLATFORM} )
125 This expands to a string corresponding to the processor type
126 of the host system (e.g., "x86_64").
127 On some architectures, the Linux kernel doesn't provide a platform
128 string to the dynamic linker.
129 The value of this string is taken from the
131 value in the auxiliary vector (see
133 .\" To get an idea of the places that $PLATFORM would match,
134 .\" look at the output of the following:
137 .\" LD_LIBRARY_PATH=/tmp/d strace -e open /bin/date 2>&1 | grep /tmp/d
139 .\" ld.so lets names be abbreviated, so $O will work for $ORIGIN;
144 List all dependencies and how they are resolved.
147 Verify that program is dynamically linked and this dynamic linker can handle
150 .B \-\-library\-path PATH
153 environment variable setting (see below).
155 .B \-\-inhibit\-rpath LIST
156 Ignore RPATH and RUNPATH information in object names in LIST.
157 This option is ignored if
159 is set-user-ID or set-group-ID.
162 Use objects named in LIST as auditors.
163 .SH HARDWARE CAPABILITIES
164 Some libraries are compiled using hardware-specific instructions which do
165 not exist on every CPU.
166 Such libraries should be installed in directories whose names define the
167 required hardware capabilities, such as
169 The dynamic linker checks these directories against the hardware of the
170 machine and selects the most suitable version of a given library.
171 Hardware capability directories can be cascaded to combine CPU features.
172 The list of supported hardware capability names depends on the CPU.
173 The following names are currently recognized:
176 ev4, ev5, ev56, ev6, ev67
179 loongson2e, loongson2f, octeon, octeon2
182 4xxmac, altivec, arch_2_05, arch_2_06, booke, cellbe, dfp, efpdouble, efpsingle,
183 fpu, ic_snoop, mmu, notb, pa6t, power4, power5, power5+, power6x, ppc32, ppc601,
184 ppc64, smt, spe, ucache, vsx
187 flush, muldiv, stbar, swap, ultra3, v9, v9v, v9v2
190 dfp, eimm, esan3, etf3enh, g5, highgprs, hpage, ldisp, msa, stfle,
191 z900, z990, z9-109, z10, zarch
194 acpi, apic, clflush, cmov, cx8, dts, fxsr, ht, i386, i486, i586, i686, mca, mmx,
195 mtrr, pat, pbe, pge, pn, pse36, sep, ss, sse, sse2, tm
197 Among the more important environment variables are the following:
201 Each shared library can inform the dynamic linker of the minimum kernel ABI
202 version that it requires.
203 (This requirement is encoded in an ELF note section that is viewable via
206 .BR NT_GNU_ABI_TAG .)
208 the dynamic linker determines the ABI version of the running kernel and
209 will reject loading shared libraries that specify minimum ABI versions
210 that exceed that ABI version.
214 cause the dynamic linker to assume that it is running on a system with
215 a different kernel ABI version.
216 For example, the following command line causes the
217 dynamic linker to assume it is running on Linux 2.2.5 when loading
218 the shared libraries required by
223 $ \fBLD_ASSUME_KERNEL=2.2.5 ./myprog\fP
227 On systems that provide multiple versions of a shared library
228 (in different directories in the search path) that have
229 different minimum kernel ABI version requirements,
231 can be used to select the version of the library that is used
232 (dependent on the directory search order).
233 Historically, the most common use of the
235 feature was to manually select the older
236 LinuxThreads POSIX threads implementation on systems that provided both
237 LinuxThreads and NPTL
238 (which latter was typically the default on such systems);
244 Don't update the Global Offset Table (GOT) and Procedure Linkage Table (PLT)
245 when resolving a symbol.
248 (libc5; glibc since 2.1.1)
249 If set to a nonempty string,
250 causes the dynamic linker to resolve all symbols
251 at program startup instead of deferring function call resolution to the point
252 when they are first referenced.
253 This is useful when using a debugger.
256 A colon-separated list of directories in which to search for
257 ELF libraries at execution-time.
260 environment variable.
261 Ignored in set-user-ID and set-group-ID programs.
264 A list of additional, user-specified, ELF shared
265 libraries to be loaded before all others.
266 The items of the list can be separated by spaces or colons.
267 This can be used to selectively override functions in other shared libraries.
268 The libraries are searched for using the rules given under DESCRIPTION.
269 For set-user-ID/set-group-ID ELF binaries,
270 preload pathnames containing slashes are ignored,
271 and libraries in the standard search directories are loaded
272 only if the set-user-ID permission bit is enabled on the library file.
274 .B LD_TRACE_LOADED_OBJECTS
276 If set to a nonempty string, causes the program to list its dynamic library
277 dependencies, as if run by
279 instead of running normally.
281 Then there are lots of more or less obscure variables,
282 many obsolete or only for internal use.
284 .B LD_AOUT_LIBRARY_PATH
288 for a.out binaries only.
289 Old versions of ld\-linux.so.1 also supported
290 .BR LD_ELF_LIBRARY_PATH .
296 for a.out binaries only.
297 Old versions of ld\-linux.so.1 also supported
302 A colon-separated list of user-specified, ELF shared objects
303 to be loaded before all others in a separate linker namespace
304 (i.e., one that does not intrude upon the normal symbol bindings that
305 would occur in the process).
306 These libraries can be used to audit the operation of the dynamic linker.
308 is ignored for set-user-ID/set-group-ID binaries.
310 The dynamic linker will notify the audit
311 libraries at so-called auditing checkpoints\(emfor example,
312 loading a new library, resolving a symbol,
313 or calling a symbol from another shared object\(emby
314 calling an appropriate function within the audit library.
317 The auditing interface is largely compatible with that provided on Solaris,
319 .IR "Linker and Libraries Guide" ,
321 .IR "Runtime Linker Auditing Interface" .
325 Do not update the GOT (global offset table) and PLT (procedure linkage table)
326 after resolving a symbol.
330 Output verbose debugging information about the dynamic linker.
333 prints all debugging information it has, if set to
335 prints a help message about which categories can be specified in this
336 environment variable.
339 is ignored for set-user-ID/set-group-ID binaries.
345 output should be written.
346 The default is standard error.
348 is ignored for set-user-ID/set-group-ID binaries.
352 Allow weak symbols to be overridden (reverting to old glibc behavior).
353 For security reasons, since glibc 2.3.4,
355 is ignored for set-user-ID/set-group-ID binaries.
359 Mask for hardware capabilities.
363 Don't ignore the directory in the names of a.out libraries to be loaded.
364 Use of this option is strongly discouraged.
368 Suppress warnings about a.out libraries with incompatible minor
373 Path where the binary is found (for non-set-user-ID programs).
374 For security reasons, since glibc 2.4,
376 is ignored for set-user-ID/set-group-ID binaries.
377 .\" Only used if $ORIGIN can't be determined by normal means
378 .\" (from the origin path saved at load time, or from /proc/self/exe)?
382 Set to 0 to disable pointer guarding.
383 Any other value enables pointer guarding, which is also the default.
384 Pointer guarding is a security mechanism whereby some pointers to code
385 stored in writable program memory (return addresses saved by
387 or function pointers used by various glibc internals) are mangled
388 semi-randomly to make it more difficult for an attacker to hijack
389 the pointers for use in the event of a buffer overrun or
390 stack-smashing attack.
394 The name of a (single) shared object to be profiled,
395 specified either as a pathname or a soname.
396 Profiling output is appended to the file whose name is:
397 "\fI$LD_PROFILE_OUTPUT\fP/\fI$LD_PROFILE\fP.profile".
403 output should be written.
404 If this variable is not defined, or is defined as an empty string,
408 is ignored for set-user-ID and set-group-ID programs,
414 Show auxiliary array passed up from the kernel.
415 For security reasons, since glibc 2.3.5,
417 is ignored for set-user-ID/set-group-ID binaries.
419 .\" Document LD_TRACE_PRELINKING (e.g.: LD_TRACE_PRELINKING=libx1.so ./prog)
420 .\" Available since glibc 2.3
421 .\" Also enables DL_DEBUG_PRELINK
424 .\" http://sources.redhat.com/ml/libc-hacker/2003-11/msg00127.html
425 .\" Subject: [PATCH] Support LD_USE_LOAD_BIAS
427 By default (i.e., if this variable is not defined)
428 executables and prelinked
429 shared objects will honor base addresses of their dependent libraries
430 and (nonprelinked) position-independent executables (PIEs)
431 and other shared objects will not honor them.
434 is defined wit the value, both executables and PIEs
435 will honor the base addresses.
438 is defined with the value 0,
439 neither executables nor PIEs will honor the base addresses.
440 This variable is ignored by set-user-ID and set-group-ID programs.
444 If set to a nonempty string,
445 output symbol versioning information about the
447 .B LD_TRACE_LOADED_OBJECTS
448 environment variable has been set.
451 (ELF only)(glibc since 2.1.3)
452 If set to a nonempty string, warn about unresolved symbols.
459 when none is present.
464 a.out dynamic linker/loader
466 .IR /lib/ld\-linux.so. { 1 , 2 }
467 ELF dynamic linker/loader
470 File containing a compiled list of directories in which to search for
471 libraries and an ordered list of candidate libraries.
473 .I /etc/ld.so.preload
474 File containing a whitespace-separated list of ELF shared libraries to
475 be loaded before the program.
483 functionality is available for executables compiled using libc version
485 ELF functionality is available since Linux 1.1.52 and libc5.
494 .\" ld.so: David Engel, Eric Youngdale, Peter MacDonald, Hongjiu Lu, Linus
495 .\" Torvalds, Lars Wirzenius and Mitch D'Souza
496 .\" ld-linux.so: Roland McGrath, Ulrich Drepper and others.
498 .\" In the above, (libc5) stands for David Engel's ld.so/ld-linux.so.