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