1 .\" $NetBSD: ld.aout_so.1,v 1.8 2008/04/30 13:10:52 martin Exp $
3 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Paul Kranenburg.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nd run-time link-editor
38 is a self-contained, position independent program image
39 providing run-time support for loading and link-editing
40 shared objects into a process' address space.
41 It uses the data structures
46 contained within dynamically linked programs to determine which shared
47 libraries are needed and loads them at a convenient virtual address
52 After all shared libraries have been successfully loaded,
54 proceeds to resolve external references from both the main program and
56 A mechanism is provided for initialization routines to be called,
57 on a per-object basis, giving a shared object an opportunity
58 to perform any extra set-up, before execution of the program proper begins.
60 looks for a symbol named
62 in each object's symbol table.
63 If present, this symbol is assumed to represent a C-function declared as
70 function is called just before an object is unloaded from the process
71 address space as a result of calling
73 Note that while an object's
75 is always called, whether the object is loaded automatically at program
76 startup or programmatically by using
80 function is called only on
81 .Sq last Xr dlclose 3 .
83 This mechanism is exploited by the system-supplied C++ constructor
84 initialization code located in
85 .Pa /usr/lib/c++rt.o .
86 This file should be included in the list of object-code files passed to
88 when building a shared C++ library.
91 is itself a shared object that is initially loaded by the startup module
95 formats do not provide easy access to the file header from within a running
98 uses the special symbol
100 to determine whether a program is in fact dynamically linked or not.
103 has relocated this symbol to a location other than 0,
105 assumes the services of
116 entry point before the program's
121 can complete the link-editing process before the dynamic program calls upon
122 services of any dynamic library.
124 To quickly locate the required shared objects in the filesystem,
128 file, prepared by the
130 utility, in which the full path specification of the shared objects can be
131 looked up by hashing on the 3-tuple
133 library-name, major-version-number, minor-version-number
137 recognizes a number of environment variables that can be used to modify
138 its behavior as follows:
140 .\" intentionally not the longest
141 .Bl -tag -width LD_TRACE_LOADED_OBJECTS
142 .It Ev LD_LIBRARY_PATH
143 A colon separated list of directories, overriding the default search path
144 for shared libraries.
146 A colon separated list of shared object filenames to be loaded
150 its shared object dependencies.
151 .It Ev LD_WARN_NON_PURE_CODE
152 When set, issue a warning whenever a link-editing operation requires
153 modification of the text segment of some loaded object.
154 This is usually indicative of an incorrectly built library.
155 .It Ev LD_SUPPRESS_WARNINGS
156 When set, no warning messages of any kind are issued.
157 Normally, a warning is given if satisfactorily versioned
158 library could not be found.
159 .It Ev LD_TRACE_LOADED_OBJECTS
162 to exit after loading the shared objects and printing a summary which includes
163 the absolute pathnames of all objects, to standard output.
164 .It Ev LD_TRACE_LOADED_OBJECTS_FMT1
165 .It Ev LD_TRACE_LOADED_OBJECTS_FMT2
166 When set, these variables are interpreted as format strings a la
168 to customize the trace output and are used by
173 to be operated as a filter more conveniently.
174 The following conversions can be used:
177 The main program's name
182 The value of the environment variable
183 .Ev LD_TRACE_LOADED_OBJECTS_PROGNAME
187 The library's major version number.
189 The library's minor version number.
191 The full pathname as determined by
193 library search rules.
195 The library's load address.
202 are recognized and have their usual meaning.
203 .It Ev LD_NO_INTERN_SEARCH
206 does not process any internal search paths that were recorded in the
209 When set, do not include a set of built-in standard directory paths for
211 This might be useful when running on a system with a completely
212 non-standard filesystem layout.
215 .Bl -tag -width /var/run/ld.so.hintsXXX -compact
216 .It Pa /var/run/ld.so.hints
217 library location hints built by
227 The shared library model employed first appeared in SunOS 4.0.
228 .Sh SECURITY CONSIDERATIONS
229 The environment variables
233 are not honored when executing in a set-user-ID or set-group-ID environment.
234 This action is taken to prevent malicious substitution of shared object
235 dependencies or interposition of symbols.