ldd.1, sprof.1, execve.2, dlopen.3, ld.so.8: Prefer "shared object" over "shared library"

The man pages variously use "shared library" or "shared object".
Try to more consistently use one term ("shared object"), while
also pointing out on a few pages that the terms are synonymous.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2015-07-10 20:37:59 +02:00
parent b5d07fd924
commit 43151de329
5 changed files with 103 additions and 98 deletions

View File

@ -13,13 +13,13 @@
.\"
.TH LDD 1 2015-03-29 "" "Linux Programmer's Manual"
.SH NAME
ldd \- print shared library dependencies
ldd \- print shared object dependencies
.SH SYNOPSIS
.BR ldd " [\fIoption\fP]... \fIfile\fP..."
.SH DESCRIPTION
.B ldd
prints the shared libraries required by each program or shared library
specified on the command line.
prints the shared objects (shared libraries) required by each program or
shared object specified on the command line.
.SS Security
In the usual case,
.B ldd

View File

@ -34,7 +34,7 @@ sprof \- read and display shared object profiling data
The
.B sprof
command displays a profiling summary for the
shared object specified as its first command-line argument.
shared object (shared library) specified as its first command-line argument.
The profiling summary is created using previously generated
profiling data in the (optional) second command-line argument.
If the profiling data pathname is omitted, then
@ -80,7 +80,7 @@ command is a GNU extension, not present in POSIX.1.
The following example demonstrates the use of
.BR sprof .
The example consists of a main program that calls two functions
in a shared library.
in a shared object.
First, the code of the main program:
.in +4n
@ -106,7 +106,7 @@ The functions
and
.IR x2()
are defined in the following source file that is used to
construct the shared library:
construct the shared object:
.in +4n
.nf
@ -150,7 +150,7 @@ x2(void)
.fi
.in
.PP
Now we construct the shared library with the real name
Now we construct the shared object with the real name
.IR libdemo.so.1.0.1 ,
and the soname
.IR libdemo.so.1 :
@ -172,7 +172,7 @@ $ \fBln \-sf libdemo.so.1 libdemo.so\fP
.fi
.in
.PP
Next, we compile the main program, linking it against the shared library,
Next, we compile the main program, linking it against the shared object,
and then list the dynamic dependencies of the program:
.in +4n
@ -186,7 +186,7 @@ $ \fBldd prog\fP
.fi
.in
.PP
In order to get profiling information for the shared library,
In order to get profiling information for the shared object,
we define the environment variable
.BR LD_PROFILE
with the soname of the library:

View File

@ -106,12 +106,12 @@ binary executable containing
shared-library stubs, the Linux dynamic linker
.BR ld.so (8)
is called at the start of execution to bring
needed shared libraries into memory
needed shared objects into memory
and link the executable with them.
If the executable is a dynamically linked ELF executable, the
interpreter named in the PT_INTERP segment is used to load the needed
shared libraries.
shared objects.
This interpreter is typically
.I /lib/ld-linux.so.2
for binaries linked with glibc.

View File

