History log of /freebsd-current/sys/sys/elf_common.h
Revision Date Author Comments
# d7ac4267 17-Apr-2024 Andrew Turner <andrew@FreeBSD.org>

elf_common.h: Add STO_AARCH64_VARIANT_PCS

This is used to mark symbols that use a variant procedure call with
a different calling convention to the main ABI.

Reviewed by: kib, imp
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D44868


# f39010b1 12-Oct-2023 Andrew Turner <andrew@FreeBSD.org>

sys/sys: Check for __ASSEMBLER__ in elf_common.h

When preprocessing assembly files with clang or gcc the __ASSEMBLER__
macro is defined. Check for this as an alternative to LOCORE in
elf_common.h so it can be included by .S files.

Reviewed by: imp
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D42224


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 2f0e0bd5 02-Aug-2023 Gordon Bergling <gbe@FreeBSD.org>

elf(3): Fix a typo in a source code comment

- s/speciaal/special/

MFC after: 3 days


# 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


# 7738bb89 28-Jan-2023 Mitchell Horne <mhorne@FreeBSD.org>

elf_common.h: remove obsolete riscv relocations

These were specified at one time, but later removed.

Reviewed by: jrtc27, imp, emaste
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38174


# c52c98e6 20-Jan-2023 Warner Losh <imp@FreeBSD.org>

elf_common.h: Add parens to EF_ARM_EABI_VERSION macro

Due to my haste, I missed John's suggestion in the review that I add ()
here. Belatedly add them. It didn't matter for my test case, but there's
some pathological uses where it might matter.

Suggested by: jrtc23, jhb
Sponsored by: Netflix


# 2c6b9107 20-Jan-2023 Warner Losh <imp@FreeBSD.org>

elf_common.h: define EF_ARM_EABI_VERSION

The Linux distributions have had the EF_ARM_EABI_VERSION macro for a
while now. The kernel of arm* targets build depends on it being in the
host's elf.h environment. Add it here so it gets pulled in so there's
one fewer hack required to build a Linux kernel on a FreeBSD host.

Sponsored by: Netflix
Reviewed by: jrtc27, kib, jhb
Differential Revision: https://reviews.freebsd.org/D38139


# ff41239f 12-Sep-2022 Konstantin Belousov <kib@FreeBSD.org>

Add AT_USRSTACK{BASE, LIM} AT vectors, and ELF_BSDF_VMNOOVERCOMMIT flag

Reviewed by: brooks, imp (previous version)
Discussed with: markj
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D36540


# 05b6744c 28-Jun-2022 Ed Maste <emaste@FreeBSD.org>

Add ELFCOMPRESS_ZSTD ELF compression constant

ELFCOMPRESS_ZSTD indicates that an ELF section is compressed with zstd.
It is the second compression type, after the existing ELFCOMPRESS_ZLIB.
Zstd generally provides a compelling tradeoff of speed and compression
(other algorithms may compress slightly better but take a lot longer,
or run faster but do not compress nearly as well).

See https://groups.google.com/g/generic-abi/c/satyPkuMisk for details.
ELFCOMPRESS_ZSTD will be supported in a future Clang/LLVM update. ELF
Tool Chain tools also need updating.

Reviewed by: Fangrui Song
MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# 931983ee 24-Mar-2022 John Baldwin <jhb@FreeBSD.org>

x86: Add a NT_X86_SEGBASES register set.

This register set contains the values of the fsbase and gsbase
registers. Note that these registers can already be controlled
individually via ptrace(2) via MD operations, so the main reason for
adding this is to include these register values in core dumps. In
particular, this will enable looking up the value of TLS variables
from core dumps in gdb.

The value of NT_X86_SEGBASES was chosen to match the value of
NT_386_TLS on Linux. The notes serve similar purposes, but FreeBSD
will never dump a note equivalent to NT_386_TLS (which dumps a single
segment descriptor rather than a pair of addresses) and picking a
currently-unused value in the NT_X86_* range could result in a future
conflict.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D34650


# b2cb74c2 23-Mar-2022 John Baldwin <jhb@FreeBSD.org>

arm,arm64: Add a NT_ARM_TLS read-only register set.

This register set exposes the per-thread TLS register. It matches the
layout used by Linux on arm64. Linux does not implement this note for
32-bit arm.

Reviewed by: andrew, markj
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34595


# 6713be31 30-Aug-2021 Andrew Turner <andrew@FreeBSD.org>

Add NT_ARM_ADDR_MASK

This can be used by debuggers to find which bits in a virtual address
should be masked off to get a canonical address. This is currently used
by the Pointer Authentication Code support to get its mask. It could also
be used if we support Top Byte Ignore for the same purpose.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34302


# 758d98de 17-Jan-2022 Mark Johnston <markj@FreeBSD.org>

exec: Remove the stack gap implementation

ASLR stack randomization will reappear in a forthcoming commit. Rather
than inserting a random gap into the stack mapping, the entire stack
mapping itself will be randomized in the same way that other mappings
are when ASLR is enabled.

No functional change intended, as the stack gap implementation is
currently disabled by default.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33704


# 01c77a43 11-Nov-2021 Konstantin Belousov <kib@FreeBSD.org>

Pass vdso address to userspace

Reviewed by: emaste
Discussed with: jrtc27
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 month
Differential revision: https://reviews.freebsd.org/D32960


# 1cf06333 16-Oct-2021 Fangrui Song <i@maskray.me>

