1995-08-26 14:17:39 +01:00
|
|
|
.\" Copyright (c) 1995 Paul Kranenburg
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
1997-01-12 00:19:14 +00:00
|
|
|
.\" must display the following acknowledgment:
|
1995-08-26 14:17:39 +01:00
|
|
|
.\" This product includes software developed by Paul Kranenburg.
|
|
|
|
.\" 3. The name of the author may not be used to endorse or promote products
|
|
|
|
.\" derived from this software without specific prior written permission
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
2003-06-02 16:02:06 +01:00
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2021-11-13 01:18:13 +00:00
|
|
|
.Dd November 13, 2021
|
1995-08-26 14:17:39 +01:00
|
|
|
.Dt RTLD 1
|
2001-07-10 11:49:54 +01:00
|
|
|
.Os
|
1995-08-26 14:17:39 +01:00
|
|
|
.Sh NAME
|
2000-01-29 03:16:54 +00:00
|
|
|
.Nm ld-elf.so.1 ,
|
2003-02-13 23:07:28 +00:00
|
|
|
.Nm ld.so ,
|
1999-09-28 06:35:59 +01:00
|
|
|
.Nm rtld
|
1995-08-26 14:17:39 +01:00
|
|
|
.Nd run-time link-editor
|
|
|
|
.Sh DESCRIPTION
|
2002-07-06 20:19:48 +01:00
|
|
|
The
|
1995-08-26 14:17:39 +01:00
|
|
|
.Nm
|
2002-07-06 20:19:48 +01:00
|
|
|
utility is a self-contained shared object providing run-time
|
1995-08-26 14:17:39 +01:00
|
|
|
support for loading and link-editing shared objects into a process'
|
2002-01-10 17:49:57 +00:00
|
|
|
address space.
|
|
|
|
It is also commonly known as the dynamic linker.
|
2000-01-29 03:16:54 +00:00
|
|
|
It uses the data structures
|
1995-08-26 14:17:39 +01:00
|
|
|
contained within dynamically linked programs to determine which shared
|
2000-01-29 03:16:54 +00:00
|
|
|
libraries are needed and loads them using the
|
1995-08-26 14:17:39 +01:00
|
|
|
.Xr mmap 2
|
|
|
|
system call.
|
|
|
|
.Pp
|
1997-01-12 00:19:14 +00:00
|
|
|
After all shared libraries have been successfully loaded,
|
1995-08-26 14:17:39 +01:00
|
|
|
.Nm
|
|
|
|
proceeds to resolve external references from both the main program and
|
2002-01-10 17:49:57 +00:00
|
|
|
all objects loaded.
|
|
|
|
A mechanism is provided for initialization routines
|
2000-01-29 03:16:54 +00:00
|
|
|
to be called on a per-object basis, giving a shared object an opportunity
|
|
|
|
to perform any extra set-up before execution of the program proper begins.
|
1997-05-27 14:46:40 +01:00
|
|
|
This is useful for C++ libraries that contain static constructors.
|
1995-08-26 14:17:39 +01:00
|
|
|
.Pp
|
2009-04-01 15:38:20 +01:00
|
|
|
When resolving dependencies for the loaded objects,
|
|
|
|
.Nm
|
2017-05-29 14:36:32 +01:00
|
|
|
translates dynamic token strings in rpath and soname.
|
|
|
|
If the
|
2009-04-01 15:38:20 +01:00
|
|
|
.Fl "z origin"
|
2017-05-29 14:36:32 +01:00
|
|
|
option of the static linker was set when linking the binary,
|
|
|
|
the token expansion is performed at the object load time, see
|
2009-04-01 15:38:20 +01:00
|
|
|
.Xr ld 1 .
|
|
|
|
The following strings are recognized now:
|
|
|
|
.Bl -tag -width ".Pa $PLATFORM"
|
|
|
|
.It Pa $ORIGIN
|
|
|
|
Translated to the full path of the loaded object.
|
|
|
|
.It Pa $OSNAME
|
|
|
|
Translated to the name of the operating system implementation.
|
|
|
|
.It Pa $OSREL
|
|
|
|
Translated to the release level of the operating system.
|
|
|
|
.It Pa $PLATFORM
|
|
|
|
Translated to the machine hardware platform.
|
|
|
|
.El
|
|
|
|
.Pp
|
2002-07-06 20:19:48 +01:00
|
|
|
The
|
1995-08-26 14:17:39 +01:00
|
|
|
.Nm
|
2002-07-06 20:19:48 +01:00
|
|
|
utility itself is loaded by the kernel together with any dynamically-linked
|
2002-01-10 17:49:57 +00:00
|
|
|
program that is to be executed.
|
|
|
|
The kernel transfers control to the
|
|
|
|
dynamic linker.
|
|
|
|
After the dynamic linker has finished loading,
|
2000-01-29 03:16:54 +00:00
|
|
|
relocating, and initializing the program and its required shared
|
|
|
|
objects, it transfers control to the entry point of the program.
|
2012-07-15 11:53:48 +01:00
|
|
|
The following search order is used to locate required shared objects:
|
1995-08-26 14:17:39 +01:00
|
|
|
.Pp
|
2012-07-15 11:53:48 +01:00
|
|
|
.Bl -enum -offset indent -compact
|
|
|
|
.It
|
|
|
|
.Dv DT_RPATH
|
|
|
|
of the referencing object unless that object also contains a
|
|
|
|
.Dv DT_RUNPATH
|
|
|
|
tag
|
|
|
|
.It
|
|
|
|
.Dv DT_RPATH
|
|
|
|
of the program unless the referencing object contains a
|
|
|
|
.Dv DT_RUNPATH
|
|
|
|
tag
|
|
|
|
.It
|
|
|
|
Path indicated by
|
|
|
|
.Ev LD_LIBRARY_PATH
|
|
|
|
environment variable
|
|
|
|
.It
|
|
|
|
.Dv DT_RUNPATH
|
|
|
|
of the referencing object
|
|
|
|
.It
|
|
|
|
Hints file produced by the
|
1995-08-26 14:17:39 +01:00
|
|
|
.Xr ldconfig 8
|
2012-07-15 11:53:48 +01:00
|
|
|
utility
|
|
|
|
.It
|
|
|
|
The
|
|
|
|
.Pa /lib
|
|
|
|
and
|
|
|
|
.Pa /usr/lib
|
|
|
|
directories, unless the referencing object was linked using the
|
|
|
|
.Dq Fl z Ar nodefaultlib
|
|
|
|
option
|
|
|
|
.El
|
1995-08-26 14:17:39 +01:00
|
|
|
.Pp
|
2002-07-06 20:19:48 +01:00
|
|
|
The
|
1995-08-26 14:17:39 +01:00
|
|
|
.Nm
|
2002-07-06 20:19:48 +01:00
|
|
|
utility
|
1997-09-13 17:01:53 +01:00
|
|
|
recognizes a number of environment variables that can be used to modify
|
2006-03-27 01:53:58 +01:00
|
|
|
its behaviour.
|
|
|
|
On 64-bit architectures, the linker for 32-bit objects recognizes
|
|
|
|
all the environment variables listed below, but is being prefixed with
|
2006-09-17 22:48:47 +01:00
|
|
|
.Ev LD_32_ ,
|
|
|
|
for example:
|
|
|
|
.Ev LD_32_TRACE_LOADED_OBJECTS .
|
2021-05-29 00:59:07 +01:00
|
|
|
If the activated image is setuid or setgid, the variables are ignored.
|
2003-06-02 16:02:06 +01:00
|
|
|
.Bl -tag -width ".Ev LD_LIBMAP_DISABLE"
|
2003-06-19 04:55:38 +01:00
|
|
|
.It Ev LD_DUMP_REL_POST
|
2007-01-23 22:38:39 +00:00
|
|
|
If set,
|
2003-06-19 04:55:38 +01:00
|
|
|
.Nm
|
2003-06-19 05:34:09 +01:00
|
|
|
will print a table containing all relocations after symbol
|
2003-06-19 04:55:38 +01:00
|
|
|
binding and relocation.
|
|
|
|
.It Ev LD_DUMP_REL_PRE
|
2007-01-23 22:38:39 +00:00
|
|
|
If set,
|
2003-06-19 04:55:38 +01:00
|
|
|
.Nm
|
2003-06-19 05:34:09 +01:00
|
|
|
will print a table containing all relocations before symbol
|
2003-06-19 04:55:38 +01:00
|
|
|
binding and relocation.
|
2021-08-15 05:13:33 +01:00
|
|
|
.It Ev LD_DYNAMIC_WEAK
|
|
|
|
If set, use the ELF standard-compliant symbol lookup behavior:
|
|
|
|
resolve to the first found symbol definition.
|
|
|
|
.Pp
|
|
|
|
By default,
|
|
|
|
.Fx
|
|
|
|
provides the non-standard symbol lookup behavior:
|
|
|
|
when a weak symbol definition is found, remember the definition and
|
|
|
|
keep searching in the remaining shared objects for a non-weak definition.
|
|
|
|
If found, the non-weak definition is preferred, otherwise the remembered
|
|
|
|
weak definition is returned.
|
|
|
|
.Pp
|
|
|
|
Symbols exported by dynamic linker itself (see
|
|
|
|
.Xr dlfcn 3 )
|
|
|
|
are always resolved using
|
|
|
|
.Fx
|
|
|
|
rules regardless of the presence of the variable.
|
|
|
|
This variable is unset for set-user-ID and set-group-ID programs.
|
2005-02-04 02:46:41 +00:00
|
|
|
.It Ev LD_LIBMAP
|
|
|
|
A library replacement list in the same format as
|
|
|
|
.Xr libmap.conf 5 .
|
|
|
|
For convenience, the characters
|
|
|
|
.Ql =
|
|
|
|
and
|
|
|
|
.Ql \&,
|
|
|
|
can be used instead of a space and a newline.
|
2005-06-14 09:41:11 +01:00
|
|
|
This variable is parsed after
|
2005-02-04 02:46:41 +00:00
|
|
|
.Xr libmap.conf 5 ,
|
|
|
|
and will override its entries.
|
2007-05-17 20:14:25 +01:00
|
|
|
This variable is unset for set-user-ID and set-group-ID programs.
|
2003-05-31 15:45:11 +01:00
|
|
|
.It Ev LD_LIBMAP_DISABLE
|
2003-06-02 16:02:06 +01:00
|
|
|
If set, disables the use of
|
2005-06-14 09:41:11 +01:00
|
|
|
.Xr libmap.conf 5
|
2005-02-04 02:46:41 +00:00
|
|
|
and
|
|
|
|
.Ev LD_LIBMAP .
|
2007-05-17 20:14:25 +01:00
|
|
|
This variable is unset for set-user-ID and set-group-ID programs.
|
2009-03-23 16:49:00 +00:00
|
|
|
.It Ev LD_ELF_HINTS_PATH
|
|
|
|
This variable will override the default location of
|
|
|
|
.Dq hints
|
|
|
|
file.
|
|
|
|
This variable is unset for set-user-ID and set-group-ID programs.
|
1995-08-26 14:17:39 +01:00
|
|
|
.It Ev LD_LIBRARY_PATH
|
|
|
|
A colon separated list of directories, overriding the default search path
|
|
|
|
for shared libraries.
|
2007-05-17 20:14:25 +01:00
|
|
|
This variable is unset for set-user-ID and set-group-ID programs.
|
2012-07-15 11:53:48 +01:00
|
|
|
.It Ev LD_LIBRARY_PATH_RPATH
|
|
|
|
If the variable is specified and has a value starting with
|
|
|
|
any of \'y\', \'Y\' or \'1\' symbols, the path specified by
|
|
|
|
.Ev LD_LIBRARY_PATH
|
|
|
|
variable is allowed to override the path from
|
|
|
|
.Dv DT_RPATH
|
|
|
|
for binaries which does not contain
|
|
|
|
.Dv DT_RUNPATH
|
|
|
|
tag.
|
|
|
|
For such binaries, when the variable
|
|
|
|
.Ev LD_LIBRARY_PATH_RPATH
|
|
|
|
is set,
|
|
|
|
.Dq Fl z Ar nodefaultlib
|
|
|
|
link-time option is ignored as well.
|
1996-04-20 19:29:50 +01:00
|
|
|
.It Ev LD_PRELOAD
|
2000-01-29 03:16:54 +00:00
|
|
|
A list of shared libraries, separated by colons and/or white space,
|
|
|
|
to be linked in before any
|
2002-01-10 17:49:57 +00:00
|
|
|
other shared libraries.
|
|
|
|
If the directory is not specified then
|
|
|
|
the directories specified by
|
2022-02-25 16:09:03 +00:00
|
|
|
.Ev LD_LIBRARY_PATH
|
|
|
|
will be searched first
|
|
|
|
followed by the set of built-in standard directories.
|
|
|
|
This variable is unset for set-user-ID and set-group-ID programs.
|
2021-03-24 23:49:59 +00:00
|
|
|
.It Ev LD_PRELOAD_FDS
|
2021-03-24 21:10:33 +00:00
|
|
|
A colon separated list of file descriptor numbers for libraries.
|
|
|
|
This is intended for preloading libraries in which we already have a file
|
|
|
|
descriptor.
|
|
|
|
This may optimize the process of loading libraries because we do not have to
|
|
|
|
look for them in directories.
|
|
|
|
It may also be useful in a capability base system where we do not have access to
|
|
|
|
global namespaces such as the filesystem.
|
2017-05-18 01:32:05 +01:00
|
|
|
.It Ev LD_LIBRARY_PATH_FDS
|
2014-06-20 18:08:32 +01:00
|
|
|
A colon separated list of file descriptor numbers for library directories.
|
|
|
|
This is intended for use within
|
|
|
|
.Xr capsicum 4
|
|
|
|
sandboxes, when global namespaces such as the filesystem are unavailable.
|
|
|
|
It is consulted just after LD_LIBRARY_PATH.
|
|
|
|
This variable is unset for set-user-ID and set-group-ID programs.
|
2017-03-15 21:11:57 +00:00
|
|
|
.It Ev LD_BIND_NOT
|
|
|
|
When set to a nonempty string, prevents modifications of the PLT slots when
|
|
|
|
doing bindings.
|
|
|
|
As result, each call of the PLT-resolved function is resolved.
|
|
|
|
In combination with debug output, this provides complete account of
|
|
|
|
all bind actions at runtime.
|
2017-03-16 22:15:43 +00:00
|
|
|
This variable is unset for set-user-ID and set-group-ID programs.
|
1997-01-12 00:16:36 +00:00
|
|
|
.It Ev LD_BIND_NOW
|
|
|
|
When set to a nonempty string, causes
|
|
|
|
.Nm
|
|
|
|
to relocate all external function calls before starting execution of the
|
2002-01-10 17:49:57 +00:00
|
|
|
program.
|
|
|
|
Normally, function calls are bound lazily, at the first call
|
1997-01-12 00:16:36 +00:00
|
|
|
of each function.
|
|
|
|
.Ev LD_BIND_NOW
|
|
|
|
increases the start-up time of a program, but it avoids run-time
|
|
|
|
surprises caused by unexpectedly undefined functions.
|
1995-08-26 14:17:39 +01:00
|
|
|
.It Ev LD_TRACE_LOADED_OBJECTS
|
1997-01-12 00:16:36 +00:00
|
|
|
When set to a nonempty string, causes
|
1995-08-26 14:17:39 +01:00
|
|
|
.Nm
|
|
|
|
to exit after loading the shared objects and printing a summary which includes
|
|
|
|
the absolute pathnames of all objects, to standard output.
|
2002-02-17 07:04:32 +00:00
|
|
|
.It Ev LD_TRACE_LOADED_OBJECTS_ALL
|
|
|
|
When set to a nonempty string, causes
|
|
|
|
.Nm
|
|
|
|
to expand the summary to indicate which objects caused each object to
|
|
|
|
be loaded.
|
Update to handle new version ld.so.hints and info in executable for
configurable fallback search paths, as well as new crt interface version.
Also:
- even faster getenv(), get all environment variable settings in a single
pass.
- ldd printf-like format specifications
- minor code cleanups, one vsprintf -> vsnprintf (harmless)
The library search sequence is a little more complete now. Before,
it'd search $LD_LIBRARY_PATH (by opendir/readdir/closedir), then read
the hints file, then read /usr/lib (again by scanning thr directory). It
would then fail if there was no "found" library.
Now, it does LD_LIBRARY_PATH and the hints file the same, but then uses
a longer fallback path. The -R path is fetched from the executable if
specified at build time, the ldconfig path is appended, and /usr/lib is
appended to that. Duplicates are suppressed. This means that simply
placing a new library in /usr/local/lib will work (the same as it did in
/usr/lib) without needing ldconfig -m. It will find it quicker if the
ldconfig is run though.
Similar changes have been made to the NetBSD ld.so, but ours is rather
different now due to John Polstra's speedups and fixes from a while back.
The ldd printf-like format support came direct from NetBSD.
Reviewed by: nate, jdp
1996-10-01 02:52:03 +01:00
|
|
|
.It Ev LD_TRACE_LOADED_OBJECTS_FMT1
|
|
|
|
.It Ev LD_TRACE_LOADED_OBJECTS_FMT2
|
|
|
|
When set, these variables are interpreted as format strings a la
|
|
|
|
.Xr printf 3
|
|
|
|
to customize the trace output and are used by
|
2001-01-16 09:15:57 +00:00
|
|
|
.Xr ldd 1 Ns 's
|
Update to handle new version ld.so.hints and info in executable for
configurable fallback search paths, as well as new crt interface version.
Also:
- even faster getenv(), get all environment variable settings in a single
pass.
- ldd printf-like format specifications
- minor code cleanups, one vsprintf -> vsnprintf (harmless)
The library search sequence is a little more complete now. Before,
it'd search $LD_LIBRARY_PATH (by opendir/readdir/closedir), then read
the hints file, then read /usr/lib (again by scanning thr directory). It
would then fail if there was no "found" library.
Now, it does LD_LIBRARY_PATH and the hints file the same, but then uses
a longer fallback path. The -R path is fetched from the executable if
specified at build time, the ldconfig path is appended, and /usr/lib is
appended to that. Duplicates are suppressed. This means that simply
placing a new library in /usr/local/lib will work (the same as it did in
/usr/lib) without needing ldconfig -m. It will find it quicker if the
ldconfig is run though.
Similar changes have been made to the NetBSD ld.so, but ours is rather
different now due to John Polstra's speedups and fixes from a while back.
The ldd printf-like format support came direct from NetBSD.
Reviewed by: nate, jdp
1996-10-01 02:52:03 +01:00
|
|
|
.Fl f
|
|
|
|
option and allows
|
|
|
|
.Xr ldd 1
|
|
|
|
to be operated as a filter more conveniently.
|
2007-05-12 13:24:49 +01:00
|
|
|
If the dependency name starts with string
|
|
|
|
.Pa lib ,
|
|
|
|
.Ev LD_TRACE_LOADED_OBJECTS_FMT1
|
|
|
|
is used, otherwise
|
|
|
|
.Ev LD_TRACE_LOADED_OBJECTS_FMT2
|
|
|
|
is used.
|
Update to handle new version ld.so.hints and info in executable for
configurable fallback search paths, as well as new crt interface version.
Also:
- even faster getenv(), get all environment variable settings in a single
pass.
- ldd printf-like format specifications
- minor code cleanups, one vsprintf -> vsnprintf (harmless)
The library search sequence is a little more complete now. Before,
it'd search $LD_LIBRARY_PATH (by opendir/readdir/closedir), then read
the hints file, then read /usr/lib (again by scanning thr directory). It
would then fail if there was no "found" library.
Now, it does LD_LIBRARY_PATH and the hints file the same, but then uses
a longer fallback path. The -R path is fetched from the executable if
specified at build time, the ldconfig path is appended, and /usr/lib is
appended to that. Duplicates are suppressed. This means that simply
placing a new library in /usr/local/lib will work (the same as it did in
/usr/lib) without needing ldconfig -m. It will find it quicker if the
ldconfig is run though.
Similar changes have been made to the NetBSD ld.so, but ours is rather
different now due to John Polstra's speedups and fixes from a while back.
The ldd printf-like format support came direct from NetBSD.
Reviewed by: nate, jdp
1996-10-01 02:52:03 +01:00
|
|
|
The following conversions can be used:
|
2002-01-10 17:49:57 +00:00
|
|
|
.Bl -tag -width 4n
|
|
|
|
.It Li %a
|
Update to handle new version ld.so.hints and info in executable for
configurable fallback search paths, as well as new crt interface version.
Also:
- even faster getenv(), get all environment variable settings in a single
pass.
- ldd printf-like format specifications
- minor code cleanups, one vsprintf -> vsnprintf (harmless)
The library search sequence is a little more complete now. Before,
it'd search $LD_LIBRARY_PATH (by opendir/readdir/closedir), then read
the hints file, then read /usr/lib (again by scanning thr directory). It
would then fail if there was no "found" library.
Now, it does LD_LIBRARY_PATH and the hints file the same, but then uses
a longer fallback path. The -R path is fetched from the executable if
specified at build time, the ldconfig path is appended, and /usr/lib is
appended to that. Duplicates are suppressed. This means that simply
placing a new library in /usr/local/lib will work (the same as it did in
/usr/lib) without needing ldconfig -m. It will find it quicker if the
ldconfig is run though.
Similar changes have been made to the NetBSD ld.so, but ours is rather
different now due to John Polstra's speedups and fixes from a while back.
The ldd printf-like format support came direct from NetBSD.
Reviewed by: nate, jdp
1996-10-01 02:52:03 +01:00
|
|
|
The main program's name
|
2001-08-07 16:48:51 +01:00
|
|
|
(also known as
|
|
|
|
.Dq __progname ) .
|
2002-01-10 17:49:57 +00:00
|
|
|
.It Li \&%A
|
Update to handle new version ld.so.hints and info in executable for
configurable fallback search paths, as well as new crt interface version.
Also:
- even faster getenv(), get all environment variable settings in a single
pass.
- ldd printf-like format specifications
- minor code cleanups, one vsprintf -> vsnprintf (harmless)
The library search sequence is a little more complete now. Before,
it'd search $LD_LIBRARY_PATH (by opendir/readdir/closedir), then read
the hints file, then read /usr/lib (again by scanning thr directory). It
would then fail if there was no "found" library.
Now, it does LD_LIBRARY_PATH and the hints file the same, but then uses
a longer fallback path. The -R path is fetched from the executable if
specified at build time, the ldconfig path is appended, and /usr/lib is
appended to that. Duplicates are suppressed. This means that simply
placing a new library in /usr/local/lib will work (the same as it did in
/usr/lib) without needing ldconfig -m. It will find it quicker if the
ldconfig is run though.
Similar changes have been made to the NetBSD ld.so, but ours is rather
different now due to John Polstra's speedups and fixes from a while back.
The ldd printf-like format support came direct from NetBSD.
Reviewed by: nate, jdp
1996-10-01 02:52:03 +01:00
|
|
|
The value of the environment variable
|
2008-05-15 11:47:14 +01:00
|
|
|
.Ev LD_TRACE_LOADED_OBJECTS_PROGNAME .
|
|
|
|
Typically used to print both the names of programs and shared libraries
|
|
|
|
being inspected using
|
|
|
|
.Xr ldd 1 .
|
2002-01-10 17:49:57 +00:00
|
|
|
.It Li %o
|
1997-01-12 00:19:14 +00:00
|
|
|
The library name.
|
2002-01-10 17:49:57 +00:00
|
|
|
.It Li %p
|
Update to handle new version ld.so.hints and info in executable for
configurable fallback search paths, as well as new crt interface version.
Also:
- even faster getenv(), get all environment variable settings in a single
pass.
- ldd printf-like format specifications
- minor code cleanups, one vsprintf -> vsnprintf (harmless)
The library search sequence is a little more complete now. Before,
it'd search $LD_LIBRARY_PATH (by opendir/readdir/closedir), then read
the hints file, then read /usr/lib (again by scanning thr directory). It
would then fail if there was no "found" library.
Now, it does LD_LIBRARY_PATH and the hints file the same, but then uses
a longer fallback path. The -R path is fetched from the executable if
specified at build time, the ldconfig path is appended, and /usr/lib is
appended to that. Duplicates are suppressed. This means that simply
placing a new library in /usr/local/lib will work (the same as it did in
/usr/lib) without needing ldconfig -m. It will find it quicker if the
ldconfig is run though.
Similar changes have been made to the NetBSD ld.so, but ours is rather
different now due to John Polstra's speedups and fixes from a while back.
The ldd printf-like format support came direct from NetBSD.
Reviewed by: nate, jdp
1996-10-01 02:52:03 +01:00
|
|
|
The full pathname as determined by
|
|
|
|
.Nm rtld Ns 's
|
|
|
|
library search rules.
|
2002-01-10 17:49:57 +00:00
|
|
|
.It Li %x
|
Update to handle new version ld.so.hints and info in executable for
configurable fallback search paths, as well as new crt interface version.
Also:
- even faster getenv(), get all environment variable settings in a single
pass.
- ldd printf-like format specifications
- minor code cleanups, one vsprintf -> vsnprintf (harmless)
The library search sequence is a little more complete now. Before,
it'd search $LD_LIBRARY_PATH (by opendir/readdir/closedir), then read
the hints file, then read /usr/lib (again by scanning thr directory). It
would then fail if there was no "found" library.
Now, it does LD_LIBRARY_PATH and the hints file the same, but then uses
a longer fallback path. The -R path is fetched from the executable if
specified at build time, the ldconfig path is appended, and /usr/lib is
appended to that. Duplicates are suppressed. This means that simply
placing a new library in /usr/local/lib will work (the same as it did in
/usr/lib) without needing ldconfig -m. It will find it quicker if the
ldconfig is run though.
Similar changes have been made to the NetBSD ld.so, but ours is rather
different now due to John Polstra's speedups and fixes from a while back.
The ldd printf-like format support came direct from NetBSD.
Reviewed by: nate, jdp
1996-10-01 02:52:03 +01:00
|
|
|
The library's load address.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Additionally,
|
2002-01-10 17:49:57 +00:00
|
|
|
.Ql \en
|
Update to handle new version ld.so.hints and info in executable for
configurable fallback search paths, as well as new crt interface version.
Also:
- even faster getenv(), get all environment variable settings in a single
pass.
- ldd printf-like format specifications
- minor code cleanups, one vsprintf -> vsnprintf (harmless)
The library search sequence is a little more complete now. Before,
it'd search $LD_LIBRARY_PATH (by opendir/readdir/closedir), then read
the hints file, then read /usr/lib (again by scanning thr directory). It
would then fail if there was no "found" library.
Now, it does LD_LIBRARY_PATH and the hints file the same, but then uses
a longer fallback path. The -R path is fetched from the executable if
specified at build time, the ldconfig path is appended, and /usr/lib is
appended to that. Duplicates are suppressed. This means that simply
placing a new library in /usr/local/lib will work (the same as it did in
/usr/lib) without needing ldconfig -m. It will find it quicker if the
ldconfig is run though.
Similar changes have been made to the NetBSD ld.so, but ours is rather
different now due to John Polstra's speedups and fixes from a while back.
The ldd printf-like format support came direct from NetBSD.
Reviewed by: nate, jdp
1996-10-01 02:52:03 +01:00
|
|
|
and
|
2002-01-10 17:49:57 +00:00
|
|
|
.Ql \et
|
1997-09-13 17:01:53 +01:00
|
|
|
are recognized and have their usual meaning.
|
2007-01-23 22:38:39 +00:00
|
|
|
.It Ev LD_UTRACE
|
|
|
|
If set,
|
|
|
|
.Nm
|
|
|
|
will log events such as the loading and unloading of shared objects via
|
|
|
|
.Xr utrace 2 .
|
2010-12-25 08:51:20 +00:00
|
|
|
.It Ev LD_LOADFLTR
|
|
|
|
If set,
|
|
|
|
.Nm
|
|
|
|
will process the filtee dependencies of the loaded objects immediately,
|
|
|
|
instead of postponing it until required.
|
|
|
|
Normally, the filtees are opened at the time of the first symbol resolution
|
|
|
|
from the filter object.
|
2021-11-13 01:18:13 +00:00
|
|
|
.It Ev LD_SHOW_AUXV
|
|
|
|
If set, causes
|
|
|
|
.Nm
|
|
|
|
to dump content of the aux vector to standard output, before passing
|
|
|
|
control to any user code.
|
1995-08-26 14:17:39 +01:00
|
|
|
.El
|
2017-05-29 14:38:26 +01:00
|
|
|
.Sh DIRECT EXECUTION MODE
|
|
|
|
.Nm
|
|
|
|
is typically used implicitly, loaded by the kernel as requested by the
|
|
|
|
.Dv PT_INTERP
|
|
|
|
program header of the executed binary.
|
|
|
|
.Fx
|
|
|
|
also supports a direct execution mode for the dynamic linker.
|
|
|
|
In this mode, the user explicitly executes
|
|
|
|
.Nm
|
|
|
|
and provides the path of the program to be linked and executed as
|
|
|
|
an argument.
|
|
|
|
This mode allows use of a non-standard dynamic linker for a program
|
|
|
|
activation without changing the binary or without changing
|
|
|
|
the installed dynamic linker.
|
|
|
|
Execution options may be specified.
|
|
|
|
.Pp
|
|
|
|
The syntax of the direct invocation is
|
|
|
|
.Bd -ragged -offset indent
|
|
|
|
.Pa /libexec/ld-elf.so.1
|
2020-05-31 23:37:33 +01:00
|
|
|
.Op Fl b Ar exe
|
2021-10-11 23:26:54 +01:00
|
|
|
.Op Fl d
|
2017-05-29 14:38:26 +01:00
|
|
|
.Op Fl f Ar fd
|
|
|
|
.Op Fl p
|
2021-06-02 23:50:49 +01:00
|
|
|
.Op Fl u
|
2021-05-29 00:59:07 +01:00
|
|
|
.Op Fl v
|
2017-05-29 14:38:26 +01:00
|
|
|
.Op Fl -
|
|
|
|
.Pa image_path
|
|
|
|
.Op Ar image arguments
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2017-07-14 16:42:12 +01:00
|
|
|
The options are:
|
2017-05-29 14:38:26 +01:00
|
|
|
.Bl -tag -width indent
|
2020-05-31 23:37:33 +01:00
|
|
|
.It Fl b Ar exe
|
|
|
|
Use the executable
|
|
|
|
.Fa exe
|
|
|
|
instead of
|
|
|
|
.Fa image_path
|
|
|
|
for activation.
|
|
|
|
If this option is specified,
|
|
|
|
.Ar image_path
|
|
|
|
is only used to provide the
|
|
|
|
.Va argv[0]
|
|
|
|
value to the program.
|
2021-10-11 23:26:54 +01:00
|
|
|
.It Fl d
|
|
|
|
Turn off the emulation of the binary execute permission.
|
2017-05-29 14:38:26 +01:00
|
|
|
.It Fl f Ar fd
|
|
|
|
File descriptor
|
|
|
|
.Ar fd
|
|
|
|
references the binary to be activated by
|
|
|
|
.Nm .
|
|
|
|
It must already be opened in the process when executing
|
|
|
|
.Nm .
|
|
|
|
If this option is specified,
|
|
|
|
.Ar image_path
|
|
|
|
is only used to provide the
|
|
|
|
.Va argv[0]
|
|
|
|
value to the program.
|
|
|
|
.It Fl p
|
|
|
|
If the
|
|
|
|
.Pa image_path
|
|
|
|
argument specifies a name which does not contain a slash
|
|
|
|
.Dq Li /
|
|
|
|
character,
|
|
|
|
.Nm
|
|
|
|
uses the search path provided by the environment variable
|
|
|
|
.Dv PATH
|
|
|
|
to find the binary to execute.
|
2021-06-02 23:50:49 +01:00
|
|
|
.It Fl u
|
2021-05-29 00:59:07 +01:00
|
|
|
Ignore all
|
|
|
|
.Ev LD_
|
|
|
|
environment variables that otherwise affect the dynamic
|
|
|
|
linker behavior.
|
2020-05-31 22:53:15 +01:00
|
|
|
.It Fl v
|
|
|
|
Display information about this run-time linker binary, then exit.
|
2017-05-29 14:38:26 +01:00
|
|
|
.It Fl -
|
|
|
|
Ends the
|
|
|
|
.Nm
|
|
|
|
options.
|
|
|
|
The argument following
|
|
|
|
.Fl -
|
2017-07-14 16:42:12 +01:00
|
|
|
is interpreted as the path of the binary to execute.
|
2017-05-29 14:38:26 +01:00
|
|
|
.El
|
|
|
|
.Pp
|
2017-07-14 16:42:12 +01:00
|
|
|
In the direct execution mode,
|
2017-05-29 14:38:26 +01:00
|
|
|
.Nm
|
2017-07-14 16:42:12 +01:00
|
|
|
emulates verification of the binary execute permission for the
|
|
|
|
current user.
|
2020-10-09 16:14:19 +01:00
|
|
|
This is done to avoid breaking user expectations in naively restricted
|
2017-07-14 16:42:12 +01:00
|
|
|
execution environments.
|
2017-05-29 14:38:26 +01:00
|
|
|
The verification only uses Unix
|
|
|
|
.Dv DACs ,
|
|
|
|
ignores
|
2017-09-01 17:56:37 +01:00
|
|
|
.Dv ACLs ,
|
2017-07-14 16:42:12 +01:00
|
|
|
and is naturally prone to race conditions.
|
|
|
|
Environments which rely on such restrictions are weak
|
|
|
|
and breakable on their own.
|
2021-10-11 23:26:54 +01:00
|
|
|
It can be turned off with the
|
|
|
|
.Fl d
|
|
|
|
option.
|
Add version indicators to rtld.
It is wrong to relate on __FreeBSD_version, either from
include/param.h, kernel, or libc, to check for rtld features.
Rtld might be from newer world than the running userspace.
Add special private symbols exported by rtld itself, to indicate the
changes in runtime behavior, and features that cannot be otherwise
detected or deduced at runtime.
Note that the symbols are not exported from libc, so they intentionally
cannot be linked against, and exported from the private namespace from rtld.
Consumers are required to use dlsym(3). For instance, for
_rtld_version_laddr_offset, user should do
ptr = dlsym(RTLD_DEFAULT, "_rtld_version_laddr_offset")
or even
ptr = dlvsym(RTLD_DEFAULT, "_rtld_version_laddr_offset",
"FBSDprivate_1.0");
Non-null ptr means that the change is present.
Also add _rtld_version__FreeBSD_version indicator to report the
headers version used at time of the rtld build.
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D24982
2020-05-26 20:22:46 +01:00
|
|
|
.Sh VERSIONING
|
|
|
|
Newer
|
|
|
|
.Nm
|
|
|
|
might provide some features or changes in runtime behavior that cannot be
|
|
|
|
easily detected at runtime by checking of the normal exported symbols.
|
|
|
|
Note that it is almost always wrong to verify
|
|
|
|
.Dv __FreeBSD_version
|
|
|
|
in userspace to detect features, either at compile or at run time,
|
|
|
|
because either kernel, or libc, or environment variables could not
|
|
|
|
match the running
|
|
|
|
.Nm .
|
|
|
|
.Pp
|
|
|
|
To solve the problem,
|
|
|
|
.Nm
|
|
|
|
exports some feature indicators in the
|
|
|
|
.Fx
|
|
|
|
private symbols namespace
|
|
|
|
.Dv FBSDprivate_1.0 .
|
|
|
|
Symbols start with the
|
|
|
|
.Dv _rtld_version
|
|
|
|
prefix.
|
|
|
|
Current list of defined symbols and corresponding features is:
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Dv _rtld_version__FreeBSD_version
|
|
|
|
Symbol exports the value of the
|
|
|
|
.Dv __FreeBSD_version
|
|
|
|
definition as it was provided during the
|
|
|
|
.Nm
|
|
|
|
build.
|
|
|
|
The symbol is always present since the
|
|
|
|
.Dv _rtld_version
|
|
|
|
facility was introduced.
|
|
|
|
.It Dv _rtld_version_laddr_offset
|
|
|
|
The
|
|
|
|
.Va l_addr
|
|
|
|
member of the
|
|
|
|
.Vt link_map
|
|
|
|
structure contains the load offset of the shared object.
|
|
|
|
Before that,
|
|
|
|
.Va l_addr
|
|
|
|
contained the base address of the library.
|
|
|
|
See
|
|
|
|
.Xr dlinfo 3 .
|
|
|
|
.Pp
|
|
|
|
Also it indicates the presence of
|
|
|
|
.Va l_refname
|
|
|
|
member of the structure.
|
2021-04-05 04:05:44 +01:00
|
|
|
.It Dv _rtld_version_dlpi_tls_data
|
|
|
|
The
|
|
|
|
.Va dlpi_tls_data
|
|
|
|
member of the structure
|
|
|
|
.Vt dl_phdr_info
|
|
|
|
contains the address of the module TLS segment for the calling thread,
|
|
|
|
and not the address of the initialization segment.
|
Add version indicators to rtld.
It is wrong to relate on __FreeBSD_version, either from
include/param.h, kernel, or libc, to check for rtld features.
Rtld might be from newer world than the running userspace.
Add special private symbols exported by rtld itself, to indicate the
changes in runtime behavior, and features that cannot be otherwise
detected or deduced at runtime.
Note that the symbols are not exported from libc, so they intentionally
cannot be linked against, and exported from the private namespace from rtld.
Consumers are required to use dlsym(3). For instance, for
_rtld_version_laddr_offset, user should do
ptr = dlsym(RTLD_DEFAULT, "_rtld_version_laddr_offset")
or even
ptr = dlvsym(RTLD_DEFAULT, "_rtld_version_laddr_offset",
"FBSDprivate_1.0");
Non-null ptr means that the change is present.
Also add _rtld_version__FreeBSD_version indicator to report the
headers version used at time of the rtld build.
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D24982
2020-05-26 20:22:46 +01:00
|
|
|
.El
|
1995-08-26 14:17:39 +01:00
|
|
|
.Sh FILES
|
2006-03-27 01:53:58 +01:00
|
|
|
.Bl -tag -width ".Pa /var/run/ld-elf32.so.hints" -compact
|
2000-12-20 13:26:01 +00:00
|
|
|
.It Pa /var/run/ld-elf.so.hints
|
2003-05-16 22:34:21 +01:00
|
|
|
Hints file.
|
2006-03-27 01:53:58 +01:00
|
|
|
.It Pa /var/run/ld-elf32.so.hints
|
|
|
|
Hints file for 32-bit binaries on 64-bit system.
|
2003-04-07 17:21:26 +01:00
|
|
|
.It Pa /etc/libmap.conf
|
2003-05-16 22:34:21 +01:00
|
|
|
The libmap configuration file.
|
2006-03-27 01:53:58 +01:00
|
|
|
.It Pa /etc/libmap32.conf
|
|
|
|
The libmap configuration file for 32-bit binaries on 64-bit system.
|
2000-12-20 13:26:01 +00:00
|
|
|
.El
|
1995-08-26 14:17:39 +01:00
|
|
|
.Sh SEE ALSO
|
1996-09-23 23:24:39 +01:00
|
|
|
.Xr ld 1 ,
|
2000-03-28 10:01:04 +01:00
|
|
|
.Xr ldd 1 ,
|
Add version indicators to rtld.
It is wrong to relate on __FreeBSD_version, either from
include/param.h, kernel, or libc, to check for rtld features.
Rtld might be from newer world than the running userspace.
Add special private symbols exported by rtld itself, to indicate the
changes in runtime behavior, and features that cannot be otherwise
detected or deduced at runtime.
Note that the symbols are not exported from libc, so they intentionally
cannot be linked against, and exported from the private namespace from rtld.
Consumers are required to use dlsym(3). For instance, for
_rtld_version_laddr_offset, user should do
ptr = dlsym(RTLD_DEFAULT, "_rtld_version_laddr_offset")
or even
ptr = dlvsym(RTLD_DEFAULT, "_rtld_version_laddr_offset",
"FBSDprivate_1.0");
Non-null ptr means that the change is present.
Also add _rtld_version__FreeBSD_version indicator to report the
headers version used at time of the rtld build.
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D24982
2020-05-26 20:22:46 +01:00
|
|
|
.Xr dlinfo 3 ,
|
2014-06-20 18:08:32 +01:00
|
|
|
.Xr capsicum 4 ,
|
2001-07-06 17:46:48 +01:00
|
|
|
.Xr elf 5 ,
|
2003-05-17 20:46:49 +01:00
|
|
|
.Xr libmap.conf 5 ,
|
1997-01-13 00:25:51 +00:00
|
|
|
.Xr ldconfig 8
|