Commit graph

79 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 fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -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
Alfonso Gregory a1b6427a97 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
2023-07-07 10:45:18 -06:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Simon J. Gerraty d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Eric van Gyzen 86e5e10daf elfdump: handle small files more gracefully
elfdump -E on an empty file would complain "Invalid argument" because
it tried to mmap zero bytes.  With the -E flag, elfdump should
simply exit non-zero.  For tiny files, the code would reference off
the end of the mapped region.

Ensure the file is large enough to contain an ELF header before mapping it.

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2022-02-17 10:09:53 -06:00
Ed Maste 97d368d62b elfdump: use designated array initialization for note types
This ensures the note type name is in the correct slot.

PR:		228290
Submitted by:	kib
MFC with:	343610
Sponsored by:	The FreeBSD Foundation
2019-01-31 16:49:06 +00:00
Ed Maste 8ae9aa2772 elfdump: fix build after r343610
One patch hunk did not survive the trip from git to svn.

PR:		228290
MFC with:	r343610
2019-01-31 16:21:09 +00:00
Ed Maste 2bc7b0242f elfdump: include note type names
Based on a patch submitted by Dan McGregor.

PR:		228290
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-01-31 16:19:04 +00:00
Ed Maste 0f663f7258 elfdump: whitespace fixup in advance of other changes 2019-01-31 16:11:15 +00:00
Brooks Davis c35530f464 elfdump: Add -E to test if a file is an ELF binary.
This is intended to replace potentially unreliable checks like:

	file -b $1 | grep -q '^ELF ..-bit .SB executable'

Reviewed by:	emaste
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15971
2018-11-05 22:53:50 +00:00
Mariusz Zaborski 377421df96 capsicum: use a new capsicum helpers in tools
Use caph_{rights,ioctls,fcntls}_limit to simplify the code.
2018-11-04 19:24:49 +00:00
Mariusz Zaborski 7672a0148f Convert cap_enter() < 0 && errno != ENOSYS to caph_enter() < 0.
No functional change intended.
2018-06-19 23:43:14 +00:00
Ed Maste f37e7f527b elfdump: chase ABI tag note name change from r232832
r232832 changed the ABI tag note name from .note.ABI-tag to .note.tag.
Follow suit in elfdump.

Elfdump's note parsing is very basic and should be significantly
reworked, but for now just restore the broken functionality.

PR:		228290
Submitted by:	martin at lispworks.com
MFC after:	1 week
2018-05-30 01:16:50 +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
Bryan Drewery 490a8aa9a1 DIRDEPS_BUILD: Update dependencies.
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
2016-11-13 00:11:30 +00:00
Ed Maste cf8fb39f7d elfdump: correct DT_AUXILIARY / DT_USED / DT_FILTER definitions
r109332 introduced these three as DT_SUNW_*. Update to the correct
names already used elsewhere in FreeBSD and the Sun "Linker and
Libraries Guide"

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2016-10-17 13:36:50 +00:00
Mariusz Zaborski a4e3fc54a0 Remove the duplicated code using Capsicum helpers.
Reviewed by:	cem, ed, bapt, emaste
Differential Revision	https://reviews.freebsd.org/D8140
2016-10-07 17:56:57 +00:00
Ed Maste 9e8f606352 elfdump: limit STDIN to no rights rather than closing it
Closing stdin/stdout/stderr is often a bad idea as a future open()
can end up with its fd. Leave it open and limit it to no rights
instead.

Reviewed by:	cem
Differential Revision:	https://reviews.freebsd.org/D7984
2016-09-20 21:38:12 +00:00
Ed Maste 06403dbce5 elfdump: adjust stdout/stderr capabilities
stdio uses fstat and the TIOCGETA ioctl. Also collapse the
cap_rights_limit and new cap_ioctls_limit calls into one if statement.
Errors here are not actionable by the user and distinguishing stdout
from stderr doesn't really have value.

Reported by:	kib
Reviewed by:	allanjude, bapt
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D7944
2016-09-18 20:23:26 +00:00
Ed Maste 3a4b59a2cf elfdump: handle STT_SPARC_REGISTER
STT_SPARC_REGISTER is a SPARC-specific symbol type specified by the
Sparcv9 ABI to provide some information on register use by the object.