sys: Add definitions for RELR relative relocation format

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32526


# b94d360e 20-Sep-2021 Andrew Turner <andrew@FreeBSD.org>

Add ELF macros found in the aaelf64 spec

The arm64 aaelf64 spec [0] has DT_AARCH64_ that could be used with
dynamic linking. It also adds GNU_PROPERTY_AARCH64_FEATURE_1_AND used
to tell the kernel which CPU features the binary is compatible with,
but does not require to execute correctly.

Add these values so the kernel and elf tools can make use of them.

[0] https://github.com/ARM-software/abi-aa/blob/2021Q1/aaelf64/aaelf64.rst

Sponsored by: The FreeBSD Foundation


# f2210001 19-Jul-2021 Jessica Clarke <jrtc27@FreeBSD.org>

elf: Remove R_RISCV_[GT]PREL_[IS] relocation defines

These were internal binutils relocations that have no way to be
generated in assembly nor will ever be seen in the output, and so should
never have been defined in the psABI in the first place. They have
therefore been removed from the spec as of [1], so do so here too.

[1] https://github.com/riscv/riscv-elf-psabi-doc/commit/44f98e0fd8104def00f2a5a8d94b23dd647d18fb


# f7d18154 17-Jan-2021 Konstantin Belousov <kib@FreeBSD.org>

elf: add some definitions for i386 and amd64 relocations

I believe that rtld does not need to implement them, they are mostly for
the static linker. 'Mostly' because for amd64 our kernel linker loads
object files, and amd64 relocation types could be observed.

Defines were taken from glibc sources.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28205


# 673e2dd6 18-Dec-2020 Konstantin Belousov <kib@FreeBSD.org>

Add ELF flag to disable ASLR stack gap.

Also centralize and unify checks to enable ASLR stack gap in a new
helper exec_stackgap().

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


# f8e8a06d 10-Oct-2020 Conrad Meyer <cem@FreeBSD.org>

random(4) FenestrasX: Push root seed version to arc4random(3)

Push the root seed version to userspace through the VDSO page, if
the RANDOM_FENESTRASX algorithm is enabled. Otherwise, there is no
functional change. The mechanism can be disabled with
debug.fxrng_vdso_enable=0.

arc4random(3) obtains a pointer to the root seed version published by
the kernel in the shared page at allocation time. Like arc4random(9),
it maintains its own per-process copy of the seed version corresponding
to the root seed version at the time it last rekeyed. On read requests,
the process seed version is compared with the version published in the
shared page; if they do not match, arc4random(3) reseeds from the
kernel before providing generated output.

This change does not implement the FenestrasX concept of PCPU userspace
generators seeded from a per-process base generator. That change is
left for future discussion/work.

Reviewed by: kib (previous version)
Approved by: csprng (me -- only touching FXRNG here)
Differential Revision: https://reviews.freebsd.org/D22839


# bc6f027a 23-Aug-2020 Konstantin Belousov <kib@FreeBSD.org>

Reserve FreeBSD ELF feature control bit LA48 to control VA layout on amd64.

Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D25273


# d93010c5 12-Jun-2020 John Baldwin <jhb@FreeBSD.org>

Allow <sys/elf_common.h> to be used in assembly.

Hide C-only declarations under #ifndef LOCORE. This will be used by
future changes to define ELF notes in assembly.

Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25211


# 36f0d336 30-May-2020 Ed Maste <emaste@FreeBSD.org>

elf_common.h: define DF_1_PIE

DF_1_PIE indicates that the object is a position-independent executable.

Reference:
https://docs.oracle.com/cd/E36784_01/html/E36857/chapter6-42444.html

MFC after: 3 days
Sponsored by: The FreeBSD Foundation


# 4b88ccbc 08-May-2020 Mitchell Horne <mhorne@FreeBSD.org>

Sync relocation definitions

Add the most recent relocation types from the RISC-V ELF psABI spec.

MFC after: 3 days


# 9df1c38b 15-Apr-2020 Brooks Davis <brooks@FreeBSD.org>

Export argc, argv, envc, envv, and ps_strings in auxargs.

This simplifies discovery of these values, potentially with reducing the
number of syscalls we need to make at runtime. Longer term, we wish to
convert the startup process to pass an auxargs pointer to _start() and
use that rather than walking off the end of envv. This is cleaner,
more C-friendly, and for systems with strong bounds (e.g. CHERI)
necessary.

Reviewed by: kib
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24407


# d06e23f9 04-Mar-2020 Ed Maste <emaste@FreeBSD.org>

Reserve WXNEEDED ELF feature control flag

This will be used to tag binaries that require W+X mappings, in advance
of the ability to prevent W^X in mmap/mprotect.

There is still some discussion about the flag's name, but the ABI won't
change even if the name does (as kib pointed out in the review).

Reviewed by: csjp, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23909


# 944cf37b 08-Feb-2020 Konstantin Belousov <kib@FreeBSD.org>

Add AT_BSDFLAGS auxv entry.

The intent is to provide bsd-specific flags relevant to interpreter
and C runtime. I did not want to reuse AT_FLAGS which is common ELF
auxv entry.

Use bsdflags to report kernel support for sigfastblock(2). This
allows rtld and libthr to safely infer the syscall presence without
SIGSYS. The tunable kern.elf{32,64}.sigfastblock blocks reporting.

Tested by: pho
Disscussed with: cem, emaste, jilles
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D12773


