Merge from vendor branch DIFFUTILS:
[dragonfly.git] / libexec / rtld-aout / rtld.1aout
1 .\" $FreeBSD: src/libexec/rtld-aout/rtld.1aout,v 1.17.2.4 2001/08/16 10:44:20 ru Exp $
2 .\" $DragonFly: src/libexec/rtld-aout/Attic/rtld.1aout,v 1.2 2003/06/17 04:27:08 dillon Exp $
3 .\"
4 .\" Copyright (c) 1995 Paul Kranenburg
5 .\" All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\"    must display the following acknowledgment:
17 .\"      This product includes software developed by Paul Kranenburg.
18 .\" 3. The name of the author may not be used to endorse or promote products
19 .\"    derived from this software without specific prior written permission
20 .\"
21 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 .\"
32 .Dd June 27, 1995
33 .Dt RTLD 1
34 .Os
35 .Sh NAME
36 .Nm ld.so ,
37 .Nm rtld
38 .Nd run-time link-editor
39 .Sh DESCRIPTION
40 .Nm
41 is a self-contained, position independent program image providing run-time
42 support for loading and link-editing shared objects into a process'
43 address space. It uses the data structures
44 (see
45 .Xr link 5 )
46 contained within dynamically linked programs to determine which shared
47 libraries are needed and loads them at a convenient virtual address
48 using the
49 .Xr mmap 2
50 system call.
51 .Pp
52 After all shared libraries have been successfully loaded,
53 .Nm
54 proceeds to resolve external references from both the main program and
55 all objects loaded. A mechanism is provided for initialization routines
56 to be called, on a per-object basis, giving a shared object an opportunity
57 to perform any extra set-up, before execution of the program proper begins.
58 This is useful for C++ libraries that contain static constructors.
59 .Pp
60 .Nm
61 is itself a shared object that is initially loaded by the startup module
62 .Em crt0 .
63 Since
64 .Xr a.out 5
65 formats do not provide easy access to the file header from within a running
66 process,
67 .Em crt0
68 uses the special symbol
69 .Va _DYNAMIC
70 to determine whether a program is in fact dynamically linked or not. Whenever
71 the linker
72 .Xr ld 1
73 has relocated this symbol to a location other than 0,
74 .Em crt0
75 assumes the services of
76 .Nm
77 are needed
78 (see
79 .Xr link 5
80 for details).
81 .Em crt0
82 passes control to
83 .Nm Ns 's
84 entry point before the program's
85 .Fn main
86 routine is called. Thus,
87 .Nm
88 can complete the link-editing process before the dynamic program calls upon
89 services of any dynamic library.
90 .Pp
91 To quickly locate the required shared objects in the filesystem,
92 .Nm
93 may use a
94 .Dq hints
95 file, prepared by the
96 .Xr ldconfig 8
97 utility, in which the full path specification of the shared objects can be
98 looked up by hashing on the 3-tuple
99 .Aq library-name , major-version-number , minor-version-number .
100 .Pp
101 .Nm
102 recognizes a number of environment variables that can be used to modify
103 its behaviour as follows:
104 .Pp
105 .Bl -tag -width "LD_IGNORE_MISSING_OBJECTS"
106 .It Ev LD_LIBRARY_PATH
107 A colon separated list of directories, overriding the default search path
108 for shared libraries.
109 This is ignored for set-user-ID and set-group-ID programs.
110 .It Ev LD_PRELOAD
111 A colon separated list of shared libraries, to be linked in before any
112 other shared libraries.  If the directory is not specified then
113 the directories specified by LD_LIBRARY_PATH will be searched first
114 followed by the set of built-in standard directories.
115 This is ignored for set-user-ID and set-group-ID programs.
116 .It Ev LD_BIND_NOW
117 When set to a nonempty string, causes
118 .Nm
119 to relocate all external function calls before starting execution of the
120 program.  Normally, function calls are bound lazily, at the first call
121 of each function.
122 .Ev LD_BIND_NOW
123 increases the start-up time of a program, but it avoids run-time
124 surprises caused by unexpectedly undefined functions.
125 .It Ev LD_WARN_NON_PURE_CODE
126 When set to a nonempty string, issue a warning whenever a link-editing
127 operation requires modification of the text segment of some loaded
128 object. This is usually indicative of an incorrectly built library.
129 .It Ev LD_SUPPRESS_WARNINGS
130 When set to a nonempty string, no warning messages of any kind are
131 issued. Normally, a warning is given if satisfactorily versioned
132 library could not be found.
133 .It Ev LD_IGNORE_MISSING_OBJECTS
134 When set to a nonempty string, makes it a nonfatal condition if
135 one or more required shared objects cannot be loaded.
136 Loading and execution proceeds using the objects that are
137 available.
138 A warning is produced for each missing object, unless the environment
139 variable
140 .Ev LD_SUPPRESS_WARNINGS
141 is set to a nonempty string.
142 .Pp
143 This is ignored for set-user-ID and set-group-ID programs.
144 .Pp
145 Missing shared objects can be ignored without errors if all the
146 following conditions hold:
147 .Bl -bullet
148 .It
149 They do not supply definitions for any required data symbols.
150 .It
151 No functions defined by them are called during program execution.
152 .It
153 The environment variable
154 .Ev LD_BIND_NOW
155 is unset or is set to the empty string.
156 .El
157 .It Ev LD_TRACE_LOADED_OBJECTS
158 When set to a nonempty string, causes
159 .Nm
160 to exit after loading the shared objects and printing a summary which includes
161 the absolute pathnames of all objects, to standard output.
162 .It Ev LD_TRACE_LOADED_OBJECTS_FMT1
163 .It Ev LD_TRACE_LOADED_OBJECTS_FMT2
164 When set, these variables are interpreted as format strings a la
165 .Xr printf 3
166 to customize the trace output and are used by
167 .Xr ldd 1 Ns 's
168 .Fl f
169 option and allows
170 .Xr ldd 1
171 to be operated as a filter more conveniently.
172 The following conversions can be used:
173 .Bl -tag -width "xxxx"
174 .It \&%a
175 The main program's name
176 (also known as
177 .Dq __progname ) .
178 .It \&%A
179 The value of the environment variable
180 .Ev LD_TRACE_LOADED_OBJECTS_PROGNAME
181 .It \&%o
182 The library name.
183 .It \&%m
184 The library's major version number.
185 .It \&%n
186 The library's minor version number.
187 .It \&%p
188 The full pathname as determined by
189 .Nm rtld Ns 's
190 library search rules.
191 .It \&%x
192 The library's load address.
193 .El
194 .Pp
195 Additionally,
196 .Sy \en
197 and
198 .Sy \et
199 are recognized and have their usual meaning.
200 .\" .It Ev LD_NO_INTERN_SEARCH
201 .\" When set,
202 .\" .Nm
203 .\" does not process any internal search paths that were recorded in the
204 .\" executable.
205 .\" .It Ev LD_NOSTD_PATH
206 .\" When set, do not include a set of built-in standard directory paths for
207 .\" searching. This might be useful when running on a system with a completely
208 .\" non-standard filesystem layout.
209 .El
210 .Pp
211 .Sh FILES
212 /var/run/ld.so.hints
213 .Pp
214 .Sh SEE ALSO
215 .Xr ld 1 ,
216 .Xr link 5 ,
217 .Xr ldconfig 8
218 .Sh HISTORY
219 The shared library model employed first appeared in SunOS 4.0.