linux/tools/include/nolibc
David Laight 2177dd375d tools/nolibc: Implement strerror() in terms of strerror_r()
strerror() can be the only part of a program that has a .data section.
This requires 4k in the program file.

Add a simple implementation of strerror_r() and use that in strerror()
so that the "errno=" string is copied at run-time.
Use __builtin_memcpy() because that optimises away the input string
and just writes the required constants to the target buffer.

Code size change largely depends on whether the inlining decision for
strerror() changes.

Change the tests to use the normal EXPECT_VFPRINTF() when testing %m.
Skip the tests when !is_nolibc.

Signed-off-by: David Laight <david.laight.linux@gmail.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260308113742.12649-4-david.laight.linux@gmail.com
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
History 2026-03-20 17:46:07 +01:00
..
sys tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
.gitignore tools/nolibc: Add gitignore to avoid git complaints about sysroot 2023-03-20 08:45:21 -07:00
arch-arm.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
arch-arm64.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
arch-loongarch.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
arch-m68k.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
arch-mips.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
arch-powerpc.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
arch-riscv.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
arch-s390.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
arch-sh.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
arch-sparc.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
arch-x86.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
arch.h nolibc changes for v6.19 2025-12-03 09:23:25 -08:00
compiler.h tools/nolibc: Add _NOLIBC_OPTIMIZER_HIDE_VAR() to compiler.h 2026-03-20 17:46:06 +01:00
crt.h tools/nolibc: add option to disable runtime 2025-10-29 16:29:16 +01:00
ctype.h tools/nolibc: include nolibc.h early from all header files 2025-05-21 15:31:50 +02:00
dirent.h tools/nolibc/dirent: avoid errno in readdir_r 2025-10-29 16:29:14 +01:00
elf.h tools/nolibc: include nolibc.h early from all header files 2025-05-21 15:31:50 +02:00
errno.h tools/nolibc: include nolibc.h early from all header files 2025-05-21 15:31:50 +02:00
fcntl.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
getopt.h tools/nolibc: avoid using plain integer as NULL pointer 2025-11-09 21:29:57 +01:00
inttypes.h tools/nolibc: add the more portable inttypes.h 2025-11-02 14:28:20 +01:00
limits.h tools/nolibc: add limits.h shim header 2025-03-03 20:00:12 +01:00
Makefile tools/nolibc: always use 64-bit mode for s390 header checks 2026-01-04 10:28:56 +01:00
math.h tools/nolibc: add abs() and friends 2025-05-21 15:32:05 +02:00
nolibc.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
poll.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
sched.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
signal.h tools/nolibc: include nolibc.h early from all header files 2025-05-21 15:31:50 +02:00
stackprotector.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
std.h tools/nolibc: always use 64-bit time types 2026-01-04 10:29:03 +01:00
stdarg.h tools/nolibc: add stdarg.h header 2023-10-12 21:13:52 +02:00
stdbool.h tools/nolibc: add stdbool.h header 2024-07-29 07:52:57 +02:00
stddef.h tools/nolibc: move NULL and offsetof() to sys/stddef.h 2025-05-21 15:32:25 +02:00
stdint.h tools/nolibc: use intmax definitions from compiler 2025-04-22 10:56:24 +02:00
stdio.h tools/nolibc: Implement strerror() in terms of strerror_r() 2026-03-20 17:46:07 +01:00
stdlib.h tools/nolibc: Optimise and common up the number to ascii functions 2026-03-20 17:45:57 +01:00
string.h tools/nolibc: add missing memchr() to string.h 2025-11-02 12:11:48 +01:00
sys.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
time.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00
types.h tools/nolibc: always use 64-bit time types 2026-01-04 10:29:03 +01:00
unistd.h tools/nolibc: rename my_syscallX() to __nolibc_syscallX() 2026-02-25 08:21:17 +01:00