summaryrefslogtreecommitdiff
path: root/man8/ld.so.8
blob: 4062727fc98fff3854f6e6ec72cd7eb3b9d95e90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
.\" %%%LICENSE_START(PUBLIC_DOMAIN)
.\" This is in the public domain
.\" %%%LICENSE_END
.\"
.TH LD.SO 8 2014-01-08 "GNU" "Linux Programmer's Manual"
.SH NAME
ld.so, ld-linux.so* \- dynamic linker/loader
.SH SYNOPSIS
The dynamic linker can be run either indirectly by running some
dynamically linked program or library (in which case no command-line options
to the dynamic linker can be passed and, in the ELF case, the dynamic linker
which is stored in the
.B .interp
section of the program is executed) or directly by running:
.P
.I /lib/ld-linux.so.*
[OPTIONS] [PROGRAM [ARGUMENTS]]
.SH DESCRIPTION
The programs
.B ld.so
and
.B ld-linux.so*
find and load the shared libraries needed by a program, prepare
the program to run, and then run it.
.LP
Linux binaries require dynamic linking (linking at run time)
unless the
.B \-static
option was given to
.BR ld (1)
during compilation.
.LP
The program
.B ld.so
handles a.out binaries, a format used long ago;
.B ld-linux.so*
handles ELF (\fI/lib/ld-linux.so.1\fP for libc5, \fI/lib/ld-linux.so.2\fP
for glibc2), which everybody has been using for years now.
Otherwise, both have the same behavior, and use the same
support files and programs
.BR ldd (1),
.BR ldconfig (8)
and
.IR /etc/ld.so.conf .
.LP
When resolving library dependencies,
the dynamic linker first inspects each dependency
string to see if it contains a slash (this can occur if
a library pathname containing slashes was specified at link time).
If a slash is found, then the dependency string is interpreted as
a (relative or absolute) pathname,
and the library is loaded using that pathname.
.LP
If a library dependency does not contain a slash,
then it is searched for in the following order:
.IP o 3
(ELF only) Using the directories specified in the
DT_RPATH dynamic section attribute
of the binary if present and DT_RUNPATH attribute does not exist.
Use of DT_RPATH is deprecated.
.IP o
Using the environment variable
.BR LD_LIBRARY_PATH .
Except if the executable is a set-user-ID/set-group-ID binary,
in which case it is ignored.
.IP o
(ELF only) Using the directories specified in the
DT_RUNPATH dynamic section attribute
of the binary if present.
.IP o
From the cache file
.IR /etc/ld.so.cache ,
which contains a compiled list of candidate libraries previously found
in the augmented library path.
If, however, the binary was linked with the
.B \-z nodeflib
linker option, libraries in the default library paths are skipped.
Libraries installed in hardware capability directories (see below)
are preferred to other libraries.
.IP o
In the default path
.IR /lib ,
and then
.IR /usr/lib .
If the binary was linked with the
.B \-z nodeflib
linker option, this step is skipped.
.SS Rpath token expansion
.PP
.B ld.so
understands certain strings in an rpath specification (DT_RPATH or DT_RUNPATH); those strings are substituted as follows
.TP
.IR $ORIGIN " (or equivalently " ${ORIGIN} )
This expands to
the directory containing the application executable.
Thus, an application located in
.I somedir/app
could be compiled with

    gcc \-Wl,\-rpath,\(aq$ORIGIN/../lib\(aq

so that it finds an associated shared library in
.I somedir/lib
no matter where
.I somedir
is located in the directory hierarchy.
This facilitates the creation of "turn-key" applications that
do not need to be installed into special directories,
but can instead be unpacked into any directory
and still find their own shared libraries.
.TP
.IR $LIB " (or equivalently " ${LIB} )
This expands to
.I lib
or
.I lib64
depending on the architecture
(e.g., on x86-64, it expands to
.IR lib64
and
on x86-32, it expands to
.IR lib ).
.TP
.IR $PLATFORM " (or equivalently " ${PLATFORM} )
This expands to a string corresponding to the processor type
of the host system (e.g., "x86_64").
On some architectures, the Linux kernel doesn't provide a platform
string to the dynamic linker.
The value of this string is taken from the
.BR AT_PLATFORM
value in the auxiliary vector (see
.BR getauxval (3)).
.\" To get an idea of the places that $PLATFORM would match,
.\" look at the output of the following:
.\"
.\"     mkdir /tmp/d
.\"     LD_LIBRARY_PATH=/tmp/d strace -e open /bin/date 2>&1 | grep /tmp/d
.\"
.\" ld.so lets names be abbreviated, so $O will work for $ORIGIN;
.\" Don't do this!!
.SH OPTIONS
.TP
.B \-\-list
List all dependencies and how they are resolved.
.TP
.B \-\-verify
Verify that program is dynamically linked and this dynamic linker can handle
it.
.TP
.B \-\-library\-path PATH
Use PATH instead of
.B LD_LIBRARY_PATH
environment variable setting (see below).
.TP
.B \-\-inhibit\-rpath LIST
Ignore RPATH and RUNPATH information in object names in LIST.
This option is ignored if
.B ld.so
is set-user-ID or set-group-ID.
.TP
.B \-\-audit LIST
Use objects named in LIST as auditors.
.SH HARDWARE CAPABILITIES
Some libraries are compiled using hardware-specific instructions which do
not exist on every CPU.
Such libraries should be installed in directories whose names define the
required hardware capabilities, such as
.IR /usr/lib/sse2/ .
The dynamic linker checks these directories against the hardware of the
machine and selects the most suitable version of a given library.
Hardware capability directories can be cascaded to combine CPU features.
The list of supported hardware capability names depends on the CPU.
The following names are currently recognized:
.TP
.B Alpha
ev4, ev5, ev56, ev6, ev67
.TP
.B MIPS
loongson2e, loongson2f, octeon, octeon2
.TP
.B PowerPC
4xxmac, altivec, arch_2_05, arch_2_06, booke, cellbe, dfp, efpdouble, efpsingle,
fpu, ic_snoop, mmu, notb, pa6t, power4, power5, power5+, power6x, ppc32, ppc601,
ppc64, smt, spe, ucache, vsx
.TP
.B SPARC
flush, muldiv, stbar, swap, ultra3, v9, v9v, v9v2
.TP
.B s390
dfp, eimm, esan3, etf3enh, g5, highgprs, hpage, ldisp, msa, stfle,
z900, z990, z9-109, z10, zarch
.TP
.B x86 (32-bit only)
acpi, apic, clflush, cmov, cx8, dts, fxsr, ht, i386, i486, i586, i686, mca, mmx,
mtrr, pat, pbe, pge, pn, pse36, sep, ss, sse, sse2, tm
.SH ENVIRONMENT
Among the more important environment variables are the following:
.TP
.B LD_ASSUME_KERNEL
(glibc since 2.2.3)
Each shared library can inform the dynamic linker of the minimum kernel ABI
version that it requires.
(This requirement is encoded in an ELF note section that is viewable via
.IR "readelf\ \-n"
as a section labeled
.BR NT_GNU_ABI_TAG .)
At run time,
the dynamic linker determines the ABI version of the running kernel and
will reject loading shared libraries that specify minimum ABI versions
that exceed that ABI version.

