1LD.SO(8) Linux Programmer's Manual LD.SO(8)
2
3
4
6 ld.so, ld-linux.so* - dynamic linker/loader
7
9 The dynamic linker can be run either indirectly by running some dynami‐
10 cally 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
12 linker which is stored in the .interp section of the program is exe‐
13 cuted) or directly by running:
14
15 /lib/ld-linux.so.* [OPTIONS] [PROGRAM [ARGUMENTS]]
16
18 The programs ld.so and ld-linux.so* find and load the shared libraries
19 needed by a program, prepare the program to run, and then run it.
20
21 Linux binaries require dynamic linking (linking at run time) unless the
22 -static option was given to ld(1) during compilation.
23
24 The program ld.so handles a.out binaries, a format used long ago; ld-
25 linux.so* handles ELF (/lib/ld-linux.so.1 for libc5, /lib/ld-linux.so.2
26 for glibc2), which everybody has been using for years now. Otherwise
27 both have the same behavior, and use the same support files and pro‐
28 grams ldd(1), ldconfig(8) and /etc/ld.so.conf.
29
30 When resolving library dependencies, the dynamic linker first inspects
31 each dependency string to see if it contains a slash (this can occur if
32 a library pathname containing slashes was specified at link time). If
33 a slash is found, then the dependency string is interpreted as a (rela‐
34 tive or absolute) pathname, and the library is loaded using that path‐
35 name.
36
37 If a library dependency does not contain a slash, then it is searched
38 for in the following order:
39
40 o (ELF only) Using the directories specified in the DT_RPATH dynamic
41 section attribute of the binary if present and DT_RUNPATH attribute
42 does not exist. Use of DT_RPATH is deprecated.
43
44 o Using the environment variable LD_LIBRARY_PATH. Except if the exe‐
45 cutable is a set-user-ID/set-group-ID binary, in which case it is
46 ignored.
47
48 o (ELF only) Using the directories specified in the DT_RUNPATH dynamic
49 section attribute of the binary if present.
50
51 o From the cache file /etc/ld.so.cache, which contains a compiled list
52 of candidate libraries previously found in the augmented library
53 path. If, however, the binary was linked with the -z nodeflib
54 linker option, libraries in the default library paths are skipped.
55 Libraries installed in hardware capability directories (see below)
56 are preferred to other libraries.
57
58 o In the default path /lib, and then /usr/lib. If the binary was
59 linked with the -z nodeflib linker option, this step is skipped.
60
61 Rpath token expansion
62 ld.so understands certain strings in an rpath specification (DT_RPATH
63 or DT_RUNPATH); those strings are substituted as follows
64
65 $ORIGIN (or equivalently ${ORIGIN})
66 This expands to the directory containing the application exe‐
67 cutable. Thus, an application located in somedir/app could be
68 compiled with
69
70 gcc -Wl,-rpath,'$ORIGIN/../lib'
71
72 so that it finds an associated shared library in somedir/lib no
73 matter where somedir is located in the directory hierarchy.
74 This facilitates the creation of "turn-key" applications that do
75 not need to be installed into special directories, but can
76 instead be unpacked into any directory and still find their own
77 shared libraries.
78
79 $LIB (or equivalently ${LIB})
80 This expands to lib or lib64 depending on the architecture
81 (e.g., on x86-64, it expands to lib64 and on x86-32, it expands
82 to lib).
83
84 $PLATFORM (or equivalently ${PLATFORM})
85 This expands to a string corresponding to the processor type of
86 the host system (e.g., "x86_64"). On some architectures, the
87 Linux kernel doesn't provide a platform string to the dynamic
88 linker. The value of this string is taken from the AT_PLATFORM
89 value in the auxiliary vector (see getauxval(3)).
90
92 --list List all dependencies and how they are resolved.
93
94 --verify
95 Verify that program is dynamically linked and this dynamic
96 linker can handle it.
97
98 --library-path PATH
99 Use PATH instead of LD_LIBRARY_PATH environment variable setting
100 (see below).
101
102 --inhibit-rpath LIST
103 Ignore RPATH and RUNPATH information in object names in LIST.
104 This option is ignored if ld.so is set-user-ID or set-group-ID.
105
106 --audit LIST
107 Use objects named in LIST as auditors.
108
110 Some libraries are compiled using hardware-specific instructions which
111 do not exist on every CPU. Such libraries should be installed in
112 directories whose names define the required hardware capabilities, such
113 as /usr/lib/sse2/. The dynamic linker checks these directories against
114 the hardware of the machine and selects the most suitable version of a
115 given library. Hardware capability directories can be cascaded to com‐
116 bine CPU features. The list of supported hardware capability names
117 depends on the CPU. The following names are currently recognized:
118
119 Alpha ev4, ev5, ev56, ev6, ev67
120
121 MIPS loongson2e, loongson2f, octeon, octeon2
122
123 PowerPC
124 4xxmac, altivec, arch_2_05, arch_2_06, booke, cellbe, dfp, efp‐
125 double, efpsingle, fpu, ic_snoop, mmu, notb, pa6t, power4,
126 power5, power5+, power6x, ppc32, ppc601, ppc64, smt, spe,
127 ucache, vsx
128
129 SPARC flush, muldiv, stbar, swap, ultra3, v9, v9v, v9v2
130
131 s390 dfp, eimm, esan3, etf3enh, g5, highgprs, hpage, ldisp, msa,
132 stfle, z900, z990, z9-109, z10, zarch
133
134 x86 (32-bit only)
135 acpi, apic, clflush, cmov, cx8, dts, fxsr, ht, i386, i486, i586,
136 i686, mca, mmx, mtrr, pat, pbe, pge, pn, pse36, sep, ss, sse,
137 sse2, tm
138
140 There are four important environment variables.
141
142 LD_ASSUME_KERNEL
143 (glibc since 2.2.3) Each shared library can inform the dynamic
144 linker of the minimum kernel ABI version that it requires.
145 (This requirement is encoded in an ELF note section that is
146 viewable via readelf -n as a section labeled NT_GNU_ABI_TAG.)
147 At run time, the dynamic linker determines the ABI version of
148 the running kernel and will reject loading shared libraries that
149 specify minimum ABI versions that exceed that ABI version.
150
151 LD_ASSUME_KERNEL can be used to cause the dynamic linker to
152 assume that it is running on a system with a different kernel
153 ABI version. For example, the following command line causes the
154 dynamic linker to assume it is running on Linux 2.2.5 when load‐
155 ing the shared libraries required by myprog:
156
157 $ LD_ASSUME_KERNEL=2.2.5 ./myprog
158
159 On systems that provide multiple versions of a shared library
160 (in different directories in the search path) that have differ‐
161 ent minimum kernel ABI version requirements, LD_ASSUME_KERNEL
162 can be used to select the version of the library that is used
163 (dependent on the directory search order). Historically, the
164 most common use of the LD_ASSUME_KERNEL feature was to manually
165 select the older LinuxThreads POSIX threads implementation on
166 systems that provided both LinuxThreads and NPTL (which latter
167 was typically the default on such systems); see pthreads(7).
168
169 LD_BIND_NOT
170 (glibc since 2.2) Don't update the Global Offset Table (GOT) and
171 Procedure Linkage Table (PLT) when resolving a symbol.
172
173 LD_BIND_NOW
174 (libc5; glibc since 2.1.1) If set to a nonempty string, causes
175 the dynamic linker to resolve all symbols at program startup
176 instead of deferring function call resolution to the point when
177 they are first referenced. This is useful when using a debug‐
178 ger.
179
180 LD_LIBRARY_PATH
181 A colon-separated list of directories in which to search for ELF
182 libraries at execution-time. Similar to the PATH environment
183 variable. Ignored in set-user-ID and set-group-ID programs.
184
185 LD_PRELOAD
186 A list of additional, user-specified, ELF shared libraries to be
187 loaded before all others. The items of the list can be sepa‐
188 rated by spaces or colons. This can be used to selectively
189 override functions in other shared libraries. The libraries are
190 searched for using the rules given under DESCRIPTION. For set-
191 user-ID/set-group-ID ELF binaries, preload pathnames containing
192 slashes are ignored, and libraries in the standard search direc‐
193 tories are loaded only if the set-user-ID permission bit is
194 enabled on the library file.
195
196 LD_TRACE_LOADED_OBJECTS
197 (ELF only) If set to a nonempty string, causes the program to
198 list its dynamic library dependencies, as if run by ldd(1),
199 instead of running normally.
200
201 Then there are lots of more or less obscure variables, many obsolete or
202 only for internal use.
203
204 LD_AOUT_LIBRARY_PATH
205 (libc5) Version of LD_LIBRARY_PATH for a.out binaries only. Old
206 versions of ld-linux.so.1 also supported LD_ELF_LIBRARY_PATH.
207
208 LD_AOUT_PRELOAD
209 (libc5) Version of LD_PRELOAD for a.out binaries only. Old ver‐
210 sions of ld-linux.so.1 also supported LD_ELF_PRELOAD.
211
212 LD_AUDIT
213 (glibc since 2.4) A colon-separated list of user-specified, ELF
214 shared objects to be loaded before all others in a separate
215 linker namespace (i.e., one that does not intrude upon the nor‐
216 mal symbol bindings that would occur in the process). These
217 libraries can be used to audit the operation of the dynamic
218 linker. LD_AUDIT is ignored for set-user-ID/set-group-ID bina‐
219 ries.
220
221 The dynamic linker will notify the audit libraries at so-called
222 auditing checkpoints—for example, loading a new library, resolv‐
223 ing a symbol, or calling a symbol from another shared object—by
224 calling an appropriate function within the audit library. For
225 details, see rtld-audit(7). The auditing interface is largely
226 compatible with that provided on Solaris, as described in its
227 Linker and Libraries Guide, in the chapter Runtime Linker Audit‐
228 ing Interface.
229
230 LD_BIND_NOT
231 (glibc since 2.1.95) Do not update the GOT (global offset table)
232 and PLT (procedure linkage table) after resolving a symbol.
233
234 LD_DEBUG
235 (glibc since 2.1) Output verbose debugging information about the
236 dynamic linker. If set to all prints all debugging information
237 it has, if set to help prints a help message about which cate‐
238 gories can be specified in this environment variable. Since
239 glibc 2.3.4, LD_DEBUG is ignored for set-user-ID/set-group-ID
240 binaries.
241
242 LD_DEBUG_OUTPUT
243 (glibc since 2.1) File in which LD_DEBUG output should be writ‐
244 ten. The default is standard output. LD_DEBUG_OUTPUT is
245 ignored for set-user-ID/set-group-ID binaries.
246
247 LD_DYNAMIC_WEAK
248 (glibc since 2.1.91) Allow weak symbols to be overridden
249 (reverting to old glibc behavior). For security reasons, since
250 glibc 2.3.4, LD_DYNAMIC_WEAK is ignored for set-user-ID/set-
251 group-ID binaries.
252
253 LD_HWCAP_MASK
254 (glibc since 2.1) Mask for hardware capabilities.
255
256 LD_KEEPDIR
257 (a.out only)(libc5) Don't ignore the directory in the names of
258 a.out libraries to be loaded. Use of this option is strongly
259 discouraged.
260
261 LD_NOWARN
262 (a.out only)(libc5) Suppress warnings about a.out libraries with
263 incompatible minor version numbers.
264
265 LD_ORIGIN_PATH
266 (glibc since 2.1) Path where the binary is found (for non-set-
267 user-ID programs). For security reasons, since glibc 2.4,
268 LD_ORIGIN_PATH is ignored for set-user-ID/set-group-ID binaries.
269
270 LD_POINTER_GUARD
271 (glibc since 2.4) Set to 0 to disable pointer guarding. Any
272 other value enables pointer guarding, which is also the default.
273 Pointer guarding is a security mechanism whereby some pointers
274 to code stored in writable program memory (return addresses
275 saved by setjmp(3) or function pointers used by various glibc
276 internals) are mangled semi-randomly to make it more difficult
277 for an attacker to hijack the pointers for use in the event of a
278 buffer overrun or stack-smashing attack.
279
280 LD_PROFILE
281 (glibc since 2.1) Shared object to be profiled, specified either
282 as a pathname or a soname. Profiling output is written to the
283 file whose name is: "$LD_PROFILE_OUTPUT/$LD_PROFILE.profile".
284
285 LD_PROFILE_OUTPUT
286 (glibc since 2.1) Directory where LD_PROFILE output should be
287 written. If this variable is not defined, or is defined as an
288 empty string, then the default is /var/tmp. LD_PROFILE_OUTPUT
289 is ignored for set-user-ID and set-group-ID programs, which
290 always use /var/profile.
291
292 LD_SHOW_AUXV
293 (glibc since 2.1) Show auxiliary array passed up from the ker‐
294 nel. For security reasons, since glibc 2.3.5, LD_SHOW_AUXV is
295 ignored for set-user-ID/set-group-ID binaries.
296
297 LD_USE_LOAD_BIAS
298 By default (i.e., if this variable is not defined) executables
299 and prelinked shared objects will honor base addresses of their
300 dependent libraries and (nonprelinked) position-independent exe‐
301 cutables (PIEs) and other shared objects will not honor them.
302 If LD_USE_LOAD_BIAS is defined wit the value, both executables
303 and PIEs will honor the base addresses. If LD_USE_LOAD_BIAS is
304 defined with the value 0, neither executables nor PIEs will
305 honor the base addresses. This variable is ignored by set-user-
306 ID and set-group-ID programs.
307
308 LD_VERBOSE
309 (glibc since 2.1) If set to a nonempty string, output symbol
310 versioning information about the program if the
311 LD_TRACE_LOADED_OBJECTS environment variable has been set.
312
313 LD_WARN
314 (ELF only)(glibc since 2.1.3) If set to a nonempty string, warn
315 about unresolved symbols.
316
317 LDD_ARGV0
318 (libc5) argv[0] to be used by ldd(1) when none is present.
319
321 /lib/ld.so
322 a.out dynamic linker/loader
323 /lib/ld-linux.so.{1,2}
324 ELF dynamic linker/loader
325 /etc/ld.so.cache
326 File containing a compiled list of directories in which to
327 search for libraries and an ordered list of candidate libraries.
328 /etc/ld.so.preload
329 File containing a whitespace-separated list of ELF shared
330 libraries to be loaded before the program.
331 lib*.so*
332 shared libraries
333
335 The ld.so functionality is available for executables compiled using
336 libc version 4.4.3 or greater. ELF functionality is available since
337 Linux 1.1.52 and libc5.
338
340 ldd(1), sln(1), getauxval(3), rtld-audit(7), ldconfig(8)
341
343 This page is part of release 3.53 of the Linux man-pages project. A
344 description of the project, and information about reporting bugs, can
345 be found at http://www.kernel.org/doc/man-pages/.
346
347
348
349GNU 2013-07-15 LD.SO(8)