OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / 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 2014-01-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 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
13 .B .interp
14 section of the program is executed) or directly by running:
15 .P
16 .I /lib/ld-linux.so.*
17 [OPTIONS] [PROGRAM [ARGUMENTS]]
18 .SH DESCRIPTION
19 The programs
20 .B ld.so
21 and
22 .B ld-linux.so*
23 find and load the shared libraries needed by a program, prepare
24 the program to run, and then run it.
25 .LP
26 Linux binaries require dynamic linking (linking at run time)
27 unless the
28 .B \-static
29 option was given to
30 .BR ld (1)
31 during compilation.
32 .LP
33 The program
34 .B ld.so
35 handles a.out binaries, a format used long ago;
36 .B ld-linux.so*
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
41 .BR ldd (1),
42 .BR ldconfig (8)
43 and
44 .IR /etc/ld.so.conf .
45 .LP
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.
53 .LP
54 If a library dependency does not contain a slash,
55 then it is searched for in the following order:
56 .IP o 3
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.
61 .IP o
62 Using the environment variable
63 .BR LD_LIBRARY_PATH .
64 Except if the executable is a set-user-ID/set-group-ID binary,
65 in which case it is ignored.
66 .IP o
67 (ELF only) Using the directories specified in the
68 DT_RUNPATH dynamic section attribute
69 of the binary if present.
70 .IP o
71 From the cache file
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
76 .B \-z nodeflib
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.
80 .IP o
81 In the default path
82 .IR /lib ,
83 and then
84 .IR /usr/lib .
85 If the binary was linked with the
86 .B \-z nodeflib
87 linker option, this step is skipped.
88 .SS Rpath token expansion
89 .PP
90 .B ld.so
91 understands certain strings in an rpath specification (DT_RPATH or DT_RUNPATH); those strings are substituted as follows
92 .TP
93 .IR $ORIGIN " (or equivalently " ${ORIGIN} )
94 This expands to
95 the directory containing the application executable.
96 Thus, an application located in
97 .I somedir/app
98 could be compiled with
99
100     gcc \-Wl,\-rpath,\(aq$ORIGIN/../lib\(aq
101
102 so that it finds an associated shared library in
103 .I somedir/lib
104 no matter where
105 .I somedir
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.
111 .TP
112 .IR $LIB " (or equivalently " ${LIB} )
113 This expands to
114 .I lib
115 or
116 .I lib64
117 depending on the architecture
118 (e.g., on x86-64, it expands to
119 .IR lib64
120 and
121 on x86-32, it expands to
122 .IR lib ).
123 .TP
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
130 .BR AT_PLATFORM
131 value in the auxiliary vector (see
132 .BR getauxval (3)).
133 .\" To get an idea of the places that $PLATFORM would match,
134 .\" look at the output of the following:
135 .\"
136 .\"     mkdir /tmp/d
137 .\"     LD_LIBRARY_PATH=/tmp/d strace -e open /bin/date 2>&1 | grep /tmp/d
138 .\"
139 .\" ld.so lets names be abbreviated, so $O will work for $ORIGIN;
140 .\" Don't do this!!
141 .SH OPTIONS
142 .TP
143 .B \-\-list
144 List all dependencies and how they are resolved.
145 .TP
146 .B \-\-verify
147 Verify that program is dynamically linked and this dynamic linker can handle
148 it.
149 .TP
150 .B \-\-library\-path PATH
151 Use PATH instead of
152 .B LD_LIBRARY_PATH
153 environment variable setting (see below).
154 .TP
155 .B \-\-inhibit\-rpath LIST
156 Ignore RPATH and RUNPATH information in object names in LIST.
157 This option is ignored if
158 .B ld.so
159 is set-user-ID or set-group-ID.
160 .TP
161 .B \-\-audit LIST
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
168 .IR /usr/lib/sse2/ .
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:
174 .TP
175 .B Alpha
176 ev4, ev5, ev56, ev6, ev67
177 .TP
178 .B MIPS
179 loongson2e, loongson2f, octeon, octeon2
180 .TP
181 .B PowerPC
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
185 .TP
186 .B SPARC
187 flush, muldiv, stbar, swap, ultra3, v9, v9v, v9v2
188 .TP
189 .B s390
190 dfp, eimm, esan3, etf3enh, g5, highgprs, hpage, ldisp, msa, stfle,
191 z900, z990, z9-109, z10, zarch
192 .TP
193 .B x86 (32-bit only)
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
196 .SH ENVIRONMENT
197 Among the more important environment variables are the following:
198 .TP
199 .B LD_ASSUME_KERNEL
200 (glibc since 2.2.3)
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
204 .IR "readelf\ \-n"
205 as a section labeled
206 .BR NT_GNU_ABI_TAG .)
207 At run time,
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.
211
212 .BR LD_ASSUME_KERNEL
213 can be used to
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
219 .IR myprog :
220
221 .in +4n
222 .nf
223 $ \fBLD_ASSUME_KERNEL=2.2.5 ./myprog\fP
224 .fi
225 .in
226
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,
230 .BR LD_ASSUME_KERNEL
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
234 .BR LD_ASSUME_KERNEL
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);
239 see
240 .BR pthreads (7).
241 .TP
242 .B LD_BIND_NOT
243 (glibc since 2.2)
244 Don't update the Global Offset Table (GOT) and Procedure Linkage Table (PLT)
245 when resolving a symbol.
246 .TP
247 .B LD_BIND_NOW
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.
254 .TP
255 .B LD_LIBRARY_PATH
256 A colon-separated list of directories in which to search for
257 ELF libraries at execution-time.
258 Similar to the
259 .B PATH
260 environment variable.
261 Ignored in set-user-ID and set-group-ID programs.
262 .TP
263 .B LD_PRELOAD
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.
273 .TP
274 .B LD_TRACE_LOADED_OBJECTS
275 (ELF only)
276 If set to a nonempty string, causes the program to list its dynamic library
277 dependencies, as if run by
278 .BR ldd (1),
279 instead of running normally.
280 .LP
281 Then there are lots of more or less obscure variables,
282 many obsolete or only for internal use.
283 .TP
284 .B LD_AOUT_LIBRARY_PATH
285 (libc5)
286 Version of
287 .B LD_LIBRARY_PATH
288 for a.out binaries only.
289 Old versions of ld\-linux.so.1 also supported
290 .BR LD_ELF_LIBRARY_PATH .
291 .TP
292 .B LD_AOUT_PRELOAD
293 (libc5)
294 Version of
295 .B LD_PRELOAD
296 for a.out binaries only.
297 Old versions of ld\-linux.so.1 also supported
298 .BR LD_ELF_PRELOAD .
299 .TP
300 .B LD_AUDIT
301 (glibc since 2.4)
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.
307 .B LD_AUDIT
308 is ignored for set-user-ID/set-group-ID binaries.
309
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.
315 For details, see
316 .BR rtld-audit (7).
317 The auditing interface is largely compatible with that provided on Solaris,
318 as described in its
319 .IR "Linker and Libraries Guide" ,
320 in the chapter
321 .IR "Runtime Linker Auditing Interface" .
322 .TP
323 .B LD_BIND_NOT
324 (glibc since 2.1.95)
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 for set-user-ID/set-group-ID binaries.
340 .TP
341 .B LD_DEBUG_OUTPUT
342 (glibc since 2.1)
343 File in which
344 .B LD_DEBUG
345 output should be written.
346 The default is standard error.
347 .B LD_DEBUG_OUTPUT
348 is ignored for set-user-ID/set-group-ID binaries.
349 .TP
350 .B LD_DYNAMIC_WEAK
351 (glibc since 2.1.91)
352 Allow weak symbols to be overridden (reverting to old glibc behavior).
353 For security reasons, since glibc 2.3.4,
354 .B LD_DYNAMIC_WEAK
355 is ignored for set-user-ID/set-group-ID binaries.
356 .TP
357 .B LD_HWCAP_MASK
358 (glibc since 2.1)
359 Mask for hardware capabilities.
360 .TP
361 .B LD_KEEPDIR
362 (a.out only)(libc5)
363 Don't ignore the directory in the names of a.out libraries to be loaded.
364 Use of this option is strongly discouraged.
365 .TP
366 .B LD_NOWARN
367 (a.out only)(libc5)
368 Suppress warnings about a.out libraries with incompatible minor
369 version numbers.
370 .TP
371 .B LD_ORIGIN_PATH
372 (glibc since 2.1)
373 Path where the binary is found (for non-set-user-ID programs).
374 For security reasons, since glibc 2.4,
375 .B LD_ORIGIN_PATH
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)?
379 .TP
380 .B LD_POINTER_GUARD
381 (glibc since 2.4)
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
386 .BR setjmp (3)
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.
391 .TP
392 .B LD_PROFILE
393 (glibc since 2.1)
394 Shared object to be profiled,
395 specified either as a pathname or a soname.
396 Profiling output is written to the file whose name is:
397 "\fI$LD_PROFILE_OUTPUT\fP/\fI$LD_PROFILE\fP.profile".
398 .TP
399 .B LD_PROFILE_OUTPUT
400 (glibc since 2.1)
401 Directory where
402 .B LD_PROFILE
403 output should be written.
404 If this variable is not defined, or is defined as an empty string,
405 then the default is
406 .IR /var/tmp .
407 .B LD_PROFILE_OUTPUT
408 is ignored for set-user-ID and set-group-ID programs,
409 which always use
410 .IR /var/profile .
411 .TP
412 .B LD_SHOW_AUXV
413 (glibc since 2.1)
414 Show auxiliary array passed up from the kernel.
415 For security reasons, since glibc 2.3.5,
416 .B LD_SHOW_AUXV
417 is ignored for set-user-ID/set-group-ID binaries.
418 .\" FIXME
419 .\" Document LD_TRACE_PRELINKING (e.g.: LD_TRACE_PRELINKING=libx1.so ./prog)
420 .\" Since glibc 2.3
421 .\" Also enables DL_DEBUG_PRELINK
422 .TP
423 .B LD_USE_LOAD_BIAS
424 .\" http://sources.redhat.com/ml/libc-hacker/2003-11/msg00127.html
425 .\" Subject: [PATCH] Support LD_USE_LOAD_BIAS
426 .\" Jakub Jelinek
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.
432 If
433 .B LD_USE_LOAD_BIAS
434 is defined wit the value, both executables and PIEs
435 will honor the base addresses.
436 If
437 .B LD_USE_LOAD_BIAS
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.
441 .TP
442 .B LD_VERBOSE
443 (glibc since 2.1)
444 If set to a nonempty string,
445 output symbol versioning information about the
446 program if the
447 .B LD_TRACE_LOADED_OBJECTS
448 environment variable has been set.
449 .TP
450 .B LD_WARN
451 (ELF only)(glibc since 2.1.3)
452 If set to a nonempty string, warn about unresolved symbols.
453 .TP
454 .B LDD_ARGV0
455 (libc5)
456 .IR argv [0]
457 to be used by
458 .BR ldd (1)
459 when none is present.
460 .SH FILES
461 .PD 0
462 .TP
463 .I /lib/ld.so
464 a.out dynamic linker/loader
465 .TP
466 .IR /lib/ld\-linux.so. { 1 , 2 }
467 ELF dynamic linker/loader
468 .TP
469 .I /etc/ld.so.cache
470 File containing a compiled list of directories in which to search for
471 libraries and an ordered list of candidate libraries.
472 .TP
473 .I /etc/ld.so.preload
474 File containing a whitespace-separated list of ELF shared libraries to
475 be loaded before the program.
476 .TP
477 .B lib*.so*
478 shared libraries
479 .PD
480 .SH NOTES
481 The
482 .B ld.so
483 functionality is available for executables compiled using libc version
484 4.4.3 or greater.
485 ELF functionality is available since Linux 1.1.52 and libc5.
486 .SH SEE ALSO
487 .BR ldd (1),
488 .BR getauxval (3),
489 .BR rtld-audit (7),
490 .BR ldconfig (8),
491 .BR sln (8)
492 .\" .SH AUTHORS
493 .\" ld.so: David Engel, Eric Youngdale, Peter MacDonald, Hongjiu Lu, Linus
494 .\"  Torvalds, Lars Wirzenius and Mitch D'Souza
495 .\" ld-linux.so: Roland McGrath, Ulrich Drepper and others.
496 .\"
497 .\" In the above, (libc5) stands for David Engel's ld.so/ld-linux.so.
498 .SH COLOPHON
499 This page is part of release 3.68 of the Linux
500 .I man-pages
501 project.
502 A description of the project,
503 information about reporting bugs,
504 and the latest version of this page,
505 can be found at
506 \%http://www.kernel.org/doc/man\-pages/.