# 2bd195af 23-Jan-2020 Ed Maste <emaste@FreeBSD.org>

add MIPS-specific PT header ELF definitions

Submitted by: David Carlier
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19428


# 7e4c9d48 10-Jan-2020 Pedro F. Giffuni <pfg@FreeBSD.org>

Update ELFOSABI_* constants with OpenVOS.

Reference:
https://www.sco.com/developers/gabi/latest/ch4.eheader.html


# 78347412 29-Dec-2019 Mark Johnston <markj@FreeBSD.org>

Add ARMv8 static relocation types used for control flow instructions.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# adea0d63 26-Dec-2019 Justin Hibbits <jhibbits@FreeBSD.org>

Eliminate the last MI difference in AT_* definitions (for powerpc).

Summary:
As a transition aide, implement an alternative elfN_freebsd_fixup which
is called for old powerpc binaries. Similarly, add a translation to rtld to
convert old values to new ones (as expected by a new rtld).

Translation of old<->new values is incomplete, but sufficient to allow an
installworld of a new userspace from an old one when a new kernel is running.

Test Plan:
Someone needs to see how a new kernel/rtld/libc works with an old
binary. If if works we can probalby ship this. If not we probalby need
some more compat bits.

Submitted by: brooks
Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D20799


# 156e8654 17-Nov-2019 Konstantin Belousov <kib@FreeBSD.org>

Add elf image flag to disable stack gap.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D22379


# 8b430273 20-Sep-2019 Ed Maste <emaste@FreeBSD.org>

elf_common: add ELF note names

r348628 added a definition of NT_GNU_BUILD_ID. Some software (Valgrind)
also expects a #define for the note name (ELF_NOTE_GNU) in the case that
NT_GNU_BUILD_ID is defined.

PR: 239669
Reported by: Yuichiro NAITO
Sponsored by: The FreeBSD Foundation
Event: EuroBSDCon FreeBSD DevSummit 2019


# 1610117d 10-Sep-2019 Leandro Lupori <luporl@FreeBSD.org>

Add R_PPC_IRELATIVE relocation

Pre-requisite for most ifunc related changes.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D21587


# 5dc7e31a 02-Jul-2019 Konstantin Belousov <kib@FreeBSD.org>

Control implicit PROT_MAX() using procctl(2) and the FreeBSD note
feature bit.

In particular, allocate the bit to opt-out the image from implicit
PROTMAX enablement. Provide procctl(2) verbs to set and query
implicit PROTMAX handling. The knobs mimic the same per-image flag
and per-process controls for ASLR.

Reviewed by: emaste, markj (previous version)
Discussed with: brooks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D20795


# c9207d3d 27-Jun-2019 Mitchell Horne <mhorne@FreeBSD.org>

Add some missing RISC-V ELF defines

This adds defines for the RISC-V specific e_flags values, and some of
the missing static relocations.

Reviewed by: markj
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D20766


# ca307559 07-Jun-2019 Christian S.J. Peron <csjp@FreeBSD.org>

Teach readelf about some OpenBSD ELF program headers

- Add constants for OpenBSD wxneeded, bootdata and randomize to the
FreeBSD elf_common.h file. This is the file that gets used by the
elftoolchain library.
- Update readelf and elfdump utilities to decode these program headers
if they are encountered.

Note: FreeBSD has it's own version of elfdump(1), which will be updated
in a subsequent commit. I am adding it here anyway because this diff is
going to be submitted upstream.

Discussed with: emaste
Reviewed by: imp
MFC afer: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20548

M contrib/elftoolchain/elfdump/elfdump.c
M contrib/elftoolchain/readelf/readelf.c
M sys/sys/elf_common.h


# b734222e 04-Jun-2019 Ed Maste <emaste@FreeBSD.org>

elf_common: add GNU note types and NT_GNU_PROPERTY_TYPE_0 bits

To support Intel CET IBT/Shadow Stack.

Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# 5bf271b2 28-Mar-2019 Ed Maste <emaste@FreeBSD.org>

Revert change accidentally committed along with r345625

Reported by: Oliver Pinter <oliver.pinter@hardenedbsd.org>


# 09b47fc1 27-Mar-2019 Ed Maste <emaste@FreeBSD.org>

revert r341429 "disable BIND_NOW in libc, libthr, and rtld"

r345620 by kib@ fixed the rtld issue that caused a crash at startup
during resolution of libc's ifuncs with BIND_NOW.

PR: 233333
Sponsored by: The FreeBSD Foundation


# 75fe7176 31-Jan-2019 Konstantin Belousov <kib@FreeBSD.org>

Reserve a bit in the FreeBSD feature control note for marking the
image as not compatible with ASLR.

Requested by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D5603


# 57fe7128 07-Nov-2018 Alex Richardson <arichardson@FreeBSD.org>

Handle the DT_MIPS_RLD_MAP_REL dynamic tag in RTLD

This dynamic tag contains the location of the .rld_map section relative to
the location of the dynamic tag. For PIE MIPS binaries DT_MIPS_RLD_MAP can
not be used since it contains an absolute address. Without this change
GDB can not find the function program counters in other libraries and once
I apply this change I can successfully run info sharedlibraries again.

Reviewed By: kib
Differential Revision: https://reviews.freebsd.org/D17867


# e74f411d 02-Nov-2018 Ed Maste <emaste@FreeBSD.org>

Define NT_FREEBSD_FEATURE_CTL ELF note type

