opnsense-src/lib/libc/tests/sys
Timothy Pearson 8efa35fea3 libc/powerpc64: Fix swapcontext(3)
On PowerPC platforms a valid link to the Table of Contents (TOC) is
required for PLT lookups to function.  This TOC pointer is stored in
a dedicated register, and is used along with the stack pointer by both
C prologue and PLT lookup code.

When calling swapcontext() with uc_link != NULL, a PLT lookup to
setcontext(3) is attempted from within the _ctx_done context.  The
exiting process has usually trashed both r1 and r2 at this point,
leading to a crash within the PLT lookup before setcontext(2) is
reached to restore the linked context.

Save and restore r2 as in a regular function.  This ensures the
subsequent PLT lookup to setcontext(3) succeeds.

Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>

MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1759
2025-07-13 14:00:56 -04:00
..
brk_test.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
cpuset_test.c Remove a few more stray __FBSDID uses 2023-09-25 07:49:52 -07:00
errno_test.c libc/sys: add errno test 2024-02-25 22:35:17 +02:00
Makefile libc/powerpc64: Fix swapcontext(3) 2025-07-13 14:00:56 -04:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
mlock_helper.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
queue_test.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
sendfile_test.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
swapcontext_test.c libc/powerpc64: Fix swapcontext(3) 2025-07-13 14:00:56 -04:00