]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tools/nolibc: Implement strerror() in terms of strerror_r()
authorDavid Laight <david.laight.linux@gmail.com>
Sun, 8 Mar 2026 11:37:28 +0000 (11:37 +0000)
committerThomas Weißschuh <linux@weissschuh.net>
Fri, 20 Mar 2026 16:46:07 +0000 (17:46 +0100)
commit2177dd375d087012907e389f787b21ac38bb1785
tree365fa498a048ab5398a4fd6c9ee2b9ed08e22b97
parentab7cd329a837711b88600e5d776836f16a0e8de8
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>
tools/include/nolibc/stdio.h
tools/testing/selftests/nolibc/nolibc-test.c