This ELF note will be used to allow binaries to opt out of, or in to,
upcoming vulnerability mitigation and other features.

Committing the definition and readelf change separately to allow
independent MFC.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation


# c3adaa33 22-Oct-2018 Brooks Davis <brooks@FreeBSD.org>

Consolidate identical ELF auxargs type defintions.

All platforms except powerpc use the same values and powerpc shares a
majority of them.

Go ahead and declare AT_NOTELF, AT_UID, and AT_EUID in favor of the
unused AT_DCACHEBSIZE, AT_ICACHEBSIZE, and AT_UCACHEBSIZE for powerpc.

Reviewed by: jhb, imp
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D17397


# 8cfbc812 26-Jul-2018 Ed Maste <emaste@FreeBSD.org>

elf_common: update ARM ABI flag names

In the V5 ABI the flags are EF_ARM_ABI_FLOAT_HARD and
EF_ARM_ABI_FLOAT_SOFT. The flags have the same values as the legacy GCC
flags EF_ARM_VFP_FLOAT and EF_ARM_SOFT_FLOAT respectively.

The legacy names are kept for compatibility.

Reported by: Peter Smith (Linaro)
Reviewed by: imp
Sponsored by: The FreeBSD Foundation


# 5167f178 02-Jun-2018 Justin Hibbits <jhibbits@FreeBSD.org>

Included VSX registers in powerpc core dumps

Summary: Included VSX registers in powerpc core dumps (both kernel and gcore)

Submitted by: Luis Pires
Differential Revision: https://reviews.freebsd.org/D15512


# b40b8572 27-Apr-2018 Ed Maste <emaste@FreeBSD.org>

elf_common.h: add DT_SUNW_ASLR tag

For upcoming ELF Tool Chain import (readelf).


# 8356a9ab 23-Mar-2018 John Baldwin <jhb@FreeBSD.org>

Move remaining EF_MIPS_* flags to <sys/elf_common.h>.

Reviewed by: brooks
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D14789


# f5b26e13 18-Jan-2018 Conrad Meyer <cem@FreeBSD.org>

Add Elf_Nhdr definition to match NetBSD, OpenBSD, Linux

The mesa port started to use this type and fails to build without it.

NetBSD: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/exec_elf.h.diff?r1=1.26&r2=1.27&f=h
OpenBSD: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/sys/exec_elf.h.diff?r1=1.21&r2=1.22&f=h

PR: 225302
Reported by: Greg V <greg AT unrelenting.technology>
Sponsored by: Dell EMC Isilon


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

sys/sys: further 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.


# 27efb0a2 14-Sep-2017 John Baldwin <jhb@FreeBSD.org>

Add a NT_ARM_VFP ELF core note to hold VFP registers for each thread.

The core note matches the format and layout of NT_ARM_VFP on Linux.
Debuggers use the AT_HWCAP flags to determine how many VFP registers
are actually used and their format.

Reviewed by: mmel (earlier version w/o gcore)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D12293


# b4e9a36b 12-Sep-2017 John Baldwin <jhb@FreeBSD.org>

Handle relocations for newer non-PIC MIPS ABI.

Newer binutils supports extensions to the MIPS ABI for non-PIC code
that is used when compiling O32 binaries with clang 5 (but not used
for N64 oddly enough). These extensions require support for
R_MIPS_COPY relocations as well as a second PLT GOT using
R_MIPS_JUMP_SLOT relocations.

For R_MIPS_COPY, use the same approach as on other architectures where
fixups are deferred to the MD do_copy_relocations.

The additional PLT GOT for jump slots is located in a .got.plt section
which is identified by a DT_MIPS_PLTGOT dynamic entry. This GOT also
requires fixups for the first two GOT entries just as the normal GOT.
However, the entry point for this second GOT uses a different calling
convention. Rather than passing an offset into the GOT, it passes an
offset into the .rel.plt section. This requires a second entry point
(_rtld_pltbind_start) which calls the normal _rtld_bind() rather than
_mips_rtld_bind(). This also means providing a real version of
reloc_jmpslot() which is used by _rtld_bind().

In addition, add real implementions of reloc_plt() and
reloc_jmpslots() which walk .rel.plt handling R_MIPS_JUMP_SLOT
relocations.

Reviewed by: kib
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D12326


# 86be94fc 30-Mar-2017 Tycho Nightingale <tychon@FreeBSD.org>

Add support for capturing 'struct ptrace_lwpinfo' for signals
resulting in a process dumping core in the corefile.

Also extend procstat to view select members of 'struct ptrace_lwpinfo'
from the contents of the note.

Sponsored by: Dell EMC Isilon


# 21dff180 21-Jan-2017 Conrad Meyer <cem@FreeBSD.org>

Add remaining ELF compression definitions and structs

A follow-up to r300231.

Sponsored by: Dell EMC Isilon


# dd2be8cb 02-Aug-2016 Ed Maste <emaste@FreeBSD.org>

Move/add ARM ELF PHDR types to elf_common.h

Accidentally missed in r303674


# 4df4e8ac 02-Aug-2016 Ed Maste <emaste@FreeBSD.org>

Add ELFOSABI_ARM_AEABI ELF OSABI constant

Reported by: andrew
Sponsored by: The FreeBSD Foundation


# 71f44ab1 30-May-2016 Ed Maste <emaste@FreeBSD.org>

Add and correct MIPS relocation types

