Commit Graph

17 Commits

Author SHA1 Message Date
Warner Losh
71625ec9ad sys: Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:24 -06:00
Brandon Bergren
30dc2aebd7 [PowerPC] Fix build-id note on powerpc64 kernel
Due to the ordering of the powerpc64 linker script, we were discarding
all notes before emitting .note.gnu.build-id. This had the effect of
generating an empty build id section and breaking the kern.build_id
sysctl added in r348611.

powerpc and powerpcspe are uneffected.

PR:		246430
MFC after:	3 days
Sponsored by:	Tag1 Consulting, Inc.
2020-06-01 19:40:59 +00:00
Brandon Bergren
9411e24df3 [PowerPC] kernel ifunc support for powerpc*, fix ppc64 relocation oddities.
This is a general cleanup of the relocatable kernel support on powerpc,
needed to enable kernel ifuncs.

 * Fix some relocatable issues in the kernel linker, and change to using
   a RELOCATABLE_KERNEL #define instead of #ifdef __powerpc__ for parts that
   other platforms can use in the future if they wish to have ET_DYN kernels.

 * Get rid of the DB_STOFFS hack now that the kernel is relocated to the DMAP
   properly across the board on powerpc64.

 * Add powerpc64 and powerpc32 ifunc functionality.

 * Allow AIM64 virtual mode OF kernels to run from the DMAP like other AIM64
   by implementing a virtual mode restart. This fixes the runtime address on
   PowerMac G5.

 * Fix symbol relocation problems on post-relocation kernels by relocating
   the symbol table.

 * Add an undocumented method for supplying kernel symbols on powernv and
   other powerpc machines using linux-style kernel/initrd loading -- If
   you pass the kernel in as the initrd as well, the copy resident in initrd
   will be used as a source for symbols when initializing the debugger.
   This method is subject to removal once we have a better way of doing this.

Approved by:	jhibbits
Relnotes:	yes
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D23156
2020-05-07 19:32:49 +00:00
Ed Maste
74cd06b42e Expose the kernel's build-ID through sysctl
After our migration (of certain architectures) to lld the kernel is built
with a unique build-ID.  Make it available via a sysctl and uname(1) to
allow the user to identify their running kernel.

Submitted by:	Ali Mashtizadeh <ali_mashtizadeh.com>
MFC after:	2 weeks
Relnotes:	Yes
Event:		Waterloo Hackathon 2019
Differential Revision:	https://reviews.freebsd.org/D20326
2019-06-04 13:07:10 +00:00
Leandro Lupori
0632bb89db Fix PPC64 kernel build with clang8 + lld8
This patch fixes the following lld link errors:

- unsupported dynamic relocations on read-only sections
- out-of-range TOC references

Submitted by:	git_bdragon.rtk0.net
Reviewed by:	jhibbits, luporl
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D19352
2019-05-22 15:56:41 +00:00
Justin Hibbits
484717a4ac powerpc64: Fix kernel ldscript to only emit one PT_LOAD segment
Summary:
kexec-lite cannot currently handle multiple PT_LOAD segments.  In some
cases the compiler generates multiple PT_LOAD segments for an unknown
reason, causing boot to fail from kexec-lite.

Submitted by:	Brandon Bergren (older version)
Differential Revision: https://reviews.freebsd.org/D19574
2019-03-29 03:01:21 +00:00
Justin Hibbits
290646564b powerpc64: Align frequently used/exclusive data on cacheline boundaries
This is effectively a merge from amd64 of r312888, r323235, and r333486.

I've been running this on my POWER9 Talos for some time now with no ill
effects.

Suggested by:	mjg
2018-08-19 19:00:44 +00:00
Nathan Whitehorn
70f654991a Add support for 64-bit PowerPC kernels to be directly loaded by kexec, which
is used as the bootloader on a number of PPC64 platforms. This involves the
following pieces:
- Making the first instruction a valid kernel entry point, since kexec
  ignores the ELF entry value. This requires a separate section and linker
  magic to prevent the linker from filling the beginning of the section
  with stubs.
- Adding an entry point at 0x60 past the first instruction for systems
  lacking firmware CPU shutdown support (notably PS3).
- Linker script changes to support the above.

MFC after:	1 month
2017-12-29 20:30:10 +00:00
Nathan Whitehorn
7cc0ad62e3 Make __startkernel line up with KERNBASE, so that the math to compute the
applied relocation offset in link_elf.c works as intended. We may want to
revisit how that works in future, for example by having elf_reloc_self()
actually store the numbers it is using rather than computing them later,
but this fixes symbol lookup after r326203.

Reported by:	andreast@
Pointy hat to:	me
2017-12-19 15:50:46 +00:00
Nathan Whitehorn
25449e73a1 Avoid emitting a PT_INTERP section for powerpc64 kernels and arrange for
the first instruction to be at the start of the text segment. This allows
the kernel to be booted correctly by stock kexec-lite.

MFC after:	2 weeks
2017-11-25 21:45:51 +00:00
Ed Maste
45eff3df96 remove CONSTRUCTORS from kernel linker scripts
The linker script CONSTRUCTORS keyword is only meaningful "when linking
object file formats which do not support arbitrary sections, such as
ECOFF and XCOFF"[1] and is ignored for other object file formats.

LLVM's lld does not yet accept (and ignore) CONSTRUCTORS, so just remove
CONSTRUCTORS from the linker scripts as it has no effect.

[1] https://sourceware.org/binutils/docs/ld/Output-Section-Keywords.html

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D7343
2016-07-28 13:54:46 +00:00
Nathan Whitehorn
466d476aac Fix build with new binutils. This gets a working kernel with GCC 5.2 and
binutils 2.24. Without this, the self-relocation code in locore64.S was
failing due to a misaligned TOC section.

MFC after:	2 weeks
2015-11-29 06:40:09 +00:00
Nathan Whitehorn
bb80825435 Refactor PowerPC (especially AIM) init sequence to be less baroque.
MFC after:	2 months
2015-01-18 18:32:43 +00:00
Baptiste Daroussin
66c8095956 Rename elf*-powerpc into elf*-powerpc-freebsd in binutils
The powerpc support was the only supported architecture not prepending the elf format name
with "-freebsd" in base this change makes it consistent with other architectures.
On newer version of binutils the powerpc format is also prepended with "-freebsd".

Also modify the kernel ldscripts in that regards.

As a result it is now possible cross build the kernel on powerpc using newer binutils

Differential Revision:	https://reviews.freebsd.org/D926
Differential Revision:	https://reviews.freebsd.org/D928
2014-10-10 06:24:09 +00:00
Andreas Tobler
618abe8ba1 Add the .opd section, this is helps booting a profiled kernel.
Adjust the OUTPUT_ARCH and use the builtin ALIGN() to adjust the data segment.
2012-01-20 18:52:31 +00:00
Warner Losh
6ba63f2d8c In fact, we don't need any of these __DYNAMIC. it is a.out leftover and commented out. 2011-01-20 19:24:50 +00:00
Nathan Whitehorn
060d347db3 Add powerpc64 kernel ldscript. 2010-07-13 05:43:43 +00:00