Commit Graph

60 Commits

Author SHA1 Message Date
Konstantin Belousov
fcbb1441d0 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
2022-01-08 12:45:46 +02:00
Warner Losh
8b7cc20f79 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
2022-01-06 22:44:07 -07:00
Konstantin Belousov
3ede04c78c 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
2021-11-25 01:55:04 +02:00
Konstantin Belousov
af91158706 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
2021-11-25 01:55:04 +02:00
Konstantin Belousov
b828161d12 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
2021-11-25 01:55:03 +02:00
Konstantin Belousov
3f2c6f5598 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
2021-11-25 01:55:03 +02:00
Konstantin Belousov
83511ce5c4 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
2021-11-25 01:55:03 +02:00
Ed Maste
50a40d0911 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 aa5e1b42e6 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
2020-12-31 10:29:08 -05:00
Ed Maste
2ee11faacf 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
2020-03-17 15:57:25 +00:00
Edward Tomasz Napierala
308224833a 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
2018-08-09 11:46:12 +00:00
Pedro F. Giffuni
1de7b4b805 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.
2017-11-27 15:37:16 +00:00
Edward Tomasz Napierala
be8f91d3d0 Use MAP_PRIVATE instead of obsolete MAP_COPY. No functional changes.
MFC after:	2 weeks
2017-10-30 08:56:04 +00:00
Warner Losh
4153c21113 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.
2016-01-18 21:40:18 +00:00
Warner Losh
2493aadade 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.
2013-03-19 16:57:04 +00:00
Ed Schouten
f709df34c3 ANSIfy ldconfig and the aout bits it still uses from rtld-aout.
(Why is aout support still there?)
2009-12-29 21:07:17 +00:00
Peter Wemm
b7696cdf60 Remove unused reference to objformat.h 2007-01-25 22:38:58 +00:00
John Baldwin
6efabadaef Document -32 flag in usage() output as well.
Requested by:	ru
MFC after:	1 week
2005-11-11 21:24:21 +00:00
Ruslan Ermilov
8d646af581 Sync program's usage() with manpage's SYNOPSIS. 2005-02-10 09:19:34 +00:00
Xin LI
74b67e8422 Improve readability for the recently introduced changes by having
their sizeof(*p) instead of explicitlly specifying their types.

Suggested by:	nectar
2005-01-14 15:49:05 +00:00
Xin LI
665fc054fd Use a better name than underscore-tmpfile for better representation
of the meaning.

Suggested by:	stefanf
2005-01-14 13:18:55 +00:00
Xin LI
06eda379d4 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.
2005-01-14 12:22:57 +00:00
Stefan Farfeleder
4eae39bfdf Avoid using void pointers in additive expressions.
PR:		56653
2004-08-14 17:46:10 +00:00
Peter Wemm
c905e45dc0 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.
2004-03-21 01:21:26 +00:00
Colin Percival
7d85b9aa14 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
2004-03-13 00:11:05 +00:00
Peter Wemm
66422f5b7a 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
2002-09-17 01:49:00 +00:00
Warner Losh
854299908c o __P removed
o main prototype removed
2002-03-21 13:14:21 +00:00
David E. O'Brien
3d438ad61f 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?)
2002-03-20 17:55:10 +00:00
David E. O'Brien
5e6220d9d0 * 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.
2001-05-02 23:56:21 +00:00
John Polstra
643dcf40ee 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>
2000-08-07 19:12:04 +00:00
John Polstra
fa0c86aadc 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>
2000-07-26 04:47:17 +00:00
John Polstra
97333b9e84 Make "ldconfig" with no arguments behave the same as "ldconfig -R".
Submitted by:	Maxime Henrion <mhenrion@cybercable.fr>
2000-07-09 19:12:49 +00:00
Kris Kennaway
16bd17ce2d Fix insecure tempfile handling
Reviewed by:	audit@freebsd.org
2000-01-16 21:08:58 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Bill Fumerola
65a74e454e Make usage() reflect reality (add the -aout and -elf options).
OK'd by:	bde
1999-04-21 20:06:42 +00:00
John Polstra
cfa4d73988 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.
1998-09-09 01:21:25 +00:00
John Polstra
614d19ca10 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>
1998-09-06 20:43:25 +00:00
John Polstra
5f8d88ddd6 For a.out mode, ignore shared libraries that don't have at least 2
version numbers.
1998-09-05 16:20:15 +00:00
John Polstra
a565ca5920 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.
1998-09-05 03:31:00 +00:00
Bruce Evans
ab84534772 Fixed printf format errors. 1998-08-02 16:06:35 +00:00
Philippe Charnier
b50d7fae67 Add rcsid. remove unused #includes. Getopt returns -1 not EOF. Add usage().
Cosmetics in err(3) string.
1998-07-06 07:02:26 +00:00
Bruce Evans
7abda51bbc Fixed printf format errors. 1998-06-28 19:36:49 +00:00
Søren Schmidt
cabb97dcbf 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...
1998-05-26 20:12:56 +00:00
Peter Wemm
d4ba5766dd 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.
1997-08-22 04:42:12 +00:00
Jordan K. Hubbard
571b472b20 Allow ldconfig to accept files (containing directory paths) as well as
directory paths.
Reviewed by:	jkh & jdp
Submitted by:	Hans Zuidam <hans@brandinnovators.com>
1997-07-11 14:45:41 +00:00
Peter Wemm
fce15c9ab3 Revert $FreeBSD$ to $Id$ 1997-02-22 15:48:31 +00:00
Jordan K. Hubbard
1130b656e5 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.
1997-01-14 07:20:47 +00:00
John Polstra
d66f9d22f7 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.
1996-11-08 02:12:40 +00:00
John Polstra
7c6da7dcef 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.
1996-10-10 23:14:23 +00:00
Peter Wemm
80c714994d 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)
1996-10-01 01:31:51 +00:00
Jordan K. Hubbard
526195ad0d General -Wall warning cleanup, part I.
Submitted-By: Kent Vander Velden <graphix@iastate.edu>
1996-07-12 19:08:36 +00:00