The correct names for R_MIPS_GOT_HI16 and R_MIPS_GOT_LO16 have a _
after GOT. The nonstandard names (R_MIPS_GOTHI16, R_MIPS_GOTLO16) in the
FreeBSD elf_common.h header also had incorrect values and were not used
in the tree, so just remove them.

Add other MIPS relocation types found in FreeBSD/mips64 object files.

Reviewed by: imp, jmallett
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D6561


# 19c27002 19-May-2016 Ed Maste <emaste@FreeBSD.org>

elf_common.h: add section header flag and dynamic types

SHF_COMPRESSED section contains compressed data
DT_TLSDESC_PLT Location of PLT entry for TLS descriptor resolver calls
DT_TLSDESC_GOT Location of GOT entry used by resolver PLT entry

MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# 4d9155df 07-Apr-2016 Ed Maste <emaste@FreeBSD.org>

Rename SHT_AMD64_UNWIND to SHT_X86_64_UNWIND per ABI doc

From http://www.x86-64.org/documentation_folder/abi-0.99.pdf


# 4456b8f5 26-Jan-2016 Ed Maste <emaste@FreeBSD.org>

Add STT_SPARC_REGISTER ELF definition

MFC after: 1 week


# 7c5f2676 21-Jan-2016 Ed Maste <emaste@FreeBSD.org>

Add STB_GNU_UNIQUE symbol binding definition

Red Hat created STB_GNU_UNIQUE to handle certain special cases relating
to dynamically loading C++ DSOs[1].

We don't (currently) have support for STB_GNU_UNIQUE, but ought to
reserve the value in ELFNN_ST_BIND. This will also be used by an
upcoming ELF Tool Chain import.

[1] https://www.redhat.com/archives/posix-c++-wg/2009-August/msg00002.html

MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# b1aaaae6 18-Jan-2016 Ruslan Bukin <br@FreeBSD.org>

Add RISC-V relocation types.

Reviewed by: emaste


# 64760d92 06-Dec-2015 Ed Maste <emaste@FreeBSD.org>

Add definitions for ELF note types used in executables

Sponsored by: The FreeBSD Foundation


# 2754b49a 09-Oct-2015 Ed Maste <emaste@FreeBSD.org>

Add .gnu.versym VERSYM_HIDDEN flag and related mask

MFC after: 1 week
Sponsored by: The FreeBSD Foundation


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

Add MIPS ELF section type SHT_MIPS_ABIFLAGS definition

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


# 2e02bd22 19-May-2015 Ed Maste <emaste@FreeBSD.org>

Add GRP_COMDAT section group flag to ELF header

Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D2582


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


# e8a2ef58 09-Apr-2015 Andrew Turner <andrew@FreeBSD.org>

Add R_AARCH64_NONE, the null relocation.


# 2832cd54 02-Apr-2015 Konstantin Belousov <kib@FreeBSD.org>

Speed up symbol lookup for the amd64 kernel modules.

Amd64 uses relocatable object files as the modules format. It is good
WRT not having unneeded overhead for PIC code, in particular, due to
absence of useless GOT and PLT. But the cost is that the module
linking process cannot use hash to speed up the symbol lookup, and
that each reference to the symbol requiring a relocation, instead of
single-place relocation in GOT.

Cache the successfull symbol lookup results in the module symbol
table, using the newly allocated SHN_FBSD_CACHED value from
SHN_LOOS-HIOS range as an indicator. The SHN_FBSD_CACHED together
with the non-existent definition of the found symbol are reverted
after successfull relocations, which is done under kld_sx lock, so it
should not be visible to other consumers of the symbol table.

Submitted by: Conrad Meyer
Differential Revision: https://reviews.freebsd.org/D1718
MFC after: 3 weeks


# 03d926a0 30-Mar-2015 Ed Maste <emaste@FreeBSD.org>

Fill out arm64 dynamic relocation #defines

Sponsored by: The FreeBSD Foundation


# 27fd1736 06-Mar-2015 Ed Schouten <ed@FreeBSD.org>

Update the ELFOSABI_* constants.

Two new operating systems have been added in the meantime.
ELFOSABI_FENIXOS that uses value 16 (published in the latest draft) and
ELFOSABI_CLOUDABI that uses value 17 (to be published in the next draft).


# 00899197 20-Jan-2015 Ed Maste <emaste@FreeBSD.org>

Add missing R_X86_64_ constants to elf_common.h

PR: 196918
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation


# b59e55a9 03-Jan-2015 Justin Hibbits <jhibbits@FreeBSD.org>

Missed the header for the note definition.

X-MFC-with: r276634
MFC after: 2 weeks


# 942c3233 02-Jan-2015 Ed Maste <emaste@FreeBSD.org>

Update ELF headers to include additional defines

The elftoolchain project includes these additional defines for various
userland programs. Given that arch-specific defines are still interesting
in the context of userland programs reading or writing ELF metadata, they
should be included in top-level ELF headers.

Remove duplicate defines from ARM and MIPS elf headers.

Submitted by: will (initial version)
Reviewed by: imp, will
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D844


# 7f5a9777 18-Dec-2014 Andrew Turner <andrew@FreeBSD.org>

Add AArch64 64-bit relocation values. These will be needed by rtld when
we import it along with utilities in elftoolchain.

Differential Revision: https://reviews.freebsd.org/D1330
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation


# 180e57e5 21-Nov-2014 John Baldwin <jhb@FreeBSD.org>

