History log of /freebsd-current/sbin/ldconfig/ldconfig.c
Revision Date Author Comments
# 484de86f 01-Mar-2024 Stefan Eßer <se@FreeBSD.org>

ldconfig: remove ignored -v (verbose) option

The -v option used to print useful information when operating on a.out
format libraries. After the removal of a.out support, it was accepted
but did not have any effect.

Remove the option and update the man-page.

While here mention the set of historic options that are accepted but
ignored: "-elf", "-s", and "-v".

The FILES section contained outdated information and did not mention
the way library directories of optional ports and packages are
included in the library search path recorded in the hints file.

The description of the "-B" option was incorrect (described a planned
change) for big-endian platforms (powerpc64). These do still default
to big-endian hints files, since the current version of the "pkg"
program expects the hints file to be in native byte-order.

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D44139


# e0dfecad 28-Feb-2024 Stefan Eßer <se@FreeBSD.org>

ldconfig: support hints files of either byte-order

Make the ldconfig program accept hints files in little-endian and
big-endian format on all architectures.

The default format is the native byte-order of the respective host.
This is expected to change when a version of the pkg command is
available that implements support for either byte-order in its
internal ldconfig function. (Already committed in the development
tree of the pkg utility, a release is expected at the end of Q1/2024).

This update adds the -B option to the ldconfig program. It enforces
the creation of a big-endian hints file on a little-endian host.
The main purpose to is support of tests with non-native byte-order
files on little-endian hosts. It will be removed when all supported
FreeBSD releases use little-endian hints files by default.

When little-endian hints files are generally used, support of
either byte-order in libexec/rtld can also be removed.

When support for big-endian hints files is no longer required,
the COND_SWAP macro in ldconfig and rtld shall be replaced by
le32toh(), which just return their argument on little-endian
architectures.

Approved by: kib
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D44093


# 1e635e87 09-Jul-2023 Jessica Clarke <jrtc27@FreeBSD.org>

ldconfig: Use __PATH_ELF_HINTS("32") over _PATH_ELF32_HINTS

This will allow the latter to be removed, reducing the boilerplate
needed for a new libcompat.

Reviewed by: kib, brooks, jhb
Differential Revision: https://reviews.freebsd.org/D40933


# 65f3be91 07-Jul-2023 Alfonso Gregory <gfunni234@gmail.com>

Mark usage function as __dead2 in programs where it does not return

In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735


# fcbb1441 07-Jan-2022 Konstantin Belousov <kib@FreeBSD.org>

ldconfig: remove two symbols

_PATH_LD32_HINTS is unused because it is a.out remnant.
_PATH_ELF32_HINTS is provided by rtld_paths.h already.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 8b7cc20f 06-Jan-2022 Warner Losh <imp@FreeBSD.org>

ldconfig: remove libsoft support

Remove support for -soft and its implementation. This arg was never
documented, so no need to remove it from the man page.

Sponsored by: Netflix


# 3ede04c7 18-Nov-2021 Konstantin Belousov <kib@FreeBSD.org>

ldconfig(8): check for no-args command line after options are parsed

Default action for ldconfig is specified as -R AKA 'append', and for
no-args (without options changing default actions), ldconfig should
append empty list of directories to current list. But because the check
was done before options were parsed out, presence of any option turned
off default rescan.

