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 The shared libraries needed by the program are searched for in the fol‐
31 lowing order:
32
33 o (ELF only) Using the directories specified in the DT_RPATH dynamic
34 section attribute of the binary if present and DT_RUNPATH attribute
35 does not exist. Use of DT_RPATH is deprecated.
36
37 o Using the environment variable LD_LIBRARY_PATH. Except if the exe‐
38 cutable is a set-user-ID/set-group-ID binary, in which case it is
39 ignored.
40
41 o (ELF only) Using the directories specified in the DT_RUNPATH dynamic
42 section attribute of the binary if present.
43
44 o From the cache file /etc/ld.so.cache which contains a compiled list
45 of candidate libraries previously found in the augmented library
46 path. If, however, the binary was linked with the -z nodeflib
47 linker option, libraries in the default library paths are skipped.
48
49 o In the default path /lib, and then /usr/lib. If the binary was
50 linked with the -z nodeflib linker option, this step is skipped.
51
52 $ORIGIN and rpath
53 ld.so understands the string $ORIGIN (or equivalently ${ORIGIN}) in an
54 rpath specification (DT_RPATH or DT_RUNPATH) to mean the directory con‐
55 taining the application executable. Thus, an application located in
56 somedir/app could be compiled with gcc -Wl,-rpath,'$ORIGIN/../lib' so
57 that it finds an associated shared library in somedir/lib no matter
58 where somedir is located in the directory hierarchy. This facilitates
59 the creation of "turn-key" applications that do not need to be
60 installed into special directories, but can instead be unpacked into
61 any directory and still find their own shared libraries.
62
64 --list List all dependencies and how they are resolved.
65
66 --verify
67 Verify that program is dynamically linked and this dynamic
68 linker can handle it.
69
70 --library-path PATH
71 Override LD_LIBRARY_PATH environment variable setting (see
72 below).
73
74 --inhibit-rpath LIST
75 Ignore RPATH and RUNPATH information in object names in LIST.
76 This option is ignored if ld.so is set-user-ID or set-group-ID.
77
79 There are four important environment variables.
80
81 LD_BIND_NOW
82 (libc5; glibc since 2.1.1) If set to a non-empty string, causes
83 the dynamic linker to resolve all symbols at program startup
84 instead of deferring function call resolution to the point when
85 they are first referenced. This is useful when using a debug‐
86 ger.
87
88 LD_LIBRARY_PATH
89 A colon-separated list of directories in which to search for ELF
90 libraries at execution-time. Similar to the PATH environment
91 variable.
92
93 LD_PRELOAD
94 A whitespace-separated list of additional, user-specified, ELF
95 shared libraries to be loaded before all others. This can be
96 used to selectively override functions in other shared
97 libraries. For set-user-ID/set-group-ID ELF binaries, only
98 libraries in the standard search directories that are also set-
99 user-ID will be loaded.
100
101 LD_TRACE_LOADED_OBJECTS
102 (ELF only) If set to a non-empty string, causes the program to
103 list its dynamic library dependencies, as if run by ldd(1),
104 instead of running normally.
105
106 Then there are lots of more or less obscure variables, many obsolete or
107 only for internal use.
108
109 LD_AOUT_LIBRARY_PATH
110 (libc5) Version of LD_LIBRARY_PATH for a.out binaries only. Old
111 versions of ld-linux.so.1 also supported LD_ELF_LIBRARY_PATH.
112
113 LD_AOUT_PRELOAD
114 (libc5) Version of LD_PRELOAD for a.out binaries only. Old ver‐
115 sions of ld-linux.so.1 also supported LD_ELF_PRELOAD.
116
117 LD_AUDIT
118 (glibc since 2.4) A colon-separated list of user-specified, ELF
119 shared objects to be loaded before all others in a separate
120 linker namespace (i.e., one that does not intrude upon the nor‐
121 mal symbol bindings that would occur in the process). These
122 libraries can be used to audit the operation of the dynamic
123 linker. LD_AUDIT is ignored for set-user-ID/set-group-ID bina‐
124 ries.
125
126 The dynamic linker will notify the audit libraries at so-called
127 auditing checkpoints—for example, loading a new library, resolv‐
128 ing a symbol, or calling a symbol from another shared object—by
129 calling an appropriate function within the audit library. For
130 details, see rtld-audit(7). The auditing interface is largely
131 compatible with that provided on Solaris, as described in its
132 Linker and Libraries Guide, in the chapter Runtime Linker Audit‐
133 ing Interface.
134
135 LD_BIND_NOT
136 (glibc since 2.1.95) Do not update the GOT (global offset table)
137 and PLT (procedure linkage table) after resolving a symbol.
138
139 LD_DEBUG
140 (glibc since 2.1) Output verbose debugging information about the
141 dynamic linker. If set to all prints all debugging information
142 it has, if set to help prints a help message about which cate‐
143 gories can be specified in this environment variable. Since
144 glibc 2.3.4, LD_DEBUG is ignored for set-user-ID/set-group-ID
145 binaries.
146
147 LD_DEBUG_OUTPUT
148 (glibc since 2.1) File where LD_DEBUG output should be fed into,
149 default is standard output. LD_DEBUG_OUTPUT is ignored for set-
150 user-ID/set-group-ID binaries.
151
152 LD_DYNAMIC_WEAK
153 (glibc since 2.1.91) Allow weak symbols to be overridden
154 (reverting to old glibc behavior). For security reasons, since
155 glibc 2.3.4, LD_DYNAMIC_WEAK is ignored for set-user-ID/set-
156 group-ID binaries.
157
158 LD_HWCAP_MASK
159 (glibc since 2.1) Mask for hardware capabilities.
160
161 LD_KEEPDIR
162 (a.out only)(libc5) Don't ignore the directory in the names of
163 a.out libraries to be loaded. Use of this option is strongly
164 discouraged.
165
166 LD_NOWARN
167 (a.out only)(libc5) Suppress warnings about a.out libraries with
168 incompatible minor version numbers.
169
170 LD_ORIGIN_PATH
171 (glibc since 2.1) Path where the binary is found (for non-set-
172 user-ID programs). For security reasons, since glibc 2.4,
173 LD_ORIGIN_PATH is ignored for set-user-ID/set-group-ID binaries.
174
175 LD_POINTER_GUARD
176 (glibc since 2.4) Set to 0 to disable pointer guarding. Any
177 other value enables pointer guarding, which is also the default.
178 Pointer guarding is a security mechanism whereby some pointers
179 to code stored in writable program memory (return addresses
180 saved by setjmp(3) or function pointers used by various glibc
181 internals) are mangled semi-randomly to make it more difficult
182 for an attacker to hijack the pointers for use in the event of a
183 buffer overrun or stack-smashing attack.
184
185 LD_PROFILE
186 (glibc since 2.1) Shared object to be profiled, specified either
187 as a pathname or a soname. Profiling output is written to the
188 file whose name is: "$LD_PROFILE_OUTPUT/$LD_PROFILE.profile".
189
190 LD_PROFILE_OUTPUT
191 (glibc since 2.1) Directory where LD_PROFILE output should be
192 written. If this variable is not defined, or is defined as an
193 empty string, then the default is /var/tmp. LD_PROFILE_OUTPUT
194 is ignored for set-user-ID and set-group-ID programs, which
195 always use /var/profile.
196
197 LD_SHOW_AUXV
198 (glibc since 2.1) Show auxiliary array passed up from the ker‐
199 nel. For security reasons, since glibc 2.3.5, LD_SHOW_AUXV is
200 ignored for set-user-ID/set-group-ID binaries.
201
202 LD_USE_LOAD_BIAS
203 By default (i.e., if this variable is not defined) executables
204 and prelinked shared objects will honor base addresses of their
205 dependent libraries and (non-prelinked) position-independent
206 executables (PIEs) and other shared objects will not honor them.
207 If LD_USE_LOAD_BIAS is defined wit the value, both executables
208 and PIEs will honor the base addresses. If LD_USE_LOAD_BIAS is
209 defined with the value 0, neither executables nor PIEs will
210 honor the base addresses. This variable is ignored by set-user-
211 ID and set-group-ID programs.
212
213 LD_VERBOSE
214 (glibc since 2.1) If set to a non-empty string, output symbol
215 versioning information about the program if querying information
216 about the program (i.e., either LD_TRACE_LOADED_OBJECTS has been
217 set, or --list or --verify options have been given to the
218 dynamic linker).
219
220 LD_WARN
221 (ELF only)(glibc since 2.1.3) If set to a non-empty string, warn
222 about unresolved symbols.
223
224 LDD_ARGV0
225 (libc5) argv[0] to be used by ldd(1) when none is present.
226
228 /lib/ld.so
229 a.out dynamic linker/loader
230 /lib/ld-linux.so.{1,2}
231 ELF dynamic linker/loader
232 /etc/ld.so.cache
233 File containing a compiled list of directories in which to
234 search for libraries and an ordered list of candidate libraries.
235 /etc/ld.so.preload
236 File containing a whitespace separated list of ELF shared
237 libraries to be loaded before the program.
238 lib*.so*
239 shared libraries
240
242 The ld.so functionality is available for executables compiled using
243 libc version 4.4.3 or greater. ELF functionality is available since
244 Linux 1.1.52 and libc5.
245
247 ldd(1), rtld-audit(7), ldconfig(8)
248
250 This page is part of release 3.22 of the Linux man-pages project. A
251 description of the project, and information about reporting bugs, can
252 be found at http://www.kernel.org/doc/man-pages/.
253
254
255
256GNU 2009-01-12 LD.SO(8)