Commit graph

113 commits

Author SHA1 Message Date
Warner Losh 5e3934b15a usr.bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Jessica Clarke e17dd921a2 ldd: Use __PATH_RTLD("32") over _COMPAT32_PATH_RTLD
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/D40934
2023-07-09 18:50:24 +01:00
Simon J. Gerraty d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Ed Maste e9f8723c30 ldd: clarify format options
-f may be specified zero, one, or two times.  Make this clear in the
usage.

Reviewed by:	markj, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34733
2023-03-21 10:14:03 -04:00
David E. O'Brien 43dc1409c1 Restricting xargs to '-n1' is much slower and isn't needed for file(1)
Also note that libc.so.6 is an older version of libc (thus why you'd
want to find files linked against it).
2022-12-28 15:54:29 -08:00
Simon J. Gerraty f48114b653 ldd: ignore unverified files
When mac_veriexec is enforcing, we won't run unverified binaries,
don't let ldd examine them either.

Reviewed by:	stevek emaste
MFC after:	1 week
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D36897
2022-10-06 17:51:28 -07:00
Konstantin Belousov 9cabef3d14 ldd: use direct exec mode unconditionally
Trying to exec malformed or unusual binary, for instance, a non-FreeBSD
ABI, or using a non-standard interpreter, might give unexpected outcome.

Reported by:	The UK's National Cyber Security Centre (NCSC)
Reviewed by:	emaste, markj, philip
Discussed with:	jhb
Sponsored by:	The FreeBSD Foundation
admbug:	991
PR:	127276, 175339, 231926
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36650
2022-10-06 18:50:26 +03:00
Konstantin Belousov 7d20a08076 ldd: also use exec mode for -a
The -a option also requires passing specific environment variables to
instance of rtld doing tracing.

PR:	259069
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-11-15 22:49:33 +02:00
Konstantin Belousov 2c7a6dad4d ldd: do not use dlopen(RTLD_TRACE) for dso when format is specified
Problem is that rtld cannot reliably access updated environment.
This was made more obvious by bfd4c875a1.  The application
environment can be in arbitrary state and place, system components
can observe it only during execve(2), or in case of rtld, right after
execve, when environment is still at know location and format.

Instead spawn ld-elf.so.1 in direct exec mode which can correctly read
all inherited updates to the environment.

PR:	259069
Reviewed by:	arichardson, jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32464
2021-10-21 03:09:14 +03:00
Konstantin Belousov ca8c576d10 ldd: style
Reviewed by:	arichardson, jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32464
2021-10-21 03:09:03 +03:00
Konstantin Belousov 17fc43bc01 ldd: Remove non-functional -v option
It seems -v only worked for a.out.  Remove it, not even keeping the current
nop for compat.  Also remove more mentions of a.out format from the man
page.

Reviewed by:	dim, emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D31708
2021-08-28 23:39:16 +03:00
John Baldwin 9d4104b214 Fix ldd to work with more ELF files.
- Use libelf to parse ELF data structures and remove code duplication
  for ELF32.

- Don't require the OSABI field to be set to the FreeBSD OSABI for
  shared libraries.  Both AArch64 and RISC-V leave it set to "none"
  and instead depend on the ABI tag note.  For ldd, this means falling
  back to walking the notes in PT_NOTE segments to find the ABI tag
  note to determine if an ELF shared library without OSABI set in the
  header file is a FreeBSD shared library.

Reviewed by:	kib
MFC after:	5 days
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D28342
2021-01-29 10:53:50 -08:00
Ed Maste c8eee7c0bf ldd: renumber executable type constants
ldd had #defines for AOUT, ELF, and ELF32.  The removal of AOUT left a
possibly confusing gap.  These are not used anywhere but this file so
renumber to avoid the gap.

Reported by:	allanjude
2021-01-09 13:34:58 -05:00
Ed Maste 0713c7b88c ldd: Retire aout support
Userland aout support has not 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 ldd, perhaps as part of a jail with a full
FreeBSD 2.x install.

Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27478
2021-01-07 19:14:01 -05:00
Konstantin Belousov 2b5d88fdcf Fix ldd for PIE binaries after rtld stopped accepting binaries for dlopen.
ldd proclaims ET_DYN objects as shared libraries and tries to
dlopen(RTLD_TRACE) them to get dependencies. Since PIE binaries are
ET_DYN | DF_1_PIE, refusal to dlopen such binaries breaks ldd.

Fix it by reading and parsing dynamic segment looking for DF_FLAG_1
and taking DF_1_PIE into account when deciding between binary and
library.

Reported by:	Dewayne Geraghty <dewayne@heuristicsystems.com.au>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D25257
2020-06-13 18:21:31 +00:00
Ed Maste 5a2c0ab18b ldd: add aout deprecation notice
Reported by:	kib
2020-03-17 16:42:25 +00:00
Mark Johnston 5d704fafcb Add an IMPLEMENTATION NOTES section to ldd.1.
PR:		231926
Reviewed by:	emaste
MFC after:	1 month
2018-10-23 13:49:53 +00:00
Ed Maste fd897a5340 ldd: reference readelf instead of objdump in warning message
We have an obsolete GNU objdump 2.17.50 in the base system, which will
be removed in the future.  Suggest readelf(1) for examining ELF files
instead; for most use cases it is the preferred tool anyhow.