@ -76,10 +76,11 @@ it was last called.
.SS dlopen()
The function
.BR dlopen ()
loads the dynamic library file named by the null-terminated
loads the dynamic shared object (shared library)
file named by the null-terminated
string
.I filename
and returns an opaque "handle" for the dynamic library.
and returns an opaque "handle" for the loaded object.
If
.I filename
is NULL, then the returned handle is for the main program.
@ -87,7 +88,7 @@ If
.I filename
contains a slash ("/"), then it is interpreted as a (relative
or absolute) pathname.
Otherwise, the dynamic linker searches for the library as follows
Otherwise, the dynamic linker searches for the object as follows
(see
.BR ld.so (8)
for further details):
@ -120,11 +121,13 @@ and
.I /usr/lib
are searched (in that order).
.PP
If the library has dependencies on other shared libraries,
If the object specified by
.I filename
has dependencies on other shared objects,
then these are also automatically loaded by the dynamic linker
using the same rules.
(This process may occur recursively,
if those libraries in turn have dependencies, and so on.)
if those objects in turn have dependencies, and so on.)
.PP
One of the following two values must be included in
.IR flags :
@ -135,13 +138,13 @@ Only resolve symbols as the code that references them is executed.
If the symbol is never referenced, then it is never resolved.
(Lazy binding is performed only for function references;
references to variables are always immediately bound when
the library is loaded.)
the shared object is loaded.)
.TP
.B RTLD_NOW
If this value is specified, or the environment variable
.B LD_BIND_NOW
is set to a nonempty string,
all undefined symbols in the library are resolved before
all undefined symbols in the shared object are resolved before
.BR dlopen ()
returns.
If this cannot be done, an error is returned.
@ -150,34 +153,34 @@ Zero or more of the following values may also be ORed in
.IR flags :
.TP
.B RTLD_GLOBAL
The symbols defined by this library will be
made available for symbol resolution of subsequently loaded libraries.
The symbols defined by this shared object will be
made available for symbol resolution of subsequently loaded shared object.
.TP
.B RTLD_LOCAL
This is the converse of
.BR RTLD_GLOBAL ,
and the default if neither flag is specified.
Symbols defined in this library are not made available to resolve
references in subsequently loaded libraries.
Symbols defined in this shared object are not made available to resolve
references in subsequently loaded shared objects.
.TP
.BR RTLD_NODELETE " (since glibc 2.2)"
Do not unload the library during
Do not unload the shared object during
.BR dlclose ().
Consequently, the library's static variables are not reinitialized
if the library is reloaded with
Consequently, the object's static variables are not reinitialized
if the object is reloaded with
.BR dlopen ()
at a later time.
This flag is not specified in POSIX.1-2001.
.\" (But it is present on Solaris.)
.TP
.BR RTLD_NOLOAD " (since glibc 2.2)"
Don't load the library.
This can be used to test if the library is already resident
Don't load the shared object.
This can be used to test if the object is already resident
.RB ( dlopen ()
returns NULL if it is not, or the library's handle if it is resident).
This flag can also be used to promote the flags on a library
returns NULL if it is not, or the object's handle if it is resident).
This flag can also be used to promote the flags on a shared object
that is already loaded.
For example, a library that was previously loaded with
For example, a shared object that was previously loaded with
.B RTLD_LOCAL
can be reopened with
.BR RTLD_NOLOAD\ |\ RTLD_GLOBAL .
@ -189,10 +192,10 @@ This flag is not specified in POSIX.1-2001.
.\" Inimitably described by UD in
.\" http://sources.redhat.com/ml/libc-hacker/2004-09/msg00083.html.
Place the lookup scope of the symbols in this
library ahead of the global scope.
This means that a self-contained library will use
shared object ahead of the global scope.
This means that a self-contained object will use
its own symbols in preference to global symbols with the same name
contained in libraries that have already been loaded.
contained in objects that have already been loaded.
This flag is not specified in POSIX.1-2001.
.PP
If
@ -201,27 +204,27 @@ is NULL, then the returned handle is for the main program.
When given to
.BR dlsym (),
this handle causes a search for a symbol in the main program,
followed by all shared libraries loaded at program startup,
and then all shared libraries loaded by
followed by all shared objects loaded at program startup,
and then all shared objects loaded by
.BR dlopen ()
with the flag
.BR RTLD_GLOBAL .
.PP
External references in the library are resolved using the libraries
in that library's dependency list and any other libraries previously
opened with the
External references in the shared object are resolved using the
shared objects in that object's dependency list and any other
objects previously opened with the
.B RTLD_GLOBAL
flag.
If the executable was linked with the flag "\-rdynamic"
(or, synonymously, "\-\-export\-dynamic"),
then the global symbols in the executable will also be used
to resolve references in a dynamically loaded library.
to resolve references in a dynamically loaded shared object.
.PP
If the same library is loaded again with
If the same shared object is loaded again with
.BR dlopen (),
the same library handle is returned.
the same object handle is returned.
The dl library maintains reference
counts for library handles, so a dynamic library is not
counts for object handles, so a dynamically loaded shared object is not
deallocated until
.BR dlclose ()
has been called on it as many times as
@ -288,20 +291,20 @@ The glibc implementation supports a maximum of
.SS dlsym()
The function
.BR dlsym ()
takes a "handle" of a dynamic library returned by
takes a "handle" of a dynamic loaded shared object returned by
.BR dlopen ()
and the
null-terminated symbol name, returning the address where that symbol is
loaded into memory.
If the symbol is not found, in the specified
library or any of the libraries that were automatically loaded by
object or any of the shared objects that were automatically loaded by
.BR dlopen ()
when that library was loaded,
when that object was loaded,
.BR dlsym ()
returns NULL.
(The search performed by
.BR dlsym ()
is breadth first through the dependency tree of these libraries.)
is breadth first through the dependency tree of these shared objects.)
Since the value of the symbol could actually be NULL (so that a
NULL return from
.BR dlsym ()
@ -319,24 +322,24 @@ There are two special pseudo-handles:
.TP
.B RTLD_DEFAULT
Find the first occurrence of the desired symbol
using the default library search order.
using the default shared object search order.
The search will include global symbols in the executable
and its dependencies,
as well as symbols in libraries that were dynamically loaded with the
as well as symbols in shared objects that were dynamically loaded with the
.BR RTLD_GLOBAL
flag.
.TP
.BR RTLD_NEXT
Find the next occurrence of the desired symbol in the search order
after the current library.
after the current object.
This allows one to provide a wrapper
around a function in another shared library, so that, for example,
the definition of a function in a preloaded library
around a function in another shared object, so that, for example,
the definition of a function in a preloaded shared object
(see
.B LD_PRELOAD
in
.BR ld.so (8))
can find and invoke the "real" function provided in another library
can find and invoke the "real" function provided in another shared object
(or for that matter, the "next" definition of the function in cases
where there are multiple layers of preloading).
.SS dlvsym()
@ -348,10 +351,11 @@ but takes a version string as an additional argument.
.SS dlclose()
The function
.BR dlclose ()
decrements the reference count on the dynamic library handle
decrements the reference count on the
dynamically loaded shared object referred to by
.IR handle .
If the reference count drops to zero,
then the dynamic library is unloaded.
then the object is unloaded.
All shared objects that were automatically loaded when
.BR dlopen ()
was invoked on the object referred to by
@ -366,14 +370,14 @@ The linker recognizes special symbols
.B _init
and
.BR _fini .
If a dynamic library exports a routine named
If a dynamically loaded shared object exports a routine named
.BR _init (),
then that code is executed after the loading, before
.BR dlopen ()
returns.
If the dynamic library exports a routine named
If the shared object exports a routine named
.BR _fini (),
then that routine is called just before the library is unloaded.
then that routine is called just before the object is unloaded.
In case you need to avoid linking against the system startup files,
this can be done by using the
.BR gcc (1)
@ -391,7 +395,7 @@ since the constructor/destructor routines will not be executed
.\" void _init(void) __attribute__((constructor));
.\" void _fini(void) __attribute__((destructor));
.LP
Instead, libraries should export routines using the
Instead, shared objects should export routines using the
.B __attribute__((constructor))
and
.B __attribute__((destructor))
@ -448,7 +452,7 @@ was defined before including it.
Since glibc 2.2.3,
.BR atexit (3)
can be used to register an exit handler that is automatically
called when a library is unloaded.
called when a shared object is unloaded.
.\"
.SS dlmopen() and namespaces
A link-map list defines an isolated namespace for the
@ -473,7 +477,7 @@ since it prevents a shared object's symbols from being available to
other shared object.
In some cases,
we may want to make the symbols provided by a dynamically
loaded library available to (a subset of) other shared objects
loaded shared object available to (a subset of) other shared objects
without exposing those symbols to the entire application.
This can be achieved by using a separate namespace and the
.B RTLD_GLOBAL
@ -563,7 +567,7 @@ with the following command:
gcc \-rdynamic \-o foo foo.c \-ldl
.in
.PP
Libraries exporting (the obsolete)
Shared objects exporting (the obsolete)
.BR _init ()
and
.BR _fini ()

View File

@ -7,7 +7,8 @@
ld.so, ld-linux.so* \- dynamic linker/loader
.SH SYNOPSIS
The dynamic linker can be run either indirectly by running some
dynamically linked program or library (in which case no command-line options
dynamically linked program or shared object
(in which case no command-line options
to the dynamic linker can be passed and, in the ELF case, the dynamic linker
which is stored in the
.B .interp
@ -20,8 +21,8 @@ The programs
.B ld.so
and
.B ld-linux.so*
find and load the shared libraries needed by a program, prepare
the program to run, and then run it.
find and load the shared objects (shared libraries) needed by a program,
prepare the program to run, and then run it.
.LP
Linux binaries require dynamic linking (linking at run time)
unless the
@ -43,15 +44,15 @@ support files and programs
and
.IR /etc/ld.so.conf .
.LP
When resolving library dependencies,
When resolving shared object dependencies,
the dynamic linker first inspects each dependency
string to see if it contains a slash (this can occur if
a library pathname containing slashes was specified at link time).
a shared object pathname containing slashes was specified at link time).
If a slash is found, then the dependency string is interpreted as
a (relative or absolute) pathname,
and the library is loaded using that pathname.
and the shared object is loaded using that pathname.
.LP
If a library dependency does not contain a slash,
If a shared object dependency does not contain a slash,
then it is searched for in the following order:
.IP o 3
(ELF only) Using the directories specified in the
@ -70,19 +71,19 @@ of the binary if present.
.IP o
From the cache file
.IR /etc/ld.so.cache ,
which contains a compiled list of candidate libraries previously found
which contains a compiled list of candidate shared objects previously found
in the augmented library path.
If, however, the binary was linked with the
.B \-z nodeflib
linker option, libraries in the default library paths are skipped.
Libraries installed in hardware capability directories (see below)
are preferred to other libraries.
linker option, shared objects in the default paths are skipped.
Shared objects installed in hardware capability directories (see below)
are preferred to other shared objects.
.IP o
In the default path
.IR /lib ,
and then
.IR /usr/lib .
(On some 64-bit archiectures, the default paths for 64-bit libraries are
(On some 64-bit archiectures, the default paths for 64-bit shared objects are
.IR /lib64 ,
and then
.IR /usr/lib64 .)
@ -96,14 +97,14 @@ understands certain strings in an rpath specification (DT_RPATH or DT_RUNPATH);
.TP
.IR $ORIGIN " (or equivalently " ${ORIGIN} )
This expands to
the directory containing the program or shared library.
the directory containing the program or shared object.
Thus, an application located in
.I somedir/app
could be compiled with
gcc \-Wl,\-rpath,\(aq$ORIGIN/../lib\(aq
so that it finds an associated shared library in
so that it finds an associated shared object in
.I somedir/lib
no matter where
.I somedir
@ -111,7 +112,7 @@ is located in the directory hierarchy.
This facilitates the creation of "turn-key" applications that
do not need to be installed into special directories,
but can instead be unpacked into any directory
and still find their own shared libraries.
and still find their own shared objects.
.TP
.IR $LIB " (or equivalently " ${LIB} )
This expands to
@ -178,7 +179,7 @@ Among the more important environment variables are the following:
.TP
.B LD_ASSUME_KERNEL
(glibc since 2.2.3)
Each shared library can inform the dynamic linker of the minimum kernel ABI
Each shared object can inform the dynamic linker of the minimum kernel ABI
version that it requires.
(This requirement is encoded in an ELF note section that is viewable via
.IR "readelf\ \-n"
@ -186,7 +187,7 @@ as a section labeled
.BR NT_GNU_ABI_TAG .)
At run time,
the dynamic linker determines the ABI version of the running kernel and
will reject loading shared libraries that specify minimum ABI versions
will reject loading shared objects that specify minimum ABI versions
that exceed that ABI version.
.BR LD_ASSUME_KERNEL
@ -195,7 +196,7 @@ cause the dynamic linker to assume that it is running on a system with
a different kernel ABI version.
For example, the following command line causes the
dynamic linker to assume it is running on Linux 2.2.5 when loading
the shared libraries required by
the shared objects required by
.IR myprog :
.in +4n
@ -204,11 +205,11 @@ $ \fBLD_ASSUME_KERNEL=2.2.5 ./myprog\fP
.fi
.in
On systems that provide multiple versions of a shared library
On systems that provide multiple versions of a shared object
(in different directories in the search path) that have
different minimum kernel ABI version requirements,
.BR LD_ASSUME_KERNEL
can be used to select the version of the library that is used
can be used to select the version of the object that is used
(dependent on the directory search order).
Historically, the most common use of the
.BR LD_ASSUME_KERNEL
@ -238,18 +239,18 @@ Ignored in set-user-ID and set-group-ID programs.
.TP
.B LD_PRELOAD
A list of additional, user-specified, ELF shared
libraries to be loaded before all others.
objects to be loaded before all others.
The items of the list can be separated by spaces or colons.
This can be used to selectively override functions in other shared libraries.
The libraries are searched for using the rules given under DESCRIPTION.
This can be used to selectively override functions in other shared objects.
The objects are searched for using the rules given under DESCRIPTION.
For set-user-ID/set-group-ID ELF binaries,
preload pathnames containing slashes are ignored,
and libraries in the standard search directories are loaded
only if the set-user-ID mode bit is enabled on the library file.
and shared objects in the standard search directories are loaded
only if the set-user-ID mode bit is enabled on the shared object file.
.TP
.B LD_TRACE_LOADED_OBJECTS
(ELF only)
If set to a nonempty string, causes the program to list its dynamic library
If set to a nonempty string, causes the program to list its dynamic
dependencies, as if run by
.BR ldd (1),
instead of running normally.
@ -279,15 +280,15 @@ A colon-separated list of user-specified, ELF shared objects
to be loaded before all others in a separate linker namespace
(i.e., one that does not intrude upon the normal symbol bindings that
would occur in the process).
These libraries can be used to audit the operation of the dynamic linker.
These objects can be used to audit the operation of the dynamic linker.
.B LD_AUDIT
is ignored for set-user-ID/set-group-ID binaries.
The dynamic linker will notify the audit
libraries at so-called auditing checkpoints\(emfor example,
loading a new library, resolving a symbol,
shared objects at so-called auditing checkpoints\(emfor example,
loading a new shared object, resolving a symbol,
or calling a symbol from another shared object\(emby
calling an appropriate function within the audit library.
calling an appropriate function within the audit shared object.
For details, see
.BR rtld-audit (7).
The auditing interface is largely compatible with that provided on Solaris,
@ -409,7 +410,7 @@ then all prelinking activity is traced.
.\" Jakub Jelinek
By default (i.e., if this variable is not defined),
executables and prelinked
shared objects will honor base addresses of their dependent libraries
shared objects will honor base addresses of their dependent shared objects
and (nonprelinked) position-independent executables (PIEs)
and other shared objects will not honor them.
If
@ -451,14 +452,14 @@ ELF dynamic linker/loader
.TP
.I /etc/ld.so.cache
File containing a compiled list of directories in which to search for
libraries and an ordered list of candidate libraries.
shared objects and an ordered list of candidate shared objects.
.TP
.I /etc/ld.so.preload
File containing a whitespace-separated list of ELF shared libraries to
File containing a whitespace-separated list of ELF shared objects to
be loaded before the program.
.TP
.B lib*.so*
shared libraries
shared objects
.PD
.SH NOTES
The
@ -467,13 +468,13 @@ functionality is available for executables compiled using libc version
4.4.3 or greater.
ELF functionality is available since Linux 1.1.52 and libc5.
.SS Hardware capabilities
Some libraries are compiled using hardware-specific instructions which do
Some shared objects are compiled using hardware-specific instructions which do
not exist on every CPU.
Such libraries should be installed in directories whose names define the
Such objects should be installed in directories whose names define the
required hardware capabilities, such as
.IR /usr/lib/sse2/ .
The dynamic linker checks these directories against the hardware of the
machine and selects the most suitable version of a given library.
machine and selects the most suitable version of a given shared object.
Hardware capability directories can be cascaded to combine CPU features.
The list of supported hardware capability names depends on the CPU.
The following names are currently recognized: