xref: /freebsd/sbin/ldconfig/ldconfig.8 (revision 23f282aa31e9b6fceacd449020e936e98d6f2298)
1.\"
2.\" Copyright (c) 1993 Paul Kranenburg
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\"    must display the following acknowledgement:
15.\"      This product includes software developed by Paul Kranenburg.
16.\" 3. The name of the author may not be used to endorse or promote products
17.\"    derived from this software without specific prior written permission
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" $FreeBSD$
31.\"
32.Dd October 3, 1993
33.Dt LDCONFIG 8
34.Os FreeBSD
35.Sh NAME
36.Nm ldconfig
37.Nd configure the shared library cache
38.Sh SYNOPSIS
39.Nm ldconfig
40.Op Fl aout | Fl elf
41.Op Fl Rmrsv
42.Op Fl f Ar hints_file
43.Op Ar directory | file Ar ...
44.Sh DESCRIPTION
45.Nm
46is used to prepare a set of
47.Dq hints
48for use by the dynamic linker
49to facilitate quick lookup of shared libraries available in multiple
50directories.  It scans a set of built-in system directories and any
51.Ar directories
52specified on the command line (in the given order) looking for
53shared libraries and stores the results in a system file to forestall
54the overhead that would otherwise result from the directory search
55operations the dynamic linker would have to perform to load the
56required shared libraries.
57.Pp
58Files named on the command line are expected to contain directories
59to scan for shared libraries.  Each directory's pathname must start on a new
60line.  Blank lines and lines starting with the comment character
61.Ql \&#
62are ignored.
63.Pp
64The shared libraries so found will be automatically available for loading
65if needed by the program being prepared for execution.
66This obviates the need
67for storing search paths within the executable.
68.Pp
69The
70.Ev LD_LIBRARY_PATH
71environment variable can be used to override the use of
72directories (or the order thereof) from the cache or to specify additional
73directories where shared libraries might be found.
74.Ev LD_LIBRARY_PATH
75is a
76.Sq \:
77separated list of directory paths which are searched by
78the dynamic linker
79when it needs to load a shared library.
80It can be viewed as the run-time
81equivalent of the
82.Fl L
83switch of
84.Xr ld 1 .
85.Pp
86.Nm Ldconfig
87is typically run as part of the boot sequence.
88.Pp
89The following options recognized by
90.Nm ldconfig:
91.Bl -tag -width indent
92.It Fl aout
93Generate the hints for a.out format shared libraries.
94.It Fl elf
95Generate the hints for ELF format shared libraries.
96.It Fl R
97Rescan the previously configured directories.  This opens the previous hints
98file and fetches the directory list from the header.  Any additional pathnames
99on the command line are also processed.
100.It Fl f Ar hints_file
101Read and/or update the specified hints file, instead of the standard file.
102This option is provided primarily for testing.
103.It Fl m
104Instead of replacing the contents of the hints file
105with those found in the directories specified,
106.Dq merge
107in new entries.
108Directories recorded in the hints file by previous runs of
109.Nm
110are also rescanned for new shared libraries.
111.It Fl r
112List the current contents of the hints file
113on the standard output.
114The hints file is not modified.  The list of
115directories stored in the hints file is included.
116.It Fl s
117Do not scan the built-in system directory
118.Pq Dq /usr/lib
119for shared libraries.
120.It Fl v
121Switch on verbose mode.
122.Sh Security
123Special care must be taken when loading shared libraries into the address
124space of
125.Ev set-user-Id
126programs.
127Whenever such a program is run,
128the dynamic linker
129will only load shared libraries from the hints
130file.
131In particular, the
132.Ev LD_LIBRARY_PATH
133is not used to search for libraries.
134Thus, the role of ldconfig is dual.
135In
136addition to building a set of hints for quick lookup, it also serves to
137specify the trusted collection of directories from which shared objects can
138be safely loaded.
139It is presumed that the set of directories specified to
140.Nm ldconfig
141are under control of the system's administrator.
142.Sh ENVIRONMENT
143.Bl -tag -width OBJFORMATxxx -compact
144.It Ev OBJFORMAT
145Overrides
146.Pa /etc/objformat
147(see below) to determine whether
148.Fl aout
149or
150.Fl elf
151is the default.  If set, its value should be either
152.Ql aout
153or
154.Ql elf .
155.El
156.Sh FILES
157.Bl -tag -width /var/run/ld-elf.so.hintsxxx -compact
158.It Pa /var/run/ld.so.hints
159Standard hints file for the a.out dynamic linker.
160.It Pa /var/run/ld-elf.so.hints
161Standard hints file for the ELF dynamic linker.
162.It Pa /etc/ld.so.conf
163Conventional configuration file containing directory names for
164invocations with
165.Fl aout .
166.It Pa /etc/ld-elf.so.conf
167Conventional configuration file containing directory names for
168invocations with
169.Fl elf .
170.It Pa /etc/objformat
171Determines whether
172.Fl aout
173or
174.Fl elf
175is the default.  If present, it must consist of a single line
176containing either
177.Ql OBJFORMAT=aout
178or
179.Ql OBJFORMAT=elf .
180.Sh SEE ALSO
181.Xr ld 1 ,
182.Xr link 5
183.Sh HISTORY
184A
185.Nm
186utility first appeared in SunOS 4.0, it appeared in its current form
187in FreeBSD 1.1.
188