Improve support for XSAVE with debuggers.
- Dump an NT_X86_XSTATE note if XSAVE is in use. This note is designed
to match what Linux does in that 1) it dumps the entire XSAVE area
including the fxsave state, and 2) it stashes a copy of the current
xsave mask in the unused padding between the fxsave state and the
xstate header at the same location used by Linux.
- Teach readelf() to recognize NT_X86_XSTATE notes.
- Change PT_GET/SETXSTATE to take the entire XSAVE state instead of
only the extra portion. This avoids having to always make two
ptrace() calls to get or set the full XSAVE state.
- Add a PT_GET_XSTATE_INFO which returns the length of the current
XSTATE save area (so the size of the buffer needed for PT_GETXSTATE)
and the current XSAVE mask (%xcr0).

Differential Revision: https://reviews.freebsd.org/D1193
Reviewed by: kib
MFC after: 2 weeks


# 58c47a70 19-Oct-2014 Andrew Turner <andrew@FreeBSD.org>

Allow libkvm to get the kernel va to pa delta without the need for
physaddr. This should allow for a kernel where PHYSADDR and KERNPHYSADDR
are both undefined.

For now libkvm will use the old method of reading physaddr and kernaddr
to allow it to work with old kernels. This could be removed in the future
when enough time has passed.

Differential Revision: https://reviews.freebsd.org/D939
MFC after: 1 week


# 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


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

elfdump: add EM_AARCH64 64-bit ARM machine architecture


# 1ecdb6d4 16-Jan-2014 Kai Wang <kaiw@FreeBSD.org>

Define SHT_GNU_LIBLIST and R_MIPS_64, which is needed for libelf and
libdwarf.


# ed1bfa0c 07-Oct-2013 Konstantin Belousov <kib@FreeBSD.org>

Add the definition of DF_1_INTERPOSE flag.

Reviewed by: kan
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Approved by: re (glebius)


# 03941861 10-Jul-2013 Kevin Lo <kevlo@FreeBSD.org>

Add the ARM processor-specific section types.

Reviewed by: imp


# f1fca82e 16-Apr-2013 Mikolaj Golub <trociny@FreeBSD.org>

Add a new set of notes to a process core dump to store procstat data.

The notes format is a header of sizeof(int), which stores the size of
the corresponding data structure to provide some versioning, and data
in the format as it is returned by a related sysctl call.

The userland tools (procstat(1)) will be taught to extract this data,
providing additional info for postmortem analysis.

PR: kern/173723
Suggested by: jhb
Discussed with: jhb, kib
Reviewed by: jhb (initial version), kib
MFC after: 1 month


# 9c934bf4 06-May-2012 Konstantin Belousov <kib@FreeBSD.org>

Add definition for the -z nodefaultlib flag.

MFC after: 3 days


# b74d1af7 26-Mar-2012 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Add .reginfo section entry


# 27f3b996 23-Mar-2012 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Add define for MIPS.options


# 54c33c2a 13-Feb-2012 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Add ARM relocations types used for thread-local storage

Reviewed by: cognet


# 1b38b227 30-Jan-2012 Konstantin Belousov <kib@FreeBSD.org>

Add definition for PT_GNU_RELRO.

MFC after: 3 days


# 62f9324b 22-Jan-2012 Konstantin Belousov <kib@FreeBSD.org>

Fix typo.

Submitted by: John Marino <draco marino st>
MFC after: 3 days


# 4038b798 12-Dec-2011 Konstantin Belousov <kib@FreeBSD.org>

Add definitions for GNU-specific STT_GNU_IFUNC symbol type,
and R_{386,X86_64}_IRELATIVE relocations.

MFC after: 3 weeks


# 9b2a96cc 06-May-2011 David E. O'Brien <obrien@FreeBSD.org>

Add the ability to search for all the inlined instances of a given function.

Reviewed by: jb
Obtained from: Juniper Networks


# b75d0b4a 22-Nov-2010 Konstantin Belousov <kib@FreeBSD.org>

Add PT_GNU_STACK definition.

MFC after: 3 days


# 7f08176e 22-Nov-2010 Attilio Rao <attilio@FreeBSD.org>

Add the ability for GDB to printout the thread name along with other
thread specific informations.

In order to do that, and in order to avoid KBI breakage with existing
infrastructure the following semantic is implemented:
- For live programs, a new member to the PT_LWPINFO is added (pl_tdname)
- For cores, a new ELF note is added (NT_THRMISC) that can be used for
storing thread specific, miscellaneous, informations. Right now it is
just popluated with a thread name.

GDB, then, retrieves the correct informations from the corefile via the
BFD interface, as it groks the ELF notes and create appropriate
pseudo-sections.

Sponsored by: Sandvine Incorporated
Tested by: gianni
Discussed with: dim, kan, kib
MFC after: 2 weeks


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


# 12debc81 12-Sep-2010 Konstantin Belousov <kib@FreeBSD.org>

Add DF_1_LOADFLTR.

MFC after: 3 days


# 702dafe6 12-Sep-2010 Konstantin Belousov <kib@FreeBSD.org>

Fix typo.

MFC after: 3 days


# dbe25130 10-Jul-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Add definitions for powerpc64 ELF relocation types. Some 64-bit relocations
are identical to 32-bit relocations in meaning, name, and number, and I
have chosen not to duplicate those here.


# 1eea4693 17-Dec-2009 Konstantin Belousov <kib@FreeBSD.org>

