xref: /freebsd/libexec/rtld-elf/rtld.1 (revision f9218d3d4fd34f082473b3a021c6d4d109fb47cf)
1.\" $FreeBSD$
2.\"
3.\" Copyright (c) 1995 Paul Kranenburg
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgment:
16.\"      This product includes software developed by Paul Kranenburg.
17.\" 3. The name of the author may not be used to endorse or promote products
18.\"    derived from this software without specific prior written permission
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30.\"
31.Dd January 28, 2000
32.Dt RTLD 1
33.Os
34.Sh NAME
35.Nm ld-elf.so.1 ,
36.Nm ld.so ,
37.Nm rtld
38.Nd run-time link-editor
39.Sh DESCRIPTION
40The
41.Nm
42utility is a self-contained shared object providing run-time
43support for loading and link-editing shared objects into a process'
44address space.
45It is also commonly known as the dynamic linker.
46It uses the data structures
47contained within dynamically linked programs to determine which shared
48libraries are needed and loads them using the
49.Xr mmap 2
50system call.
51.Pp
52After all shared libraries have been successfully loaded,
53.Nm
54proceeds to resolve external references from both the main program and
55all objects loaded.
56A mechanism is provided for initialization routines
57to be called on a per-object basis, giving a shared object an opportunity
58to perform any extra set-up before execution of the program proper begins.
59This is useful for C++ libraries that contain static constructors.
60.Pp
61The
62.Nm
63utility itself is loaded by the kernel together with any dynamically-linked
64program that is to be executed.
65The kernel transfers control to the
66dynamic linker.
67After the dynamic linker has finished loading,
68relocating, and initializing the program and its required shared
69objects, it transfers control to the entry point of the program.
70.Pp
71To locate the required shared objects in the file system,
72.Nm
73may use a
74.Dq hints
75file prepared by the
76.Xr ldconfig 8
77utility.
78.Pp
79The
80.Nm
81utility
82recognizes a number of environment variables that can be used to modify
83its behaviour as follows:
84.Pp
85.Bl -tag -width ".Ev LD_LIBRARY_PATH"
86.It Ev LD_LIBRARY_PATH
87A colon separated list of directories, overriding the default search path
88for shared libraries.
89This is ignored for set-user-ID and set-group-ID programs.
90.It Ev LD_PRELOAD
91A list of shared libraries, separated by colons and/or white space,
92to be linked in before any
93other shared libraries.
94If the directory is not specified then
95the directories specified by
96.Ev LD_LIBRARY_PATH
97will be searched first
98followed by the set of built-in standard directories.
99This is ignored for set-user-ID and set-group-ID programs.
100.It Ev LD_BIND_NOW
101When set to a nonempty string, causes
102.Nm
103to relocate all external function calls before starting execution of the
104program.
105Normally, function calls are bound lazily, at the first call
106of each function.
107.Ev LD_BIND_NOW
108increases the start-up time of a program, but it avoids run-time
109surprises caused by unexpectedly undefined functions.
110.It Ev LD_TRACE_LOADED_OBJECTS
111When set to a nonempty string, causes
112.Nm
113to exit after loading the shared objects and printing a summary which includes
114the absolute pathnames of all objects, to standard output.
115.It Ev LD_TRACE_LOADED_OBJECTS_ALL
116When set to a nonempty string, causes
117.Nm
118to expand the summary to indicate which objects caused each object to
119be loaded.
120.It Ev LD_TRACE_LOADED_OBJECTS_FMT1
121.It Ev LD_TRACE_LOADED_OBJECTS_FMT2
122When set, these variables are interpreted as format strings a la
123.Xr printf 3
124to customize the trace output and are used by
125.Xr ldd 1 Ns 's
126.Fl f
127option and allows
128.Xr ldd 1
129to be operated as a filter more conveniently.
130The following conversions can be used:
131.Bl -tag -width 4n
132.It Li %a
133The main program's name
134(also known as
135.Dq __progname ) .
136.It Li \&%A
137The value of the environment variable
138.Ev LD_TRACE_LOADED_OBJECTS_PROGNAME
139.It Li %o
140The library name.
141.It Li %m
142The library's major version number.
143.It Li %p
144The full pathname as determined by
145.Nm rtld Ns 's
146library search rules.
147.It Li %x
148The library's load address.
149.El
150.Pp
151Additionally,
152.Ql \en
153and
154.Ql \et
155are recognized and have their usual meaning.
156.El
157.Sh FILES
158.Bl -tag -width indent
159.It Pa /var/run/ld-elf.so.hints
160.El
161.Sh SEE ALSO
162.Xr ld 1 ,
163.Xr ldd 1 ,
164.Xr elf 5 ,
165.Xr ldconfig 8
166