PR:		229046
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2018-06-15 16:28:50 +00:00
Eitan Adler 4f8efc2274 ldd: avoid statically linked executables in example
The example works but spews warnings if run over a directory with
statically linked binaries.

PR:		211024
Submitted by:	mike@skew.org
2017-12-23 19:48:57 +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
Bryan Drewery ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Ruslan Bukin ca20f8ec29 o Replace __riscv__ with __riscv
o Replace __riscv64 with (__riscv && __riscv_xlen == 64)

This is required to support new GCC 7.1 compiler.
This is compatible with current GCC 6.1 compiler.

RISC-V is extensible ISA and the idea here is to have built-in define
per each extension, so together with __riscv we will have some subset
of these as well (depending on -march string passed to compiler):

__riscv_compressed
__riscv_atomic
__riscv_mul
__riscv_div
__riscv_muldiv
__riscv_fdiv
__riscv_fsqrt
__riscv_float_abi_soft
__riscv_float_abi_single
__riscv_float_abi_double
__riscv_cmodel_medlow
__riscv_cmodel_medany
__riscv_cmodel_pic
__riscv_xlen

Reviewed by:	ngie
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D11901
2017-08-07 14:09:57 +00:00
Don Lewis 4b426307e5 Increase size of argv[] array to avoid running off the end.
Reported by:	Coverity
CID:		1193819
MFC after:	1 week
2016-05-16 16:01:46 +00:00
Ruslan Bukin 5a0bf0f5c6 We don't support a.out executables on RISC-V.
Reviewed by:	emaste
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D5048
2016-01-24 15:15:57 +00:00
Jung-uk Kim a41dab8fc9 Add support for ARM EABI.
MFC after:	1 week
2015-10-16 17:50:36 +00:00
Simon J. Gerraty ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty 44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty 98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Andrew Turner e1f65999b6 Allowus to exclude a.out support from ldd and use it with arm64 as it won't
support the a.out format.

Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
2015-03-18 13:59:04 +00:00
Simon J. Gerraty ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Baptiste Daroussin 2b7af31cf5 use .Mt to mark up email addresses consistently (part3)
PR:		191174
Submitted by:	Franco Fichtner  <franco at lastsummer.de>
2014-06-23 08:23:05 +00:00
Simon J. Gerraty fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty 76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty 3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Christian Brueffer b21e986087 Avoid double close() of a file descriptor.
CID:		1006089
Found with:	Coverity Prevent(tm)
MFC after:	1 week
2014-04-13 20:12:21 +00:00
Simon J. Gerraty d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Mark Johnston a94a4b74bd Pass variables prefixed with both LD_ and LD_32_ to the run-time linker.
This prevents unintentional execution of programs when running ldd(1) on
32-bit Linux binaries.

PR:		175339, 127276
Suggested by:	kib, rstone
Reviewed by:	kib
MFC after:	2 weeks
2013-08-07 00:28:17 +00:00
Simon J. Gerraty 7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
Marcel Moolenaar 7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Ben Laurie 5f301949ef Fix clang warnings.
Approved by:	philip (mentor)
2011-06-18 13:56:33 +00:00
Rebecca Cran 70557f4f83 hdr.elf.e_ident[EI_OSABI] is not a bitmask so '==' should been used.
Reported by: Artem Belevich <fbsdlist at src.cx>
2010-11-22 20:18:46 +00:00
Warner Losh 25faff346c MFtbemd:
Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want
to test of all the CPUs of a given family conform.
2010-08-23 22:24:11 +00:00
Ed Schouten b7946da96b Build usr.bin/ with WARNS=6 by default.
Also add some missing $FreeBSD$ to keep svn happy.
2010-01-02 10:27:05 +00:00
Daniel Gerzo a2ec746f79 - correctly render the provided example
PR:		docs/140962
Submitted by:	mharo
2009-11-28 11:05:22 +00:00
John Baldwin 52122f3139 A few style and whitespace fixes.
Submitted by:	bde
2008-08-02 12:04:59 +00:00
John Baldwin e68ed79390 Tweak the support for using ldd on 32-bit objects a bit further.
Specifically, build a 32-bit /usr/bin/ldd32 on amd64 which handles 32-bit
objects.  Since it is a 32-bit binary, it can fork a child process which
can dlopen() a 32-bit shared library.  The current 32-bit support in ldd
can't do this because it does the dlopen() from a 64-bit process.  In order
to preserve an intuitive interface for users, the ldd binary automatically
execs /usr/bin/ldd32 for 32-bit objects.  The end result is that ldd on
amd64 now transparently handles 32-bit shared libraries in addition to
32-bit binaries.

Submitted by:	ps (indirectly)
2008-08-01 21:52:41 +00:00