MFC r199829:
Implement rtld part of the support for -z nodlopen (see ld(1)).

MFC r199877:
Allow to load not-openable dso when tracing. This fixes ldd on such dso or
dso linked to non-openable object.
Remove '\n' at the end of error message.
End comments with dot.


# 0d3bc8a9 26-Nov-2009 Konstantin Belousov <kib@FreeBSD.org>

Implement rtld part of the support for -z nodlopen (see ld(1)).

Reviewed by: kan
MFC after: 3 weeks


# a08bed8c 10-Apr-2009 Kai Wang <kaiw@FreeBSD.org>

Added DT_GNU_HASH entry for GNU-style hash table.


# 2b0b4ee3 30-Mar-2009 Konstantin Belousov <kib@FreeBSD.org>

Implement support for RTLD_NODELETE flag for dlopen() and -z nodelete
static linker option. Do it by incrementing reference count on the loaded
object and its dependencies.

Reviewed by: davidxu, kan


# bbe2e463 16-Mar-2009 Konstantin Belousov <kib@FreeBSD.org>

Add some definitions for the DT_FLAGS_1 tag flags.

Reviewed by: kan


# c897f076 02-Feb-2009 Joseph Koshy <jkoshy@FreeBSD.org>

Introduce a C type representing the header for GNU-style hash table
sections. These ELF sections are generated by newer versions of
GNU binutils.

Reviewed by: kaiw, Ali Bahrami <ali dot bahrami at sun dot com>


# 440396a7 03-Jan-2009 Kai Wang <kaiw@FreeBSD.org>

Added section type SHT_GNU_HASH. GNU-style .hash section is a new
style of hash section with better performace than the original SYSV
hash. It can be generated by newer binutils.


# b3f4797a 31-Dec-2008 David E. O'Brien <obrien@FreeBSD.org>

style(9)

Verified with: svn diff -x -Bbw elf_common.h


# 926297fe 19-Dec-2008 Kai Wang <kaiw@FreeBSD.org>

Update elf_common.h with new EM_ types found in the latest ELF gABI.

This commit is slightly different from the original patch in the PR:
1. EM_ALPHA keeps the old value for compatibility reason.
2. Non-standard SHT_NUM is not added.
3. Style.

PR: kern/118540
Submitted by: "Pedro F. Giffuni" <giffunip[at]tutopia.com>


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

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


# 2f6a7934 01-Aug-2008 Warner Losh <imp@FreeBSD.org>

Add ELF relocation types for mips.

Obtained from: mips/include/elf.h


# 967d8727 01-Dec-2007 John Birrell <jb@FreeBSD.org>

Add extra visibility definitions.

See: <http://groups.google.com/group/generic-abi/browse_thread/thread/1a84adc15666164>

These are already in OpenSolaris and DTrace uses STV_ELIMINATE.


# 02b71ede 02-Apr-2007 Alexander Kabaev <kan@FreeBSD.org>

Correct PT_GNU_EH_FRAME definition.


# 55e1e0b0 13-Nov-2006 Joseph Koshy <jkoshy@FreeBSD.org>

