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