History log of /freebsd-current/usr.sbin/kldxref/ef_powerpc.c
Revision Date Author Comments
# 2a622f14 14-Dec-2023 Jessica Clarke <jrtc27@FreeBSD.org>

kldxref: Reduce divergence between per-architecture files

Note that relbase is always 0 for DSOs so its omission for __KLD_SHARED
architectures was not a bug in practice.

Whilst here, also parenthesise the dest offset for where to avoid
transiently creating an out-of-bounds pointer, which is UB (though even
on CHERI architectures, where capability bounds compression can result
in that creating invalid capabilities that will trap on dereference,
optimisation will reassociate to the correct form in practice and thus
work just fine).


# d1ce87ae 14-Dec-2023 Jessica Clarke <jrtc27@FreeBSD.org>

kldxref: Fix for 32-bit powerpc

R_PPC_RELATIVE lost its 32-bit handling in the libelf conversion.

Reported by: bapt
Fixes: 0299afdff145 ("kldxref: Make use of libelf to be a portable cross tool")


# 0299afdf 12-Dec-2023 John Baldwin <jhb@FreeBSD.org>

kldxref: Make use of libelf to be a portable cross tool

This allows kldxref to operate on kernel objects from any
architecture, not just the native architecture. In particular, this
will permit generating linker.hints files as part of a cross-arch
release build.

- elf.c is a new file that includes various wrappers around libelf
including routines to read ELF data structures such as program and
section headers and ELF relocations into the "generic" forms
described in <gelf.h>. This file also provides routines for
converting a linker set into an array of addresses (GElf_Addr)
as well as reading architecture-specific mod_* structures and
converting them into "generic" Gmod_* forms where pointers are
replaced with addresses.

- The various architecture-specific reloc handlers now use GElf_*
types for most values (including GElf_Rel and GElf_Rela for
relocation structures) and use routines from <sys/endian.h> to read
and write target values. A new linker set matches reloc handlers
to specific ELF (class, encoding, machine) tuples.

- The bits of kldxref.c that write out linker.hints now use the
encoding (ELFDATA2[LM]SB) of the first file encountered in a
directory to set the endianness of the output file. Input files
with a different architecture in the same directory are skipped with
a warning. In addition, the initial version record for the file
must be deferred until the first record is finished since the
architecture of the output file is not known until then.

- Various places that used 'sizeof(void *)' throughout now use
'elf_pointer_size()' to determine the size of a pointer in the
target architecture.

Tested by: amd64 binary on both amd64 and i386 /boot/kernel
Reviewed by: imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42966


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

Remove $FreeBSD$: two-line .h pattern

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


# 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


# 79f5d198 09-Feb-2022 Alfredo Dal'Ava Junior <alfredo@FreeBSD.org>

kldxref: add R_PPC_ADDR32 handler

Implements R_PPC_ADDR32 handler for kldxref, addressing
"kldxref: unhandled relocation type 1" when running
"kldxref /boot/kernel" on powerpc 32 bits.

Reviewed by: luporl
MFC after: 2 days
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D33745


# c3d9c633 27-Dec-2021 Alfredo Dal'Ava Junior <alfredo@FreeBSD.org>

kldxref: add R_PPC64_ADDR64 handler

Implements R_PPC64_ADDR64 handler for kldxref, addressing
"kldxref: unhandled relocation type 38" when running
"kldxref /boot/kernel"

Reviewed by: jhibbits
MFC after: 1 week
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D33615


# 7e452085 27-Feb-2019 Leandro Lupori <luporl@FreeBSD.org>

Fix kldxref on PowerPC64

When using kldxref on kernel modules built with clang8 + lld8,
kldxref would be unable to find the modules metadata information,
because PowerPC64 was using the ef_nop.c implementation of
ef_reloc().

When GNU LD was used, it was also relocating the metadata section of
the .ko file. LLD does not do this, but only generate dynamic
relocations for it. With minor changes, ef_powerpc.c can now work
for PowerPC64 too.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D19370


# 66f8917b 17-Jan-2018 John Baldwin <jhb@FreeBSD.org>

Adjust format string to fix build.


# 449af04f 17-Jan-2018 John Baldwin <jhb@FreeBSD.org>

Tidy some whitespace.


# e2d0802c 17-Jan-2018 Ed Maste <emaste@FreeBSD.org>

kldxref: improve style(9)

Address style issues including some previously raised in D13923.

- Use designated initializers for structs
- Always use bracketed return style
- No initialization in declarations
- Align function prototype names
- Remove old commented code/unused includes

Submitted by: Mitchell Horne <mhorne063@gmail.com>
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13943


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


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


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


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

Make our ELF64 type definitions match standards. In particular this
means:
o Remove Elf64_Quarter,
o Redefine Elf64_Half to be 16-bit,
o Redefine Elf64_Word to be 32-bit,
o Add Elf64_Xword and Elf64_Sxword for 64-bit entities,
o Use Elf_Size in MI code to abstract the difference between
Elf32_Word and Elf64_Word.
o Add Elf_Ssize as the signed counterpart of Elf_Size.

MFC after: 2 weeks


# ba454f63 02-Mar-2005 Peter Grehan <grehan@FreeBSD.org>

Doh, erase unused variable...


# d6029e94 01-Mar-2005 Peter Grehan <grehan@FreeBSD.org>

PowerPC support for kldxref by handling the PPC-specific relocations.