1.\" $OpenBSD: ld.so.1,v 1.18 2011/12/03 23:01:21 schwarze Exp $ 2.\" $NetBSD: rtld.1,v 1.2 1995/10/08 23:43:28 pk Exp $ 3.\" 4.\" Copyright (c) 1995 Paul Kranenburg 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by Paul Kranenburg. 18.\" 3. The name of the author may not be used to endorse or promote products 19.\" derived from this software without specific prior written permission 20.\" 21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31.\" 32.Dd $Mdocdate: December 3 2011 $ 33.Dt LD.SO 1 34.Os 35.Sh NAME 36.Nm ld.so 37.Nd run-time link-editor 38.Sh DESCRIPTION 39.Nm 40is a self-contained, position independent program image providing run-time 41support for loading and link-editing shared objects into a process's 42address space. 43It uses the data structures 44.Po 45see 46.Xr link 5 47.Pc 48contained within dynamically linked programs to determine which shared 49libraries are needed and loads them at a convenient virtual address 50using the 51.Xr mmap 2 52system call. 53.Pp 54After all shared libraries have been successfully loaded, 55.Nm 56proceeds to resolve external references from both the main program and 57all objects loaded. 58A mechanism is provided for initialization routines to be called, 59on a per-object basis, giving a shared object an opportunity 60to perform any extra set-up, before execution of the program proper begins. 61.\" 62.\" <talk about CTORS/DTORS> 63.\" 64.Pp 65.Nm 66is itself a shared object that is initially loaded by the kernel. 67.\" 68.\" <How it is run> 69.\" 70.Pp 71To quickly locate the required shared objects in the filesystem, 72.Nm 73may use a 74.Dq hints 75file, prepared by the 76.Xr ldconfig 8 77utility, in which the full path specification of the shared objects can be 78looked up by hashing on the 3-tuple 79.Aq library-name , major-version-number , minor-version-number . 80.Pp 81.Nm 82recognises a number of environment variables that can be used to modify 83its behaviour as follows: 84.Pp 85.Bl -tag -width Ds -compact 86.It Ev LD_LIBRARY_PATH 87A colon separated list of directories, prepending the default search path 88for shared libraries. 89This variable is ignored for set-user-ID and set-group-ID executables. 90.Pp 91.It Ev LD_PRELOAD 92A colon separate list of library names to load before any of the regular 93libraries are loaded. 94This variable is ignored for set-user-ID and set-group-ID executables. 95.Pp 96.It Ev LD_BIND_NOW 97Specifies that the dynamic linker should process all relocations before 98transferring control to the program. 99Normally, the procedure linkage table entries are handled lazily, 100avoiding symbol lookup and relocation for unused functions. 101This variable is ignored for set-user-ID and set-group-ID executables. 102.Pp 103.It Ev LD_WARN_NON_PURE_CODE 104When set, issue a warning whenever a link-editing operation requires 105modification of the text segment of some loaded object. 106This is usually indicative of an incorrectly built library. 107.Aq not yet supported 108.Pp 109.It Ev LD_SUPPRESS_WARNINGS 110When set, no warning messages of any kind are issued. 111Normally, a warning is given if a satisfactorily versioned library 112could not be found. 113.Aq not yet supported 114.Pp 115.It Ev LD_TRACE_LOADED_OBJECTS 116When set, causes 117.Nm 118to exit after loading the shared objects and printing a summary which includes 119the absolute pathnames of all objects, to standard output. 120.Pp 121.It Ev LD_TRACE_LOADED_OBJECTS_FMT1 122.It Ev LD_TRACE_LOADED_OBJECTS_FMT2 123When set, these variables are interpreted as format strings a la 124.Xr printf 3 125to customize the trace output and are used by 126.Xr ldd 1 Ns 's 127.Fl f 128option and allows 129.Xr ldd 1 130to be operated as a filter more conveniently. 131.Ev LD_TRACE_LOADED_OBJECTS_FMT1 132is used for tracing shared libraries; 133.Ev LD_TRACE_LOADED_OBJECTS_FMT2 134for dynamically loaded objects, the dynamic linker, 135and the main executable. 136The following conversions can be used: 137.Bl -tag -width "xxxx" 138.It %a 139The main program's name 140.Pq also known as Dq __progname . 141.It \&%A 142The value of the environment variable 143.Ev LD_TRACE_LOADED_OBJECTS_PROGNAME . 144.It %e 145The end address of the object. 146.It %g 147The object's group reference count. 148.It %m 149The object's major version number. 150.It %n 151The object's minor version number. 152.It \&%O 153The object's open count. 154.It %o 155The object name. 156.It %p 157The full pathname as determined by 158.Nm ld.so Ns 's 159library search rules. 160.It %r 161The object's reference count. 162.It %x 163The object's load address. 164.El 165.Pp 166Additionally, 167.Sy \en 168and 169.Sy \et 170are recognised and have their usual meaning. 171.Pp 172.It Ev LD_NO_INTERN_SEARCH 173When set, 174.Nm 175does not process any internal search paths that were recorded in the 176executable. 177.Aq not yet supported 178.Pp 179.It Ev LD_NORANDOM 180When set, do not load shared objects or libraries dependent objects in 181random order. 182This variable is ignored for set-user-ID and set-group-ID executables. 183.Pp 184.It Ev LD_NOSTD_PATH 185.Aq not yet supported 186When set, do not include a set of built-in standard directory paths for 187searching. 188This might be useful when running on a system with a completely 189non-standard filesystem layout. 190.Pp 191.It Ev LD_DEBUG 192When set, be verbose about what 193.Nm 194does. 195.Pp 196.It Ev LD_NOPREBIND 197When set, ignore any prebind data associated with the program or libraries. 198.Pp 199.It Ev LD_PREBINDVALIDATE 200When set, perform symbol relocation of the given binary and the associated 201libraries, compare the results against the prebind values, then exit. 202.El 203.Sh FILES 204.Bl -tag -width /var/run/ld.so.hintsXXX -compact 205.It Pa /var/run/ld.so.hints 206library location hints built by 207.Xr ldconfig 8 208.El 209.Sh SEE ALSO 210.Xr ld 1 , 211.Xr link 5 , 212.Xr ldconfig 8 213.Sh HISTORY 214The shared library model employed first appeared in SunOS 4.0. 215