Initial import from FreeBSD RELENG_4:
[dragonfly.git] / libexec / rtld-elf / rtld.1
CommitLineData
984263bc
MD
1.\" $FreeBSD: src/libexec/rtld-elf/rtld.1,v 1.18.2.7 2002/01/10 17:51:28 ru Exp $
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_FMT1
111.It Ev LD_TRACE_LOADED_OBJECTS_FMT2
112When set, these variables are interpreted as format strings a la
113.Xr printf 3
114to customize the trace output and are used by
115.Xr ldd 1 Ns 's
116.Fl f
117option and allows
118.Xr ldd 1
119to be operated as a filter more conveniently.
120The following conversions can be used:
121.Bl -tag -width 4n
122.It Li %a
123The main program's name
124(also known as
125.Dq __progname ) .
126.It Li \&%A
127The value of the environment variable
128.Ev LD_TRACE_LOADED_OBJECTS_PROGNAME
129.It Li %o
130The library name.
131.It Li %m
132The library's major version number.
133.It Li %p
134The full pathname as determined by
135.Nm rtld Ns 's
136library search rules.
137.It Li %x
138The library's load address.
139.El
140.Pp
141Additionally,
142.Ql \en
143and
144.Ql \et
145are recognized and have their usual meaning.
146.El
147.Sh FILES
148.Bl -tag -width indent
149.It Pa /var/run/ld-elf.so.hints
150.El
151.Sh SEE ALSO
152.Xr ld 1 ,
153.Xr ldd 1 ,
154.Xr elf 5 ,
155.Xr ldconfig 8