tools/nolibc: add support for SuperH
authorThomas Weißschuh <linux@weissschuh.net>
Mon, 23 Jun 2025 21:15:54 +0000 (23:15 +0200)
committerThomas Weißschuh <linux@weissschuh.net>
Fri, 4 Jul 2025 11:26:07 +0000 (13:26 +0200)
commit02217ad447d7b1dd592cfc8253a07375d0b32aa7
treefbbfcee49d68feb1cd4bd8b958c1d87dd673af36
parent358b2511d7e687a243383fbbba9cb21b242f48b8
tools/nolibc: add support for SuperH

Add support for SuperH/"sh" to nolibc.
Only sh4 is tested for now.

The startup code is special:

__nolibc_entrypoint_epilogue() calls __builtin_unreachable() which emits
a call to abort(). To make this work a function prologue is generated to
set up a GOT pointer which corrupts "sp".
__builtin_unreachable() is necessary for __attribute__((noreturn)).
Also depending on compiler flags (for example -fPIC) even more prologue
is generated.

Work around this by defining a nested function in asm.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70216
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Acked-by: Rob Landley <rob@landley.net>
Acked-by: D. Jeff Dionne <jeff@coresemi.io>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Link: https://lore.kernel.org/r/20250623-nolibc-sh-v2-3-0f5b4b303025@weissschuh.net
tools/include/nolibc/arch-sh.h [new file with mode: 0644]
tools/include/nolibc/arch.h
tools/testing/selftests/nolibc/Makefile.nolibc
tools/testing/selftests/nolibc/run-tests.sh