History log of /freebsd-current/usr.bin/elfdump/elfdump.c
Revision Date Author Comments
# 5e3934b1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

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


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# a1b6427a 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


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

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


# 86e5e10d 17-Feb-2022 Eric van Gyzen <vangyzen@FreeBSD.org>

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


# 97d368d6 31-Jan-2019 Ed Maste <emaste@FreeBSD.org>

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


# 8ae9aa27 31-Jan-2019 Ed Maste <emaste@FreeBSD.org>

elfdump: fix build after r343610

One patch hunk did not survive the trip from git to svn.

PR: 228290
MFC with: r343610


# 2bc7b024 31-Jan-2019 Ed Maste <emaste@FreeBSD.org>

elfdump: include note type names

Based on a patch submitted by Dan McGregor.

PR: 228290
MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# 0f663f72 31-Jan-2019 Ed Maste <emaste@FreeBSD.org>

elfdump: whitespace fixup in advance of other changes


# c35530f4 05-Nov-2018 Brooks Davis <brooks@FreeBSD.org>

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


# 377421df 04-Nov-2018 Mariusz Zaborski <oshogbo@FreeBSD.org>

capsicum: use a new capsicum helpers in tools

Use caph_{rights,ioctls,fcntls}_limit to simplify the code.


# 7672a014 19-Jun-2018 Mariusz Zaborski <oshogbo@FreeBSD.org>

Convert `cap_enter() < 0 && errno != ENOSYS` to `caph_enter() < 0`.

No functional change intended.


# f37e7f52 29-May-2018 Ed Maste <emaste@FreeBSD.org>

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


# 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.


# cf8fb39f 17-Oct-2016 Ed Maste <emaste@FreeBSD.org>

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


# a4e3fc54 07-Oct-2016 Mariusz Zaborski <oshogbo@FreeBSD.org>

Remove the duplicated code using Capsicum helpers.

Reviewed by: cem, ed, bapt, emaste
Differential Revision https://reviews.freebsd.org/D8140


# 9e8f6063 20-Sep-2016 Ed Maste <emaste@FreeBSD.org>

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


# 06403dbc 18-Sep-2016 Ed Maste <emaste@FreeBSD.org>

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


# 3a4b59a2 24-Jan-2016 Ed Maste <emaste@FreeBSD.org>

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


# 453b09ca 24-Sep-2015 Ed Maste <emaste@FreeBSD.org>

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


# 050747f2 22-Sep-2015 Ed Maste <emaste@FreeBSD.org>

elfdump: report MIPS ELF section type SHT_MIPS_REGINFO

Sponsored by: The FreeBSD Foundation


# 4db90148 21-Sep-2015 Ed Maste <emaste@FreeBSD.org>

elfdump: report MIPS-specific section type SHT_MIPS_ABIFLAGS

Sponsored by: The FreeBSD Foundation


# 119b7592 24-Jul-2015 Ed Maste <emaste@FreeBSD.org>

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


# 9afb8b24 14-May-2015 Ed Maste <emaste@FreeBSD.org>

Add ELF machine EM_IAMCU, 32-bit Intel MCU

It is e_machine 6, which was previously reserved for 486.


# 9efc7e72 24-Nov-2014 Christian Brueffer <brueffer@FreeBSD.org>

Limit descriptors and enter capability mode.

Differential: D1009
Reviewed by: jonathan, pjd
MFC after: 2 weeks
Relnotes: yes


# 494053f4 21-Aug-2014 Ed Maste <emaste@FreeBSD.org>

elfdump: Remove extraneous _SUNW_ in reported DT_ names

Sponsored by: The FreeBSD Foundation


# 4d52a0fd 21-Aug-2014 Ed Maste <emaste@FreeBSD.org>

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


# ee8e9eca 31-Jul-2014 Ed Maste <emaste@FreeBSD.org>

elfdump: use existing ELF constants where available

Sponsored by: The FreeBSD Foundation


# 2d538f8c 31-Jul-2014 Ed Maste <emaste@FreeBSD.org>

elfdump: add EM_AARCH64 64-bit ARM machine architecture


# 8edba452 26-Jul-2014 Andreas Tobler <andreast@FreeBSD.org>

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


# b3854059 25-Jul-2014 Ed Maste <emaste@FreeBSD.org>

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


# a589e596 19-Jun-2014 Marcel Moolenaar <marcel@FreeBSD.org>

Don't dump core when the ELF file has no section headers. The ELF
core files created by gcore are among those.


# 97a9b0b1 07-May-2014 Ed Maste <emaste@FreeBSD.org>

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


# fee11555 13-Jan-2014 Justin Hibbits <jhibbits@FreeBSD.org>

Add missing EM_PPC64 to e_machine header display.

MFC after: 1 week


# bf70bece 19-Oct-2012 Ed Schouten <ed@FreeBSD.org>

