]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man8/ld.so.8
ld.so.8: LD_POINTER_GUARD has been removed in glibc 2.23
[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 Except if the executable is a set-user-ID/set-group-ID binary,
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 archiectures, 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 if
170 .B ld.so
171 is set-user-ID or set-group-ID.
172 .TP
173 .BI \-\-audit " list"
174 Use objects named in
175 .I list
176 as auditors.
177 .SH ENVIRONMENT
178 Among the more important environment variables are the following:
179 .TP
180 .B LD_ASSUME_KERNEL
181 (glibc since 2.2.3)
182 Each shared object can inform the dynamic linker of the minimum kernel ABI
183 version that it requires.
184 (This requirement is encoded in an ELF note section that is viewable via
185 .IR "readelf\ \-n"
186 as a section labeled
187 .BR NT_GNU_ABI_TAG .)
188 At run time,
189 the dynamic linker determines the ABI version of the running kernel and
190 will reject loading shared objects that specify minimum ABI versions
191 that exceed that ABI version.
192
193 .BR LD_ASSUME_KERNEL
194 can be used to
195 cause the dynamic linker to assume that it is running on a system with
196 a different kernel ABI version.
197 For example, the following command line causes the
198 dynamic linker to assume it is running on Linux 2.2.5 when loading
199 the shared objects required by
200 .IR myprog :
201
202 .in +4n
203 .nf
204 $ \fBLD_ASSUME_KERNEL=2.2.5 ./myprog\fP
205 .fi
206 .in
207
208 On systems that provide multiple versions of a shared object
209 (in different directories in the search path) that have
210 different minimum kernel ABI version requirements,
211 .BR LD_ASSUME_KERNEL
212 can be used to select the version of the object that is used
213 (dependent on the directory search order).
214 Historically, the most common use of the
215 .BR LD_ASSUME_KERNEL
216 feature was to manually select the older
217 LinuxThreads POSIX threads implementation on systems that provided both
218 LinuxThreads and NPTL
219 (which latter was typically the default on such systems);
220 see
221 .BR pthreads (7).
222 .TP
223 .B LD_BIND_NOW
224 (libc5; glibc since 2.1.1)
225 If set to a nonempty string,
226 causes the dynamic linker to resolve all symbols
227 at program startup instead of deferring function call resolution to the point
228 when they are first referenced.
229 This is useful when using a debugger.
230 .TP
231 .B LD_LIBRARY_PATH
232 A list of directories in which to search for
233 ELF libraries at execution-time.
234 The items in the list are separated by either colons or semicolons.
235 Similar to the
236 .B PATH
237 environment variable.
238 Ignored in set-user-ID and set-group-ID programs.
239 .TP
240 .B LD_PRELOAD
241 A list of additional, user-specified, ELF shared
242 objects to be loaded before all others.
243 The items of the list can be separated by spaces or colons.
244 This can be used to selectively override functions in other shared objects.
245 The objects are searched for using the rules given under DESCRIPTION.
246 For set-user-ID/set-group-ID ELF binaries,
247 preload pathnames containing slashes are ignored,
248 and shared objects in the standard search directories are loaded
249 only if the set-user-ID mode bit is enabled on the shared object file.
250 .TP
251 .B LD_TRACE_LOADED_OBJECTS
252 (ELF only)
253 If set to a nonempty string, causes the program to list its dynamic
254 dependencies, as if run by
255 .BR ldd (1),
256 instead of running normally.
257 .LP
258 Then there are lots of more or less obscure variables,
259 many obsolete or only for internal use.
260 .TP
261 .B LD_AOUT_LIBRARY_PATH
262 (libc5)
263 Version of
264 .B LD_LIBRARY_PATH
265 for a.out binaries only.
266 Old versions of ld\-linux.so.1 also supported
267 .BR LD_ELF_LIBRARY_PATH .
268 .TP
269 .B LD_AOUT_PRELOAD
270 (libc5)
271 Version of
272 .B LD_PRELOAD
273 for a.out binaries only.
274 Old versions of ld\-linux.so.1 also supported
275 .BR LD_ELF_PRELOAD .
276 .TP
277 .B LD_AUDIT
278 (glibc since 2.4)
279 A colon-separated list of user-specified, ELF shared objects
280 to be loaded before all others in a separate linker namespace
281 (i.e., one that does not intrude upon the normal symbol bindings that
282 would occur in the process).
283 These objects can be used to audit the operation of the dynamic linker.
284 .B LD_AUDIT
285 is ignored for set-user-ID/set-group-ID binaries.
286
287 The dynamic linker will notify the audit
288 shared objects at so-called auditing checkpoints\(emfor example,
289 loading a new shared object, resolving a symbol,
290 or calling a symbol from another shared object\(emby
291 calling an appropriate function within the audit shared object.
292 For details, see
293 .BR rtld-audit (7).
294 The auditing interface is largely compatible with that provided on Solaris,
295 as described in its
296 .IR "Linker and Libraries Guide" ,
297 in the chapter
298 .IR "Runtime Linker Auditing Interface" .
299 .TP
300 .B LD_BIND_NOT
301 (glibc since 2.1.95)
302 Do not update the GOT (global offset table) and PLT (procedure linkage table)
303 after resolving a symbol.
304 .TP
305 .B LD_DEBUG
306 (glibc since 2.1)
307 Output verbose debugging information about the dynamic linker.
308 If set to
309 .B all
310 prints all debugging information it has, if set to
311 .B help
312 prints a help message about which categories can be specified in this
313 environment variable.
314 Since glibc 2.3.4,
315 .B LD_DEBUG
316 is ignored for set-user-ID/set-group-ID binaries.
317 .TP
318 .B LD_DEBUG_OUTPUT
319 (glibc since 2.1)
320 File in which
321 .B LD_DEBUG
322 output should be written.
323 The default is standard error.
324 .B LD_DEBUG_OUTPUT
325 is ignored for set-user-ID/set-group-ID binaries.
326 .TP
327 .B LD_DYNAMIC_WEAK
328 (glibc since 2.1.91)
329 Allow weak symbols to be overridden (reverting to old glibc behavior).
330 .\" See weak handling
331 .\" https://www.sourceware.org/ml/libc-hacker/2000-06/msg00029.html
332 .\" To: GNU libc hacker <libc-hacker at sourceware dot cygnus dot com>
333 .\" Subject: weak handling
334 .\" From: Ulrich Drepper <drepper at redhat dot com>
335 .\" Date: 07 Jun 2000 20:08:12 -0700
336 .\" Reply-To: drepper at cygnus dot com (Ulrich Drepper)
337 For security reasons, since glibc 2.3.4,
338 .B LD_DYNAMIC_WEAK
339 is ignored for set-user-ID/set-group-ID binaries.
340 .TP
341 .B LD_HWCAP_MASK
342 (glibc since 2.1)
343 Mask for hardware capabilities.
344 .TP
345 .B LD_KEEPDIR
346 (a.out only)(libc5)
347 Don't ignore the directory in the names of a.out libraries to be loaded.
348 Use of this option is strongly discouraged.
349 .TP
350 .B LD_NOWARN
351 (a.out only)(libc5)
352 Suppress warnings about a.out libraries with incompatible minor
353 version numbers.
354 .TP
355 .B LD_ORIGIN_PATH
356 (glibc since 2.1)
357 Path where the binary is found (for non-set-user-ID programs).
358 For security reasons, since glibc 2.4,
359 .B LD_ORIGIN_PATH
360 is ignored for set-user-ID/set-group-ID binaries.
361 .\" Only used if $ORIGIN can't be determined by normal means
362 .\" (from the origin path saved at load time, or from /proc/self/exe)?
363 .TP
364 .B LD_POINTER_GUARD
365 (glibc from 2.4 to 2.22)
366 Set to 0 to disable pointer guarding.
367 Any other value enables pointer guarding, which is also the default.
368 Pointer guarding is a security mechanism whereby some pointers to code
369 stored in writable program memory (return addresses saved by
370 .BR setjmp (3)
371 or function pointers used by various glibc internals) are mangled
372 semi-randomly to make it more difficult for an attacker to hijack
373 the pointers for use in the event of a buffer overrun or
374 stack-smashing attack.
375 Since glibc 2.23,
376 .\" commit a014cecd82b71b70a6a843e250e06b541ad524f7
377 .B LD_POINTER_GUARD
378 can no longer be used to disable pointer guarding,
379 which is now always enabled.
380 .TP
381 .B LD_PROFILE
382 (glibc since 2.1)
383 The name of a (single) shared object to be profiled,
384 specified either as a pathname or a soname.
385 Profiling output is appended to the file whose name is:
386 "\fI$LD_PROFILE_OUTPUT\fP/\fI$LD_PROFILE\fP.profile".
387 .TP
388 .B LD_PROFILE_OUTPUT
389 (glibc since 2.1)
390 Directory where
391 .B LD_PROFILE
392 output should be written.
393 If this variable is not defined, or is defined as an empty string,
394 then the default is
395 .IR /var/tmp .
396 .B LD_PROFILE_OUTPUT
397 is ignored for set-user-ID and set-group-ID programs,
398 which always use
399 .IR /var/profile .
400 .TP
401 .B LD_SHOW_AUXV
402 (glibc since 2.1)
403 Show auxiliary array passed up from the kernel.
404 For security reasons, since glibc 2.3.5,
405 .B LD_SHOW_AUXV
406 is ignored for set-user-ID/set-group-ID binaries.
407 .TP
408 .B LD_TRACE_PRELINKING
409 (glibc since 2.4)
410 Trace prelinking of the object whose name is assigned to
411 this environment variable.
412 (Use
413 .BR ldd (1)
414 to get a list of the objects that might be traced.)
415 If the object name is not recognized,
416 .\" (This is what seems to happen, from experimenting)
417 then all prelinking activity is traced.
418 .TP
419 .B LD_USE_LOAD_BIAS
420 .\" http://sources.redhat.com/ml/libc-hacker/2003-11/msg00127.html
421 .\" Subject: [PATCH] Support LD_USE_LOAD_BIAS
422 .\" Jakub Jelinek
423 By default (i.e., if this variable is not defined),
424 executables and prelinked
425 shared objects will honor base addresses of their dependent shared objects
426 and (nonprelinked) position-independent executables (PIEs)
427 and other shared objects will not honor them.
428 If
429 .B LD_USE_LOAD_BIAS
430 is defined with the value 1, both executables and PIEs
431 will honor the base addresses.
432 If
433 .B LD_USE_LOAD_BIAS
434 is defined with the value 0,
435 neither executables nor PIEs will honor the base addresses.
436 This variable is ignored by set-user-ID and set-group-ID programs.
437 .TP
438 .B LD_VERBOSE
439 (glibc since 2.1)
440 If set to a nonempty string,
441 output symbol versioning information about the
442 program if the
443 .B LD_TRACE_LOADED_OBJECTS
444 environment variable has been set.
445 .TP
446 .B LD_WARN
447 (ELF only)(glibc since 2.1.3)
448 If set to a nonempty string, warn about unresolved symbols.
449 .TP
450 .B LDD_ARGV0
451 (libc5)
452 .IR argv [0]
453 to be used by
454 .BR ldd (1)
455 when none is present.
456 .SH FILES
457 .PD 0
458 .TP
459 .I /lib/ld.so
460 a.out dynamic linker/loader
461 .TP
462 .IR /lib/ld\-linux.so. { 1 , 2 }
463 ELF dynamic linker/loader
464 .TP
465 .I /etc/ld.so.cache
466 File containing a compiled list of directories in which to search for
467 shared objects and an ordered list of candidate shared objects.
468 .TP
469 .I /etc/ld.so.preload
470 File containing a whitespace-separated list of ELF shared objects to
471 be loaded before the program.
472 .TP
473 .B lib*.so*
474 shared objects
475 .PD
476 .SH NOTES
477 The
478 .B ld.so
479 functionality is available for executables compiled using libc version
480 4.4.3 or greater.
481 ELF functionality is available since Linux 1.1.52 and libc5.
482 .SS Hardware capabilities
483 Some shared objects are compiled using hardware-specific instructions which do
484 not exist on every CPU.
485 Such objects should be installed in directories whose names define the
486 required hardware capabilities, such as
487 .IR /usr/lib/sse2/ .
488 The dynamic linker checks these directories against the hardware of the
489 machine and selects the most suitable version of a given shared object.
490 Hardware capability directories can be cascaded to combine CPU features.
491 The list of supported hardware capability names depends on the CPU.
492 The following names are currently recognized:
493 .TP
494 .B Alpha
495 ev4, ev5, ev56, ev6, ev67
496 .TP
497 .B MIPS
498 loongson2e, loongson2f, octeon, octeon2
499 .TP
500 .B PowerPC
501 4xxmac, altivec, arch_2_05, arch_2_06, booke, cellbe, dfp, efpdouble, efpsingle,
502 fpu, ic_snoop, mmu, notb, pa6t, power4, power5, power5+, power6x, ppc32, ppc601,
503 ppc64, smt, spe, ucache, vsx
504 .TP
505 .B SPARC
506 flush, muldiv, stbar, swap, ultra3, v9, v9v, v9v2
507 .TP
508 .B s390
509 dfp, eimm, esan3, etf3enh, g5, highgprs, hpage, ldisp, msa, stfle,
510 z900, z990, z9-109, z10, zarch
511 .TP
512 .B x86 (32-bit only)
513 acpi, apic, clflush, cmov, cx8, dts, fxsr, ht, i386, i486, i586, i686, mca, mmx,
514 mtrr, pat, pbe, pge, pn, pse36, sep, ss, sse, sse2, tm
515 .SH SEE ALSO
516 .BR ld (1),
517 .BR ldd (1),
518 .BR pldd (1),
519 .BR sprof (1),
520 .BR dlopen (3),
521 .BR getauxval (3),
522 .BR rtld-audit (7),
523 .BR ldconfig (8),
524 .BR sln (8)
525 .\" .SH AUTHORS
526 .\" ld.so: David Engel, Eric Youngdale, Peter MacDonald, Hongjiu Lu, Linus
527 .\" Torvalds, Lars Wirzenius and Mitch D'Souza
528 .\" ld-linux.so: Roland McGrath, Ulrich Drepper and others.
529 .\"
530 .\" In the above, (libc5) stands for David Engel's ld.so/ld-linux.so.