Also rework st_info type lookup to avoid out-of-bounds array access.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2016-01-25 04:22:01 +00:00
Ed Maste 453b09caf5 Rename ELFOSABI_SYSV to ELFOSABI_NONE to match current spec
Source: http://www.sco.com/developers/gabi/latest/ch4.eheader.html

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D3731
2015-09-24 21:04:48 +00:00
Ed Maste 050747f2c3 elfdump: report MIPS ELF section type SHT_MIPS_REGINFO
Sponsored by:	The FreeBSD Foundation
2015-09-23 00:32:38 +00:00
Ed Maste 4db90148e1 elfdump: report MIPS-specific section type SHT_MIPS_ABIFLAGS
Sponsored by:	The FreeBSD Foundation
2015-09-22 01:45:43 +00:00
Ed Maste 119b75925c Add RISC-V ELF machine type definition
EM_RISCV is now officially registered as e_machine 243.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2015-07-24 16:52:21 +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
Ed Maste 9afb8b24ad Add ELF machine EM_IAMCU, 32-bit Intel MCU
It is e_machine 6, which was previously reserved for 486.
2015-05-14 18:29:05 +00:00
Christian Brueffer 9efc7e72bb Limit descriptors and enter capability mode.
Differential:	D1009
Reviewed by:	jonathan, pjd
MFC after:	2 weeks
Relnotes:	yes
2014-11-24 09:31:38 +00:00
Simon J. Gerraty 9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Mark Johnston f4f080c659 Fix a typo.
MFC after:	3 days
2014-09-16 22:26:01 +00:00
Ed Maste 494053f4ee elfdump: Remove extraneous _SUNW_ in reported DT_ names
Sponsored by:	The FreeBSD Foundation
2014-08-21 20:58:43 +00:00
Ed Maste 4d52a0fd97 Rename DT_FEATURE_1 to DT_FEATURE
This provides a minor cleanup in elfdump; there are otherwise no
consumers in the tree.  Old SUN documentation can be found for either
variant, but GNU binutils switched to DT_FEATURE around 2000.

Sponsored by:	The FreeBSD Foundation
2014-08-21 20:55:10 +00:00
Simon J. Gerraty ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Ed Maste ee8e9ecaf1 elfdump: use existing ELF constants where available
Sponsored by:	The FreeBSD Foundation
2014-07-31 15:40:03 +00:00
Ed Maste 2d538f8c83 elfdump: add EM_AARCH64 64-bit ARM machine architecture 2014-07-31 15:25:12 +00:00
Andreas Tobler 8edba45283 Further improvements on elfdump, to follow up r269092:
- Add ARM specific section header types.
- Add SHT_GNU_HASH section header type.
- Improve reporting of undefined tags in d_tags.
- Add DT_GNU_HASH tag.

Reviewed by:	emaste
2014-07-26 19:44:45 +00:00
Ed Maste b385405966 elfdump: Improve section type reporting
The SHT range 0x70000000-0x7fffffff is processor-specific.  Pass the
ELF machine type header to sh_types so the section header type name can
be reported correctly for the given processor.

For all ranges report the actual value for unknown types.

Add MIPS-specific type SHT_MIPS_OPTIONS.

CR:		D483
Reviewed by:	sbruno, marcel
Sponsored by:	DARPA, AFRL
2014-07-25 18:20:56 +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
Marcel Moolenaar a589e596c0 Don't dump core when the ELF file has no section headers. The ELF
core files created by gcore are among those.
2014-06-19 20:12:28 +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 cc3f4b9965 Merge from head 2014-05-08 23:54:15 +00:00
Ed Maste 97a9b0b123 Handle ELF files with 65280 or more sections
If e_shnum or e_shstrndx are at least SHN_LORESERVE (0xff00) then an
escape value is used to indicate that the actual value is found in one
of section 0's fields.

Sponsored by:	DARPA, AFRL
2014-05-07 21:16:47 +00:00
Simon J. Gerraty 3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Justin Hibbits fee1155508 Add missing EM_PPC64 to e_machine header display.
MFC after:	1 week
2014-01-14 04:28:41 +00:00