Add `PN_XNUM', for supporting ELF objects with a large number of program
header table entries.


# 6825d607 04-Oct-2006 John Birrell <jb@FreeBSD.org>

PR:
Submitted by:
Reviewed by:
Approved by:
Obtained from:
MFC after:
Security:
Move the relocation definitions to the common elf header so that DTrace
can use them on one architecture targeted to a different one.

Add the additional ELF types defines in Sun's "Linker and Libraries"
manual.


# e3243f2b 31-May-2006 Maxim Konovalov <maxim@FreeBSD.org>

o Correct URL to ELF header documantation.

PR: kern/98213
Submitted by: Robert Gogolok


# f56d8bf1 19-Dec-2005 Marcel Moolenaar <marcel@FreeBSD.org>

o Add the GNU symbol versioning section constants (SHT_GNU_verdef,
SHT_GNU_verneed, SHT_GNU_versym),
o Fix the definition of DT_HIOS -- it was short an 'f'...


# 0eb88f20 18-Dec-2005 Alexander Kabaev <kan@FreeBSD.org>

Implement ELF symbol versioning using GNU semantics. This code aims
to be compatible with symbol versioning support as implemented by
GNU libc and documented by http://people.redhat.com/~drepper/symbol-versioning
and LSB 3.0.

Implement dlvsym() function to allow lookups for a specific version of
a given symbol.


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

Get in sync with current ELF definitions. In particular this means:
o Remove the unused and non-standard SHT_NUM, PT_COUNT and DT_COUNT.
o Add the STV_DEFAULT, STV_INTERNAL, STV_HIDDEN and STV_PROTECTED
symbol visibility constants.
o Add the ELF32_ST_VISIBILITY and ELF64_ST_VISIBILITY macros to
get the symbol visibility from the st_other field.
o Add the ELFOSABI_AIX, ELFOSABI_OPENVMS and ELFOSABI_NSK constants.
o Add the ET_LOOS, ET_HIOS, ET_LOPROC and ET_HIPROC constants.
o Further flesh out the list of machine types. Note that EM_ALPHA
remains non-standard. The standard value for EM_ALPHA is given
by EM_ALPHA_STD (which is a non-standard name :-)
o Add the SHN_LOOS, SHN_HIOS and SHN_XINDEX constants.
o Add the SHT_INIT_ARRAY, SHT_FINI_ARRAY, SHT_PREINIT_ARRAY, SHT_GROUP
and SHT_SYMTAB_SHNDX constants.
o Add the SHF_MERGE, SHF_STRINGS, SHF_INFO_LINK, SHF_LINK_ORDER,
SHF_OS_NONCONFORMING, SHF_GROUP and SHF_MASKOS constants.
o Add the PF_MASKOS and PF_MASKPROC constants.
o Add the STB_LOOS andf STB_HIOS constants.
o Add the STT_COMMON, STT_LOOS and STT_HIOS constants.

MFC after: 1 week


# 9da32aa0 04-May-2004 Marcel Moolenaar <marcel@FreeBSD.org>

Fix typo (in comment): s/IA-46/IA-64/

Submitted by: Miod Vallat <miod@online.fr>


# cc2e7a06 18-Jun-2003 Alexander Kabaev <kan@FreeBSD.org>

Add defines required for TLS support.


# 777ca648 18-Jun-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Add missing */


# da9f2454 17-Jun-2003 Matthew N. Dodd <mdodd@FreeBSD.org>

- Add support for DT_FLAGS.
- Define various things from the most recent ELF spec.


# f6273f85 11-Aug-2002 Robert Drehmel <robert@FreeBSD.org>

- Call a SHT_REL 'relocation section' rather than
'relation section'.
- Put a space between a word and the end of comment delimiter.


# 76c1f1f6 08-Sep-2001 Marcel Moolenaar <marcel@FreeBSD.org>

Catch up with common usage:

o Define ELFMAG and SELFMAG as an alternative to test the ELF magic.
ELFMAG is the magic; SELFMAG is the size of the magic. Use with
strncmp() or memcmp().
o Define SHT_NUM as the number of predefined sections.

Note: style(9) deviation for consistency.


# f310d6cf 24-Feb-2001 David E. O'Brien <obrien@FreeBSD.org>

Add "ELFOSABI_NONE" which is the symbol used in a copy of the old ELF spec,
as an alias for "ELFOSABI_SYSV".


# 68a2ed01 01-Jan-2001 David E. O'Brien <obrien@FreeBSD.org>

Update the e_machine values to include x86-64, PowerPC and [Strong]ARM;
and fix the Sparc values. Also update the ELFOSABI list while I'm here.


# d0eedf57 29-Sep-2000 Doug Rabson <dfr@FreeBSD.org>

Add machine type for ia64.


# c815a20c 17-Apr-2000 David E. O'Brien <obrien@FreeBSD.org>

Change our ELF binary branding to something more acceptable to the Binutils
maintainers.

After we established our branding method of writing upto 8 characters of
the OS name into the ELF header in the padding; the Binutils maintainers
and/or SCO (as USL) decided that instead the ELF header should grow two new
fields -- EI_OSABI and EI_ABIVERSION. Each of these are an 8-bit unsigned
integer. SCO has assigned official values for the EI_OSABI field. In
addition to this, the Binutils maintainers and NetBSD decided that a better
ELF branding method was to include ABI information in a ".note" ELF
section.

With this set of changes, we will now create ELF binaries branded using
both "official" methods. Due to the complexity of adding a section to a
binary, binaries branded with ``brandelf'' will only brand using the
EI_OSABI method. Also due to the complexity of pulling a section out of an
ELF file vs. poking around in the ELF header, our image activator only
looks at the EI_OSABI header field.

Note that a new kernel can still properly load old binaries except for
Linux static binaries branded in our old method.

*
* For a short period of time, ``ld'' will also brand ELF binaries
* using our old method. This is so people can still use kernel.old
* with a new world. This support will be removed before 5.0-RELEASE,
* and may not last anywhere upto the actual release. My expiration
* time for this is about 6mo.
*


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

$Id$ -> $FreeBSD$


# ac065b70 07-May-1999 Doug Rabson <dfr@FreeBSD.org>

The structure Elf_Note does not have 32 and 64 bit variants but always
has 32bit fields. This change allows FreeBSD/alpha to generate well-formed
ELF corefiles.

Reviewed by: John Polstra <jdp@polstra.com>


# c8afdc1d 14-Sep-1998 John Polstra <jdp@FreeBSD.org>

Add generic defines ELF_ARCH, ELF_CLASS, and ELF_DATA. These give
the relevant characteristics of the native machine, for building
and checking Elf_Ehdr structures.

Add structures to represent ELF "note" headers. Add defines for the
note types used in ELF core files.


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

Add definitions for the ELF section attribute flags, SHF_*.

Submitted by: Robert Nordier <rnordier@nordier.com>


# ca0154bc 15-Aug-1998 John Polstra <jdp@FreeBSD.org>

Revamp the ELF include files to better support architecture-independent
applications. Here's how it works.

The kernel should include <machine/elf.h> to get the definitions
for the native architecture. It can reference the various ELF
structures with generic names like Elf_Sym, Elf_Shdr, etc. A define
__ELF_WORD_SIZE is also available with the value 32 or 64 as
appropriate for the native architecture.

Generic applications should include <elf.h>, which is just a wrapper
for <machine/elf.h>.

Applications such as object file dumpers that need to deal with
foreign ELF files can include <sys/elf32.h> and/or <sys/elf64.h>.
Both can be included from the same source file if desired. The
structure names must be referenced using wordsize-specific names
like Elf32_Sym, Elf64_Shdr, etc.

I haven't change the alpha stuff, but I haven't broken it either.