d5094bcb | 12-Jul-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: define time_t in terms of __kernel_old_time_t
Nolibc assumes that the kernel ABI is using a time values that are as large as a long integer. For most ABIs this holds true. But for x32
tools/nolibc: define time_t in terms of __kernel_old_time_t
Nolibc assumes that the kernel ABI is using a time values that are as large as a long integer. For most ABIs this holds true. But for x32 this is not correct, as it uses 32bit longs but 64bit times.
Also the 'struct stat' implementation of nolibc relies on timespec::tv_sec and time_t being the same type. While timespec::tv_sec comes from the kernel and is of type __kernel_old_time_t, time_t is defined within nolibc.
Switch to the __kernel_old_time_t to always get the correct type.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20250712-nolibc-x32-v1-1-6d81cb798710@weissschuh.net Acked-by: Willy Tarreau <w@1wt.eu>
show more ...
|
f6f6be0c | 20-Jun-2025 |
Thomas Weißschuh <thomas.weissschuh@linutronix.de> |
tools/nolibc: drop s390 clang target override
tools/scripts/Makefile.include now has the same override, removing the need for the one in the nolibc Makefile.
Drop the superfluous custom override.
tools/nolibc: drop s390 clang target override
tools/scripts/Makefile.include now has the same override, removing the need for the one in the nolibc Makefile.
Drop the superfluous custom override.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Link: https://lore.kernel.org/r/20250620-tools-cross-s390-v2-2-ecda886e00e5@linutronix.de Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
31db7b6a | 07-Jul-2025 |
Thomas Weißschuh <thomas.weissschuh@linutronix.de> |
tools/nolibc: avoid false-positive -Wmaybe-uninitialized through waitpid()
The compiler does not know that waitid() will only ever return 0 or -1. If waitid() would return a positive value than wait
tools/nolibc: avoid false-positive -Wmaybe-uninitialized through waitpid()
The compiler does not know that waitid() will only ever return 0 or -1. If waitid() would return a positive value than waitpid() would return that same value and *status would not be initialized. However users calling waitpid() know that the only possible return values of it are 0 or -1. They therefore might check for errors with 'ret == -1' or 'ret < 0' and use *status otherwise. The compiler will then warn about the usage of a potentially uninitialized variable.
Example:
$ cat test.c #include <stdio.h> #include <unistd.h>
int main(void) { int ret, status;
ret = waitpid(0, &status, 0); if (ret == -1) return 0;
printf("status %x\n", status);
return 0; }
$ gcc --version gcc (GCC) 15.1.1 20250425
$ gcc -Wall -Os -Werror -nostdlib -nostdinc -static -Iusr/include -Itools/include/nolibc/ -o /dev/null test.c test.c: In function ‘main’: test.c:12:9: error: ‘status’ may be used uninitialized [-Werror=maybe-uninitialized] 12 | printf("status %x\n", status); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.c:6:18: note: ‘status’ was declared here 6 | int ret, status; | ^~~~~~ cc1: all warnings being treated as errors
Avoid the warning by normalizing waitid() errors to '-1' in waitpid().
Fixes: 0c89abf5ab3f ("tools/nolibc: implement waitpid() in terms of waitid()") Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250707-nolibc-waitpid-uninitialized-v1-1-dcd4e70bcd8f@linutronix.de Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
4a401290 | 04-Jul-2025 |
Thomas Weißschuh <thomas.weissschuh@linutronix.de> |
selftests/nolibc: correctly report errors from printf() and friends
When an error is encountered by printf() it needs to be reported. errno() is already set by the callback.
sprintf() is different,
selftests/nolibc: correctly report errors from printf() and friends
When an error is encountered by printf() it needs to be reported. errno() is already set by the callback.
sprintf() is different, but that keeps working and is already tested.
Also add a new test.
Fixes: 7e4346f4a3a6 ("tools/nolibc/stdio: add a minimal [vf]printf() implementation") Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250704-nolibc-printf-error-v1-2-74b7a092433b@linutronix.de Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
fb476dfb | 03-Jul-2025 |
Mark Brown <broonie@kernel.org> |
tools/nolibc: Provide vfork()
To allow testing of vfork() support in the arm64 basic-gcs test provide an implementation for nolibc, using the vfork() syscall if one is available and otherwise clone3
tools/nolibc: Provide vfork()
To allow testing of vfork() support in the arm64 basic-gcs test provide an implementation for nolibc, using the vfork() syscall if one is available and otherwise clone3(). We implement in terms of clone3() since the order of the arguments for clone() varies between architectures.
As for fork() SPARC returns the parent PID rather than 0 in the child for vfork() so needs custom handling.
Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20250703-arm64-gcs-vfork-exit-v3-2-1e9a9d2ddbbe@kernel.org Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
8c11625a | 03-Jul-2025 |
Mark Brown <broonie@kernel.org> |
tools/nolibc: Replace ifdef with if defined() in sys.h
Thomas has requested that if defined() be used in place of ifdef but currently ifdef is used consistently in sys.h. Update all the instances of
tools/nolibc: Replace ifdef with if defined() in sys.h
Thomas has requested that if defined() be used in place of ifdef but currently ifdef is used consistently in sys.h. Update all the instances of ifdef to if defined().
Suggested-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20250703-arm64-gcs-vfork-exit-v3-1-1e9a9d2ddbbe@kernel.org Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
02217ad4 | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
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() wh
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
show more ...
|
a6a2a8a4 | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: MIPS: add support for N64 and N32 ABIs
Add support for the MIPS 64bit N64 and ILP32 N32 ABIs.
In addition to different byte orders and ABIs there are also different releases of the MI
tools/nolibc: MIPS: add support for N64 and N32 ABIs
Add support for the MIPS 64bit N64 and ILP32 N32 ABIs.
In addition to different byte orders and ABIs there are also different releases of the MIPS architecture. To avoid blowing up the test matrix, only add a subset of all possible test combinations.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Link: https://lore.kernel.org/r/20250623-nolibc-mips-n32-v3-4-6ae2d89f4259@weissschuh.net
show more ...
|
69891dca | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: MIPS: drop noreorder option
There are no more statements in the assembly code which would require the usage of ".set noreorder".
Remove the option.
This also allows removal of the ma
tools/nolibc: MIPS: drop noreorder option
There are no more statements in the assembly code which would require the usage of ".set noreorder".
Remove the option.
This also allows removal of the manual "nop" instruction in the delay slot.
Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk> Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.2502172208570.65342@angie.orcam.me.uk/ Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Link: https://lore.kernel.org/r/20250623-nolibc-mips-n32-v3-3-6ae2d89f4259@weissschuh.net
show more ...
|
36aab169 | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: MIPS: drop manual stack pointer alignment
The stack pointer is already aligned by the kernel to a multiple of 16. All modifications of the register have been removed from the entrypoin
tools/nolibc: MIPS: drop manual stack pointer alignment
The stack pointer is already aligned by the kernel to a multiple of 16. All modifications of the register have been removed from the entrypoint, so the manual realignment is unnecessary.
Drop the manual alignment.
Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk> Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.2502161523290.65342@angie.orcam.me.uk/ Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Link: https://lore.kernel.org/r/20250623-nolibc-mips-n32-v3-2-6ae2d89f4259@weissschuh.net
show more ...
|
f1e30334 | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: MIPS: drop $gp setup
The setup of the global pointer "$gp" register was necessary when the C entrypoint was called through "jal <symbol>". However since commit 0daf8c86a451 ("tools/nol
tools/nolibc: MIPS: drop $gp setup
The setup of the global pointer "$gp" register was necessary when the C entrypoint was called through "jal <symbol>". However since commit 0daf8c86a451 ("tools/nolibc: mips: load current function to $t9") "jalr" is used instead which does not require "$gp".
Remove the unnecessary $gp setup, simplifying the code and opening the road for some other cleanups.
Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk> Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.2502172208570.65342@angie.orcam.me.uk/ Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Tested-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Link: https://lore.kernel.org/r/20250623-nolibc-mips-n32-v3-1-6ae2d89f4259@weissschuh.net
show more ...
|
01e8a6d0 | 23-Jun-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: use arm64 name over aarch64
Nolibc generally uses the kernel's architecture names. aarch64 is the only exception.
Remove the special case. Nothing changes for the users.
Acked-by: Wi
tools/nolibc: use arm64 name over aarch64
Nolibc generally uses the kernel's architecture names. aarch64 is the only exception.
Remove the special case. Nothing changes for the users.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250623-nolibc-aarch64-arm64-v1-1-a2892f1c1b27@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
cc6dc5fb | 18-Jun-2025 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc: merge i386 and x86_64 into a single x86 arch
This remained the only exception to the kernel's architectures organization and it's always a bit cumbersome to deal with. Let's merge i386
tools/nolibc: merge i386 and x86_64 into a single x86 arch
This remained the only exception to the kernel's architectures organization and it's always a bit cumbersome to deal with. Let's merge i386 and x86_64 into x86. This will result in a single arch-x86.h file by default, and we'll no longer need to merge the two manually during installation. Requesting either i386 or x86_64 will also result in installing x86.
Acked-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu>
show more ...
|
2217abe0 | 15-May-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: move NULL and offsetof() to sys/stddef.h
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarre
tools/nolibc: move NULL and offsetof() to sys/stddef.h
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-8-74f82eea3b59@weissschuh.net
show more ...
|
0f971358 | 15-May-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: move uname() and friends to sys/utsname.h
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarr
tools/nolibc: move uname() and friends to sys/utsname.h
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-7-74f82eea3b59@weissschuh.net
show more ...
|
e1211e22 | 15-May-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: move makedev() and friends to sys/sysmacros.h
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy
tools/nolibc: move makedev() and friends to sys/sysmacros.h
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-6-74f82eea3b59@weissschuh.net
show more ...
|
90895247 | 15-May-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: move getrlimit() and friends to sys/resource.h
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy
tools/nolibc: move getrlimit() and friends to sys/resource.h
This is the location regular userspace expects these definitions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-5-74f82eea3b59@weissschuh.net
show more ...
|
2efb9050 | 15-May-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: move reboot() to sys/reboot.h
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu>
tools/nolibc: move reboot() to sys/reboot.h
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-4-74f82eea3b59@weissschuh.net
show more ...
|
3edd5365 | 15-May-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: move prctl() to sys/prctl.h
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> L
tools/nolibc: move prctl() to sys/prctl.h
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-3-74f82eea3b59@weissschuh.net
show more ...
|
6e7c805a | 15-May-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: move mount() to sys/mount.h
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> L
tools/nolibc: move mount() to sys/mount.h
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-2-74f82eea3b59@weissschuh.net
show more ...
|
7281be58 | 15-May-2025 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: move ioctl() to sys/ioctl.h
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> L
tools/nolibc: move ioctl() to sys/ioctl.h
This is the location regular userspace expects this definition.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250515-nolibc-sys-v1-1-74f82eea3b59@weissschuh.net
show more ...
|
59303930 | 28-Apr-2025 |
Thomas Weißschuh <thomas.weissschuh@linutronix.de> |
tools/nolibc: implement wait() in terms of waitpid()
Newer architectures like riscv 32-bit are missing sys_wait4(). Make use of the fact that wait(&status) is defined to be equivalent to waitpid(-1,
tools/nolibc: implement wait() in terms of waitpid()
Newer architectures like riscv 32-bit are missing sys_wait4(). Make use of the fact that wait(&status) is defined to be equivalent to waitpid(-1, status, 0) to implement it on all architectures.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20250428-nolibc-misc-v2-15-3c043eeab06c@linutronix.de Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|