.BR LD_ASSUME_KERNEL
can be used to
cause the dynamic linker to assume that it is running on a system with
a different kernel ABI version.
For example, the following command line causes the
dynamic linker to assume it is running on Linux 2.2.5 when loading
the shared libraries required by
.IR myprog :

.in +4n
.nf
$ \fBLD_ASSUME_KERNEL=2.2.5 ./myprog\fP
.fi
.in

On systems that provide multiple versions of a shared library
(in different directories in the search path) that have
different minimum kernel ABI version requirements,
.BR LD_ASSUME_KERNEL
can be used to select the version of the library that is used
(dependent on the directory search order).
Historically, the most common use of the
.BR LD_ASSUME_KERNEL
feature was to manually select the older
LinuxThreads POSIX threads implementation on systems that provided both
LinuxThreads and NPTL
(which latter was typically the default on such systems);
see
.BR pthreads (7).
.TP
.B LD_BIND_NOT
(glibc since 2.2)
Don't update the Global Offset Table (GOT) and Procedure Linkage Table (PLT)
when resolving a symbol.
.TP
.B LD_BIND_NOW
(libc5; glibc since 2.1.1)
If set to a nonempty string,
causes the dynamic linker to resolve all symbols
at program startup instead of deferring function call resolution to the point
when they are first referenced.
This is useful when using a debugger.
.TP
.B LD_LIBRARY_PATH
A colon-separated list of directories in which to search for
ELF libraries at execution-time.
Similar to the
.B PATH
environment variable.
Ignored in set-user-ID and set-group-ID programs.
.TP
.B LD_PRELOAD
A list of additional, user-specified, ELF shared
libraries to be loaded before all others.
The items of the list can be separated by spaces or colons.
This can be used to selectively override functions in other shared libraries.
The libraries are searched for using the rules given under DESCRIPTION.
For set-user-ID/set-group-ID ELF binaries,
preload pathnames containing slashes are ignored,
and libraries in the standard search directories are loaded
only if the set-user-ID permission bit is enabled on the library file.
.TP
.B LD_TRACE_LOADED_OBJECTS
(ELF only)
If set to a nonempty string, causes the program to list its dynamic library
dependencies, as if run by
.BR ldd (1),
instead of running normally.
.LP
Then there are lots of more or less obscure variables,
many obsolete or only for internal use.
.TP
.B LD_AOUT_LIBRARY_PATH
(libc5)
Version of
.B LD_LIBRARY_PATH
for a.out binaries only.
Old versions of ld\-linux.so.1 also supported
.BR LD_ELF_LIBRARY_PATH .
.TP
.B LD_AOUT_PRELOAD
(libc5)
Version of
.B LD_PRELOAD
for a.out binaries only.
Old versions of ld\-linux.so.1 also supported
.BR LD_ELF_PRELOAD .
.TP
.B LD_AUDIT
(glibc since 2.4)
A colon-separated list of user-specified, ELF shared objects
to be loaded before all others in a separate linker namespace
(i.e., one that does not intrude upon the normal symbol bindings that
would occur in the process).
These libraries can be used to audit the operation of the dynamic linker.
.B LD_AUDIT
is ignored for set-user-ID/set-group-ID binaries.