As result, innocently-looked commands like `ldconfig -v' were interpreted
as setting directory hints list to one specified on the command line,
i.e. empty.

Reported by: https://github.com/mesonbuild/meson/issues/9592
Reviewed by: emaste
Tested by: jbeich
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33058


# af911587 18-Nov-2021 Konstantin Belousov <kib@FreeBSD.org>

ldconfig: use libexec/rtld-elf/rtld_paths.h

instead of duplicating definitions using slighly different macro names.

Reviewed by: emaste
Tested by: jbeich
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33058


# b828161d 18-Nov-2021 Konstantin Belousov <kib@FreeBSD.org>

ldconfig(8): nostd/-s does nothing

Remove the option from man page and summary. Silently ignore it when
parsing command line for backward compatibility.

Reviewed by: emaste
Tested by: jbeich
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33058


# 3f2c6f55 18-Nov-2021 Konstantin Belousov <kib@FreeBSD.org>

ldconfig: start of cleanup

Use bool.
Use local variables instead of static.
Remove non-functional debugging override of hints file path.
Use explicit exit() instead of return from main.
Minor style tweaks.

Reviewed by: emaste
Tested by: jbeich
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33058


# 83511ce5 24-Nov-2021 Konstantin Belousov <kib@FreeBSD.org>

ldconfig: remove a comment which is another remnant of a.out support

Noted and reviewed by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33058


# 50a40d09 31-Dec-2020 Ed Maste <emaste@FreeBSD.org>

ldconfig: Retire a.out support

aout support in ldconfig hasn't been required since FreeBSD 2.x.
If someone needs to use FreeBSD 2 shared libraries they will be best
served by using a FreeBSD 2 ldconfig as well.

In aa5e1b42e6e3 we removed the ldconfig a.out invocation from rc.d but
left the support in ldconfig itself. Remove it now.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27481


# 2ee11faa 17-Mar-2020 Ed Maste <emaste@FreeBSD.org>

ldconfig: add aout deprecation notice

aout support in ldconfig hasn't been required since FreeBSD 2.x.
Anyone still using FreeBSD 2 shared libraries can also use a FreeBSD 2
ldconfig to generate aout ldconfig hints.

Sponsored by: The FreeBSD Foundation


# 30822483 09-Aug-2018 Edward Tomasz Napierala <trasz@FreeBSD.org>

Make ldconfig(8) atomic, by removing an unneccessary call to unlink(2)
before rename(2).

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D16641


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# be8f91d3 30-Oct-2017 Edward Tomasz Napierala <trasz@FreeBSD.org>

Use MAP_PRIVATE instead of obsolete MAP_COPY. No functional changes.

MFC after: 2 weeks


# 4153c211 18-Jan-2016 Warner Losh <imp@FreeBSD.org>

Add ldconfig -soft to process the soft float abi libraries and put it
into startup scripts for armv6. It acts much like ldconfig -32 does.


# 2493aada 19-Mar-2013 Warner Losh <imp@FreeBSD.org>

Add a comment about why aout support is still here: We need it for
compat2x, which is still in use, as evidence by recent bug reports.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# f709df34 29-Dec-2009 Ed Schouten <ed@FreeBSD.org>

ANSIfy ldconfig and the aout bits it still uses from rtld-aout.

(Why is aout support still there?)


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# b7696cdf 25-Jan-2007 Peter Wemm <peter@FreeBSD.org>

Remove unused reference to objformat.h


# 6efabada 11-Nov-2005 John Baldwin <jhb@FreeBSD.org>

Document -32 flag in usage() output as well.

Requested by: ru
MFC after: 1 week


# 8d646af5 10-Feb-2005 Ruslan Ermilov <ru@FreeBSD.org>

Sync program's usage() with manpage's SYNOPSIS.


# 74b67e84 14-Jan-2005 Xin LI <delphij@FreeBSD.org>

Improve readability for the recently introduced changes by having
their sizeof(*p) instead of explicitlly specifying their types.

Suggested by: nectar


# 665fc054 14-Jan-2005 Xin LI <delphij@FreeBSD.org>

Use a better name than underscore-tmpfile for better representation
of the meaning.

Suggested by: stefanf


# 06eda379 13-Jan-2005 Xin LI <delphij@FreeBSD.org>

64-bit clean + WARNS=6:
- Convert the (char *) cast+cast backs magic to
memcpy(3). Without this, the resulting code
is potentially risky with higher optimization
levels.
- Avoid same name when calling local variables,
as well as global symbols. This reduces
confusion for both human and compiler.
- Add necessary casts, consts
- Use new style function defination.
- Minor style.Makefile(5) tweak
- Bump WARNS?= from 0 to 6

** for the aout code: changes are intentionally limited
to ease maintaince.


# 4eae39bf 14-Aug-2004 Stefan Farfeleder <stefanf@FreeBSD.org>

Avoid using void pointers in additive expressions.

PR: 56653


# c905e45d 20-Mar-2004 Peter Wemm <peter@FreeBSD.org>

Add initial support for compiling a special 32 bit version of
ld-elf.so.1 on 64 bit systems. Most of this involves using alternate
paths, environment variables and diagnostic messages.

The build glue is seperate.


# 7d85b9aa 12-Mar-2004 Colin Percival <cperciva@FreeBSD.org>

Fix 10 year old size-of-bcopy bug.

PR: bin/43930
Submitted by: Alan Barrett
Approved by: rwatson (mentor)
MFNetBSD: revision 1.35
MFC after: 3 days


# 66422f5b 16-Sep-2002 Peter Wemm <peter@FreeBSD.org>

Initiate deorbit burn for the i386-only a.out related support. Moves are
under way to move the remnants of the a.out toolchain to ports. As the
comment in src/Makefile said, this stuff is deprecated and one should not
expect this to remain beyond 4.0-REL. It has already lasted WAY beyond
that.

Notable exceptions:
gcc - I have not touched the a.out generation stuff there.
ldd/ldconfig - still have some code to interface with a.out rtld.
old as/ld/etc - I have not removed these yet, pending their move to ports.
some includes - necessary for ldd/ldconfig for now.

Tested on: i386 (extensively), alpha


# 85429990 21-Mar-2002 Warner Losh <imp@FreeBSD.org>

o __P removed
o main prototype removed


# 3d438ad6 20-Mar-2002 David E. O'Brien <obrien@FreeBSD.org>

Remove 'register' keyword.
It does not help modern compilers, and some may take some hit from it.
(I also found several functions that listed *every* of its 10 local vars with
"register" -- just how many free registers do people think machines have?)


# 5e6220d9 02-May-2001 David E. O'Brien <obrien@FreeBSD.org>

* include/elf.h has been repo copied to include/elf-hints.h, and it no
longer includes machine/elf.h.
* consumers of elf.h now use the minimalist elf header possible.

This change is motivated by Binutils 2.11.0 and too much clashing over
our base elf headers and the Binutils elf headers.


# 643dcf40 07-Aug-2000 John Polstra <jdp@FreeBSD.org>

Add a "-i" option ("insecure") which disables the checks for
root ownership, etc. I will soon commit a companion knob for
"/etc/rc.conf".

Submitted by: Maxime Henrion <mhenrion@cybercable.fr>


# fa0c86aa 25-Jul-2000 John Polstra <jdp@FreeBSD.org>

If a directory is world-writable or is not owned by root, skip it
and emit a warning. This is a security measure since ldconfig
influences the shared libraries used by all programs.

I think the check should be made even more stringent by also
ignoring group-writable directories. I will make that change soon
unless we encounter a good reason not to do it.

Submitted by: Maxime Henrion <mhenrion@cybercable.fr>


# 97333b9e 09-Jul-2000 John Polstra <jdp@FreeBSD.org>

Make "ldconfig" with no arguments behave the same as "ldconfig -R".

Submitted by: Maxime Henrion <mhenrion@cybercable.fr>


# 16bd17ce 16-Jan-2000 Kris Kennaway <kris@FreeBSD.org>

Fix insecure tempfile handling

Reviewed by: audit@freebsd.org


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 65a74e45 21-Apr-1999 Bill Fumerola <billf@FreeBSD.org>

Make usage() reflect reality (add the -aout and -elf options).

OK'd by: bde


# cfa4d739 08-Sep-1998 John Polstra <jdp@FreeBSD.org>

Add a new library function getobjformat(). It checks all the
standard places ("/etc/objformat", ${OBJFORMAT}, argv) for an
indication of the user's preferred object file format. This
consolidates some code that was starting to be duplicated in more
and more places.

Use the new function in ldconfig.

Note: I don't think that gcc should use getobjformat(), even though
it could. The compiler should limit itself to functions that are
widespread, to ease porting and cross-compilation.


# 614d19ca 06-Sep-1998 John Polstra <jdp@FreeBSD.org>

Fix calls to mmap. It returns void *, and on failure it returns
MAP_FAILED.

Don't try to extend the mapping in place if it is too short.
There's no guarantee it will be possible. Remap the file instead.

Put in a few style fixes.

Submitted by: Bruce Evans <bde>


# 5f8d88dd 05-Sep-1998 John Polstra <jdp@FreeBSD.org>

For a.out mode, ignore shared libraries that don't have at least 2
version numbers.


# a565ca59 04-Sep-1998 John Polstra <jdp@FreeBSD.org>

Implement ldconfig functionality for ELF. The hints are stored in
a different file than the a.out hints, namely, "/var/run/ld-elf.so.hints".
These hints consist only of the directory search path. There is
no hash table as in the a.out hints, because ELF doesn't have to
search for the file with the highest minor version number. (It
doesn't have minor version numbers at all.)

A single run of ldconfig updates either the a.out hints or the ELF
hints, but not both. The set of hints to process is selected in
the usual way, via /etc/objformat, or ${OBJFORMAT}, or the "-aout"
or "-elf" command line option. The rationale is that you probably
want to search different directories for ELF than for a.out.

"ldconfig -r" is faked up to produce output like we are used to,
except that for ELF there are no minor version numbers. This should
enable "ldconfig -r" to be used for checking LIB_DEPENDS in ports
even for ELF.

I implemented the ELF functionality in a new source file, with an
eye toward eliminating the a.out code entirely at some point in
the future.


# ab845347 02-Aug-1998 Bruce Evans <bde@FreeBSD.org>

Fixed printf format errors.


# b50d7fae 06-Jul-1998 Philippe Charnier <charnier@FreeBSD.org>

Add rcsid. remove unused #includes. Getopt returns -1 not EOF. Add usage().
Cosmetics in err(3) string.


# 7abda51b 28-Jun-1998 Bruce Evans <bde@FreeBSD.org>

Fixed printf format errors.


# cabb97dc 26-May-1998 Søren Schmidt <sos@FreeBSD.org>

ELF preparation step 2:

Move a.out libraries to /usr/lib/aout to make space for ELF libs.
Make rtld usr /usr/lib/aout as default library path.
Make ldconfig reject /usr/lib as an a.out library path.
Fix various Makefiles for LIBDIR!=/usr/lib breakage.

This will after a make world & reboot give a system that no
longer uses /usr/lib/*, infact one could remove all the old
libraries there, they are not used anymore.

We are getting close to an ELF make world, but I'll let this
all settle for a week or two...


# d4ba5766 21-Aug-1997 Peter Wemm <peter@FreeBSD.org>

Add -R (rescan or refresh) option to rescan and rebuild the hints
file based on the previous list of directories stored there which
should overcome a weakness of the '-m' switch which can only add
libs. This is an ideal way of updating the hints list after adding
or removing a shlib since it will remove entries that are gone and
doesn't need to have all the directories spelled out each time.
(eg: rm -f /usr/lib/libtcl75*; ldconfig -R) This only works for
version 2 hints files (which we've been generating for a year or
so) which store the path.


# 571b472b 11-Jul-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Allow ldconfig to accept files (containing directory paths) as well as
directory paths.
Reviewed by: jkh & jdp
Submitted by: Hans Zuidam <hans@brandinnovators.com>


# fce15c9a 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# d66f9d22 07-Nov-1996 John Polstra <jdp@FreeBSD.org>

Fixed a bug in the handling of the directories in the search path
that is stored in the hints file. If that search path contained
a non-existent directory (one, say, that had been removed), and
"ldconfig -m /a/perfectly/good/directory" was run, ldconfig returned
an error status without printing an error message. This caused
some confusing bombs when installing ports, in particular.

I changed it so that non-existent directories from the stored search
path are silently ignored. Only non-existent directories named
explicitly on the command line are treated as errors. Also, a
diagnostic is printed if and only if an error status is returned.

In an unrelated fix, ldconfig now silently ignores any directories
named on the command line when the "-r" option is given. Formerly,
these directories incorrectly made their way into the "search
directories" line of the listing. It really should be an error to
specify directories together with "-r", but I don't have time to
fix the manual page in that way right now.

2.2 Candidate.


# 7c6da7dc 10-Oct-1996 John Polstra <jdp@FreeBSD.org>

Add a new option "-f hints_file" to specify an alternate file instead of
"/var/run/ld.so.hints".

Delete an incorrect statement about LD_LIBRARY_PATH from the manual
page.


# 80c71499 30-Sep-1996 Peter Wemm <peter@FreeBSD.org>

Updates to deal with ld.so.hints version 2. It now deals with the
ldconfig path (from NetBSD). I added code to make sure there were no
duplicates in the path when multiple ldconfig -m's were used.

Reviewed by: nate, jdp
Obtained from: NetBSD (partly)


# 526195ad 12-Jul-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

General -Wall warning cleanup, part I.
Submitted-By: Kent Vander Velden <graphix@iastate.edu>


# 0f6b2cb3 25-Feb-1996 Paul Traina <pst@FreeBSD.org>

Bring in some of Paul K's fixes for ldconfig from NetBSD-current.
This solves the problem of being unable to use shared libraries with dots
in their names before the ".so.<version>" code.

This should be brought into -stable.

There are more changes from Paul that look like they should be included,
but they change the format of the hints file, so I'm not going to bring them
in now (but we should in the future).

Obtained from: pk@netbsd.org


# 1c7895ac 16-Aug-1995 Joerg Wunsch <joerg@FreeBSD.org>

Reset the umask before creating the output file; otherwise running
ldconfig as root with a restrictive umask yielded ld.so.hints
unreadable by the world (and thus useless).


# f606c848 24-Jun-1995 Satoshi Asami <asami@FreeBSD.org>

Add an "-m" flag to merge instead of replace the entries. We can
now safely add a line like

ldconfig -m ${PREFIX}/lib

in ports' Makefiles and packing lists without throwing away some
directories the user may have added.

Submitted by: Mostly by Paul Kranenburg <pk@cs.few.eur.nl>


# d5453ba5 12-Jan-1995 Joerg Wunsch <joerg@FreeBSD.org>

Make ldconfig and ld.so not hashing the shared lib minor number. This
misfeature caused troubles when a program attempted to access a shlib
where one with a higher minor number has been hashed. Ldconfig does
only include the highest-numbered shlib anyway, so this is in no way a
limitation of generality.

Caution: after installing the new programs, your /var/run/ld.so.hints
needs to be rebuiult; run ldconfig again as it's done from /etc/rc.


# 61f9ce8d 23-Dec-1994 Nate Williams <nate@FreeBSD.org>

Updated to recent version of Paul K.'s shlib code. This code has better
warning handling and allows for link-time warnings with a modified
version of gas.

Note: Not all of the newer bits were updated such as some of the non-x86
machine-dependant code is relevant to FreeBSD right now.

Obtained from: NetBSD


# 699e1b82 15-Jun-1994 Rich Murphey <rich@FreeBSD.org>

Changes from Paul Kranenburg which bring us into sync with his sources:

handling of errors through the standard err() and warn()
more fixes for Geoff Rehmet's NULL pointer bug.
fixes NULL pointer bugs when linking mono and nested X servers.
supports a `-nostdlib' option.
accept object files without a symbol table
don't attempt dynamic linking when `-A' is given

a few variable names have chaged (desc -> fd), and the formatting has
changed which should make it much easier to track his sources.

I tested 'make world' for /usr/src and X twice with these changes.


# 91b1841d 05-Jun-1994 Andreas Schulz <ats@FreeBSD.org>

Add the -r and -s flags to the Usage string.


# 09e3d49d 13-Feb-1994 Jordan K. Hubbard <jkh@FreeBSD.org>

This is Paul K's latest set of ld changes. A commit was necessary at this
late stage due to the fact that link.h was copyright Sun Microsystems.

This version of ld sync's us up with NetBSD's ld and supports compatablily
with NetBSD's -[zZ] flags (which we had reversed). Compiling with this
new ld will give you RRS warnings for libraries which do not contain .type
infomation - these wsarnings are harmless and will go away as soon as you
recompile your libraries (cd /usr/src; make libraries).


# 52c4ca7a 30-Nov-1993 Jordan K. Hubbard <jkh@FreeBSD.org>

Many recent fixes from Paul K, add support for chaining of shared lib deps.


# b9ae52e3 03-Nov-1993 Paul Richards <paul@FreeBSD.org>

Imported NetBSD's ld for shared libs.