More -Wmissing-variable-declarations fixes.

In addition to adding `static' where possible:

- bin/date: Move `retval' into extern.h to make it visible to date.c.
- bin/ed: Move globally used variables into ed.h.
- sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings.
- usr.bin/calendar: Remove unneeded variables.
- usr.bin/chat: Make `line' local instead of global.
- usr.bin/elfdump: Comment out unneeded function.
- usr.bin/rlogin: Use _Noreturn instead of __dead2.
- usr.bin/tset: Pull `Ospeed' into extern.h.
- usr.sbin/mfiutil: Put global variables in mfiutil.h.
- usr.sbin/pkg: Remove unused `os_corres'.
- usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'.


# 097cd850 15-Feb-2012 Eitan Adler <eadler@FreeBSD.org>

Don't extract the n_type value from the elf header, since it is never used

Fix warning when compiling with gcc46:
variable 'type' set but not used

Approved by: cperciva
MFC after: 3 days


# ead61635 16-Oct-2011 Marcel Moolenaar <marcel@FreeBSD.org>

o Use C99 designated initializer to properly handle ELFOSABI_STANDALONE.
o In elf_get_byte(), cast through uint8_t and not char to avoid sign
extension.


# 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.


# bf7cda51 11-Aug-2010 Rui Paulo <rpaulo@FreeBSD.org>

Teach elfdump(1) about the SUNW_dof section.

Sponsored by: The FreeBSD Foundation


# 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.


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

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


# 05157fa0 28-Jan-2006 Marcel Moolenaar <marcel@FreeBSD.org>

s/DT_IA64_PLT_RESERVE/DT_IA_64_PLT_RESERVE/


# 57668ad8 17-Dec-2005 Marcel Moolenaar <marcel@FreeBSD.org>

Know the machines FreeBSD runs on. Print the machine value for
unknown machines.

MFC after: 1 week


# d499047c 02-Mar-2004 Jake Burkholder <jake@FreeBSD.org>

Elf_Phdr.p_type 7 is "PT_TLS".


# dcae6166 06-Sep-2003 Jens Schweikhardt <schweikh@FreeBSD.org>

Removed another spurious semicolon forgotten in the previous commit.


# 81f8caf7 06-Sep-2003 Jens Schweikhardt <schweikh@FreeBSD.org>

Removed two spurious semicolons after function definitions.
Removed three spurious tabs on lines by themselves.

PR: bin/56492
Submitted by: Stefan Farfeleder <stefan@fafoe.narf.at>
MFC after: 6 weeks


# ac2ded1d 08-Aug-2003 Marcel Moolenaar <marcel@FreeBSD.org>

Fix sign-extension bug for 32 and 64-bit values. For 64-bit values
this involves the sign-extension of the high and low "word". Both
of which are 32-bit. The bug is especially harmful on ia64, where
0x9fffffffe0000000 is a common address (base of register stack).
This was invariably displayed as 0xffffffffe0000000.

The sign-extension is fixed by using {b|l}e{16|32|64}dec() where
applicable. Since elfdump(1) is not a bootstrap tool, dependency
on these functions is not a problem.


# 73e57b80 28-Jun-2003 Ruslan Ermilov <ru@FreeBSD.org>

Synchronize usage() and SYNOPSIS, and fix them (flags are not
optional here). Sort options. Print the file name on error.


# 75ca4dcf 02-Feb-2003 David E. O'Brien <obrien@FreeBSD.org>

Make WARNS=5 clean even on 64-bit platforms.


# 36210553 02-Feb-2003 David E. O'Brien <obrien@FreeBSD.org>

Make WARNS=5 on i386, (WARNS=1 on 64-bit platforms).

Submitted by: dwmalone (tweaked by me)


# 0529c56b 02-Feb-2003 David E. O'Brien <obrien@FreeBSD.org>

Try to tighten up the types a little bit to help debugging with GDB.


# 5f85bb36 17-Jan-2003 Marcel Moolenaar <marcel@FreeBSD.org>

If we're going to build and install this on ia64, we might as well
teach it about ia64 specific section types, dynamic tags and machine
type. This is a mostly insignificant change given the amount of
work that this tool obviously needs...


# 3df3bb12 15-Jan-2003 David E. O'Brien <obrien@FreeBSD.org>

Like sh_types, dt_tags just aren't in consecutive order, so we have to move
away from indexing into an array. Also add Sun and GNU specific tags.


# 9bc01124 15-Jan-2003 David E. O'Brien <obrien@FreeBSD.org>

The defined sh_types's just aren't in consecutive order, so we have to move
away from indexing into an array.


# 8fe960a1 15-Jan-2003 David E. O'Brien <obrien@FreeBSD.org>

Add a BSDL'ed util that displays information about ELF files.
This is simular to readelf(1) and objdump(1).

Submitted by: jake