The dynamic linker will notify the audit
libraries at so-called auditing checkpoints\(emfor example,
loading a new library, resolving a symbol,
or calling a symbol from another shared object\(emby
calling an appropriate function within the audit library.
For details, see
.BR rtld-audit (7).
The auditing interface is largely compatible with that provided on Solaris,
as described in its
.IR "Linker and Libraries Guide" ,
in the chapter
.IR "Runtime Linker Auditing Interface" .
.TP
.B LD_BIND_NOT
(glibc since 2.1.95)
Do not update the GOT (global offset table) and PLT (procedure linkage table)
after resolving a symbol.
.TP
.B LD_DEBUG
(glibc since 2.1)
Output verbose debugging information about the dynamic linker.
If set to
.B all
prints all debugging information it has, if set to
.B help
prints a help message about which categories can be specified in this
environment variable.
Since glibc 2.3.4,
.B LD_DEBUG
is ignored for set-user-ID/set-group-ID binaries.
.TP
.B LD_DEBUG_OUTPUT
(glibc since 2.1)
File in which
.B LD_DEBUG
output should be written.
The default is standard error.
.B LD_DEBUG_OUTPUT
is ignored for set-user-ID/set-group-ID binaries.
.TP
.B LD_DYNAMIC_WEAK
(glibc since 2.1.91)
Allow weak symbols to be overridden (reverting to old glibc behavior).
For security reasons, since glibc 2.3.4,
.B LD_DYNAMIC_WEAK
is ignored for set-user-ID/set-group-ID binaries.
.TP
.B LD_HWCAP_MASK
(glibc since 2.1)
Mask for hardware capabilities.
.TP
.B LD_KEEPDIR
(a.out only)(libc5)
Don't ignore the directory in the names of a.out libraries to be loaded.
Use of this option is strongly discouraged.
.TP
.B LD_NOWARN
(a.out only)(libc5)
Suppress warnings about a.out libraries with incompatible minor
version numbers.
.TP
.B LD_ORIGIN_PATH
(glibc since 2.1)
Path where the binary is found (for non-set-user-ID programs).
For security reasons, since glibc 2.4,
.B LD_ORIGIN_PATH
is ignored for set-user-ID/set-group-ID binaries.
.\" Only used if $ORIGIN can't be determined by normal means
.\" (from the origin path saved at load time, or from /proc/self/exe)?
.TP
.B LD_POINTER_GUARD
(glibc since 2.4)
Set to 0 to disable pointer guarding.
Any other value enables pointer guarding, which is also the default.
Pointer guarding is a security mechanism whereby some pointers to code
stored in writable program memory (return addresses saved by
.BR setjmp (3)
or function pointers used by various glibc internals) are mangled
semi-randomly to make it more difficult for an attacker to hijack
the pointers for use in the event of a buffer overrun or
stack-smashing attack.
.TP
.B LD_PROFILE
(glibc since 2.1)
The name of a (single) shared object to be profiled,
specified either as a pathname or a soname.
Profiling output is appended to the file whose name is:
"\fI$LD_PROFILE_OUTPUT\fP/\fI$LD_PROFILE\fP.profile".
.TP
.B LD_PROFILE_OUTPUT
(glibc since 2.1)
Directory where
.B LD_PROFILE
output should be written.
If this variable is not defined, or is defined as an empty string,
then the default is
.IR /var/tmp .
.B LD_PROFILE_OUTPUT
is ignored for set-user-ID and set-group-ID programs,
which always use
.IR /var/profile .
.TP
.B LD_SHOW_AUXV
(glibc since 2.1)
Show auxiliary array passed up from the kernel.
For security reasons, since glibc 2.3.5,
.B LD_SHOW_AUXV
is ignored for set-user-ID/set-group-ID binaries.
.\" FIXME
.\" Document LD_TRACE_PRELINKING (e.g.: LD_TRACE_PRELINKING=libx1.so ./prog)
.\" Since glibc 2.3
.\" Also enables DL_DEBUG_PRELINK
.TP
.B LD_USE_LOAD_BIAS
.\" http://sources.redhat.com/ml/libc-hacker/2003-11/msg00127.html
.\" Subject: [PATCH] Support LD_USE_LOAD_BIAS
.\" Jakub Jelinek
By default (i.e., if this variable is not defined)
executables and prelinked
shared objects will honor base addresses of their dependent libraries
and (nonprelinked) position-independent executables (PIEs)
and other shared objects will not honor them.
If
.B LD_USE_LOAD_BIAS
is defined wit the value, both executables and PIEs
will honor the base addresses.
If
.B LD_USE_LOAD_BIAS
is defined with the value 0,
neither executables nor PIEs will honor the base addresses.
This variable is ignored by set-user-ID and set-group-ID programs.
.TP
.B LD_VERBOSE
(glibc since 2.1)
If set to a nonempty string,
output symbol versioning information about the
program if the
.B LD_TRACE_LOADED_OBJECTS
environment variable has been set.
.TP
.B LD_WARN
(ELF only)(glibc since 2.1.3)
If set to a nonempty string, warn about unresolved symbols.
.TP
.B LDD_ARGV0
(libc5)
.IR argv [0]
to be used by
.BR ldd (1)
when none is present.
.SH FILES
.PD 0
.TP
.I /lib/ld.so
a.out dynamic linker/loader
.TP
.IR /lib/ld\-linux.so. { 1 , 2 }
ELF dynamic linker/loader
.TP
.I /etc/ld.so.cache
File containing a compiled list of directories in which to search for
libraries and an ordered list of candidate libraries.
.TP
.I /etc/ld.so.preload
File containing a whitespace-separated list of ELF shared libraries to
be loaded before the program.
.TP
.B lib*.so*
shared libraries
.PD
.SH NOTES
The
.B ld.so
functionality is available for executables compiled using libc version
4.4.3 or greater.
ELF functionality is available since Linux 1.1.52 and libc5.
.SH SEE ALSO
.BR ldd (1),
.BR getauxval (3),
.BR rtld-audit (7),
.BR ldconfig (8),
.BR sln (8)
.\" .SH AUTHORS
.\" ld.so: David Engel, Eric Youngdale, Peter MacDonald, Hongjiu Lu, Linus
.\"  Torvalds, Lars Wirzenius and Mitch D'Souza
.\" ld-linux.so: Roland McGrath, Ulrich Drepper and others.
.\"
.\" In the above, (libc5) stands for David Engel's ld.so/ld-linux.so.