xref: /freebsd/libexec/rtld-elf/rtld.1 (revision 42c159fe388a3765f69860c84183700af37aca8a)
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 rtld
37.Nd run-time link-editor
38.Sh DESCRIPTION
39.Nm
40is a self-contained shared object providing run-time
41support for loading and link-editing shared objects into a process'
42address space.
43It is also commonly known as the dynamic linker.
44It uses the data structures
45contained within dynamically linked programs to determine which shared
46libraries are needed and loads them using the
47.Xr mmap 2
48system call.
49.Pp
50After all shared libraries have been successfully loaded,
51.Nm
52proceeds to resolve external references from both the main program and
53all objects loaded.
54A mechanism is provided for initialization routines
55to be called on a per-object basis, giving a shared object an opportunity
56to perform any extra set-up before execution of the program proper begins.
57This is useful for C++ libraries that contain static constructors.
58.Pp
59.Nm
60itself is loaded by the kernel together with any dynamically-linked
61program that is to be executed.
62The kernel transfers control to the
63dynamic linker.
64After the dynamic linker has finished loading,
65relocating, and initializing the program and its required shared
66objects, it transfers control to the entry point of the program.
67.Pp
68To locate the required shared objects in the filesystem,
69.Nm
70may use a
71.Dq hints
72file prepared by the
73.Xr ldconfig 8
74utility.
75.Pp
76.Nm
77recognizes a number of environment variables that can be used to modify
78its behaviour as follows:
79.Pp
80.Bl -tag -width ".Ev LD_LIBRARY_PATH"
81.It Ev LD_LIBRARY_PATH
82A colon separated list of directories, overriding the default search path
83for shared libraries.
84This is ignored for set-user-ID and set-group-ID programs.
85.It Ev LD_PRELOAD
86A list of shared libraries, separated by colons and/or white space,
87to be linked in before any
88other shared libraries.
89If the directory is not specified then
90the directories specified by
91.Ev LD_LIBRARY_PATH
92will be searched first
93followed by the set of built-in standard directories.
94This is ignored for set-user-ID and set-group-ID programs.
95.It Ev LD_BIND_NOW
96When set to a nonempty string, causes
97.Nm
98to relocate all external function calls before starting execution of the
99program.
100Normally, function calls are bound lazily, at the first call
101of each function.
102.Ev LD_BIND_NOW
103increases the start-up time of a program, but it avoids run-time
104surprises caused by unexpectedly undefined functions.
105.It Ev LD_TRACE_LOADED_OBJECTS
106When set to a nonempty string, causes
107.Nm
108to exit after loading the shared objects and printing a summary which includes
109the absolute pathnames of all objects, to standard output.
110.It Ev LD_TRACE_LOADED_OBJECTS_ALL
111When set to a nonempty string, causes
112.Nm
113to expand the summary to indicate which objects caused each object to
114be loaded.
115.It Ev LD_TRACE_LOADED_OBJECTS_FMT1
116.It Ev LD_TRACE_LOADED_OBJECTS_FMT2
117When set, these variables are interpreted as format strings a la
118.Xr printf 3
119to customize the trace output and are used by
120.Xr ldd 1 Ns 's
121.Fl f
122option and allows
123.Xr ldd 1
124to be operated as a filter more conveniently.
125The following conversions can be used:
126.Bl -tag -width 4n
127.It Li %a
128The main program's name
129(also known as
130.Dq __progname ) .
131.It Li \&%A
132The value of the environment variable
133.Ev LD_TRACE_LOADED_OBJECTS_PROGNAME
134.It Li %o
135The library name.
136.It Li %m
137The library's major version number.
138.It Li %p
139The full pathname as determined by
140.Nm rtld Ns 's
141library search rules.
142.It Li %x
143The library's load address.
144.El
145.Pp
146Additionally,
147.Ql \en
148and
149.Ql \et
150are recognized and have their usual meaning.
151.El
152.Sh FILES
153.Bl -tag -width indent
154.It Pa /var/run/ld-elf.so.hints
155.El
156.Sh SEE ALSO
157.Xr ld 1 ,
158.Xr ldd 1 ,
159.Xr elf 5 ,
160.Xr ldconfig 8
161