| 079ec6a3 | 30-Sep-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: compiler: add macro __nolibc_fallthrough
Recent version of GCC and clang gained -Wimplicit-fallthrough, warning about implicit fall-through between switch labels. As nolibc does not co
tools/nolibc: compiler: add macro __nolibc_fallthrough
Recent version of GCC and clang gained -Wimplicit-fallthrough, warning about implicit fall-through between switch labels. As nolibc does not control the compilation flags, this can trigger warnings for when built by the user. Make use of the "fallthrough" attribute to explicitly annotate the expected fall-throughs and silence the warning.
Link: https://lore.kernel.org/r/20240930-nolibc-fallthrough-v2-1-2e8d10fe3430@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 25fb329a | 12-Aug-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: x86_64: use local label in memcpy/memmove
Compiling arch-x86_64.h with clang and binutils LD yields duplicate label errors:
.../gcc-13.2.0-nolibc/x86_64-linux/bin/x86_64-linux-ld: err
tools/nolibc: x86_64: use local label in memcpy/memmove
Compiling arch-x86_64.h with clang and binutils LD yields duplicate label errors:
.../gcc-13.2.0-nolibc/x86_64-linux/bin/x86_64-linux-ld: error: LLVM gold plugin: <inline asm>:44:1: symbol '.Lbackward_copy' is already defined .Lbackward_copy:leaq -1(%rdi, %rcx, 1), %rdi
Instead of a local symbol use a local label which can be defined multiple times and therefore avoids the error.
Reviewed-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240812-nolibc-lto-v2-3-736af7bbefa8@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| ff7b9abb | 12-Aug-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: stackprotector: mark implicitly used symbols as used
During LTO the references from the compiler-generated prologue and epilogues to the stack protector symbols are not visible and the
tools/nolibc: stackprotector: mark implicitly used symbols as used
During LTO the references from the compiler-generated prologue and epilogues to the stack protector symbols are not visible and the symbols are removed. This will then lead to errors during linking. As those symbols are already #ifdeffed-out if unused mark them as "used" to prevent their removal.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240812-nolibc-lto-v2-2-736af7bbefa8@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 0021d667 | 12-Aug-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: crt: mark _start_c() as used
During LTO the reference from the asm startup code to the _start_c() function is not visible and _start_c() is removed. This will then lead to errors durin
tools/nolibc: crt: mark _start_c() as used
During LTO the reference from the asm startup code to the _start_c() function is not visible and _start_c() is removed. This will then lead to errors during linking. As _start_c() is indeed always used, mark it as such.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240812-nolibc-lto-v2-1-736af7bbefa8@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| e098eebb | 07-Aug-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: compiler: use attribute((naked)) if available
The current entrypoint attributes optimize("Os", "omit-frame-pointer") are intended to avoid all compiler generated code, like function po
tools/nolibc: compiler: use attribute((naked)) if available
The current entrypoint attributes optimize("Os", "omit-frame-pointer") are intended to avoid all compiler generated code, like function porologue and epilogue. This is the exact usecase implemented by the attribute "naked".
Unfortunately this is not implemented by GCC for all targets, so only use it where available. This also provides compatibility with clang, which recognizes the "naked" attribute but not the previously used attribute "optimized".
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-6-c20f2f5fc7c2@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| ef32e9b6 | 07-Aug-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: move entrypoint specifics to compiler.h
The specific attributes for the _start entrypoint are duplicated for each architecture. Deduplicate it into a dedicated #define into compiler.h.
tools/nolibc: move entrypoint specifics to compiler.h
The specific attributes for the _start entrypoint are duplicated for each architecture. Deduplicate it into a dedicated #define into compiler.h.
For clang compatibility, the epilogue will also need to be adapted, so move that one, too.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-5-c20f2f5fc7c2@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 02a62b55 | 07-Aug-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: compiler: introduce __nolibc_has_attribute()
Recent compilers support __has_attribute() to check if a certain compiler attribute is supported. Unfortunately we have to first check if _
tools/nolibc: compiler: introduce __nolibc_has_attribute()
Recent compilers support __has_attribute() to check if a certain compiler attribute is supported. Unfortunately we have to first check if __has_attribute is supported in the first place and then if a specific attribute is present. These two checks can't be folded into a single condition as that would lead to errors.
Nesting the two conditions like below works, but becomes ugly as soon as #else blocks are used as those need to be duplicated for both levels of #if.
#if defined __has_attribute # if __has_attribute (nonnull) # define ATTR_NONNULL __attribute__ ((nonnull)) # endif #endif
Introduce a new helper which makes the usage of __has_attribute() nicer and migrate the current user to it.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-4-c20f2f5fc7c2@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 1daea158 | 07-Aug-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: powerpc: limit stack-protector workaround to GCC
As mentioned in the comment, the workaround for __attribute__((no_stack_protector)) is only necessary on GCC. Avoid applying the workar
tools/nolibc: powerpc: limit stack-protector workaround to GCC
As mentioned in the comment, the workaround for __attribute__((no_stack_protector)) is only necessary on GCC. Avoid applying the workaround on clang, as clang does not recognize __attribute__((__optimize__)) and would fail.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-3-c20f2f5fc7c2@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 0daf8c86 | 07-Aug-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: mips: load current function to $t9
The MIPS calling convention requires the address of the current function to be available in $t9. This was not done so far.
For GCC this seems to hav
tools/nolibc: mips: load current function to $t9
The MIPS calling convention requires the address of the current function to be available in $t9. This was not done so far.
For GCC this seems to have worked, but when compiled with clang the executable segfault instantly. Properly load the address of _start_c() into $t9 before calling it.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-2-c20f2f5fc7c2@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 55850eb4 | 07-Aug-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: arm: use clang-compatible asm syntax
The clang assembler rejects the current syntax. Switch to a syntax accepted by both GCC and clang.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https:
tools/nolibc: arm: use clang-compatible asm syntax
The clang assembler rejects the current syntax. Switch to a syntax accepted by both GCC and clang.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-1-c20f2f5fc7c2@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 754283ce | 28-Jul-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: pass argc, argv and envp to constructors
Since 2005 glibc has passed argc, argv, and envp to all constructors. As it is cheap and easy to do so, mirror that behaviour in nolibc. This m
tools/nolibc: pass argc, argv and envp to constructors
Since 2005 glibc has passed argc, argv, and envp to all constructors. As it is cheap and easy to do so, mirror that behaviour in nolibc. This makes it easier to migrate applications to nolibc.
Link: https://lore.kernel.org/r/20240728-nolibc-constructor-args-v1-1-36d0bf5cd4c0@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| ae1f550e | 25-Jul-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: add stdbool.h header
stdbool.h is very simple. Provide an implementation for the user convenience.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240725-nolibc-s
tools/nolibc: add stdbool.h header
stdbool.h is very simple. Provide an implementation for the user convenience.
Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240725-nolibc-stdbool-v1-1-a6ee2c80bcde@weissschuh.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| d20d0b10 | 26-Apr-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: implement strerror()
strerror() is commonly used. For example in kselftest which currently needs to do an #ifdef NOLIBC to handle the lack of strerror().
Keep it simple and reuse the
tools/nolibc: implement strerror()
strerror() is commonly used. For example in kselftest which currently needs to do an #ifdef NOLIBC to handle the lack of strerror().
Keep it simple and reuse the output format of perror() for strerror().
Acked-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 0cf24d36 | 25-Apr-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: implement strtol() and friends
The implementation always works on uintmax_t values.
This is inefficient when only 32bit are needed. However for all functions this only happens for str
tools/nolibc: implement strtol() and friends
The implementation always works on uintmax_t values.
This is inefficient when only 32bit are needed. However for all functions this only happens for strtol() on 32bit platforms.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/r/20240425-nolibc-strtol-v1-2-bfeef7846902@weissschuh.net
show more ...
|
| 0adab2b6 | 14-Apr-2024 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: add support for uname(2)
All supported kernels are assumed to use struct new_utsname. This is validated in test_uname().
uname(2) can for example be used in ksft_min_kernel_version()
tools/nolibc: add support for uname(2)
All supported kernels are assumed to use struct new_utsname. This is validated in test_uname().
uname(2) can for example be used in ksft_min_kernel_version() from the kernels selftest framework.
Link: https://lore.kernel.org/lkml/20240412123536.GA32444@redhat.com/ Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Acked-by: Willy Tarreau <w@1wt.eu>
show more ...
|
| fbffce81 | 18-Feb-2024 |
Rodrigo Campos <rodrigo@sdfg.com.ar> |
tools/nolibc: Fix strlcpy() return code and size usage
The return code should always be strlen(src), and we should copy at most size-1 bytes.
While we are there, make sure to null-terminate the dst
tools/nolibc: Fix strlcpy() return code and size usage
The return code should always be strlen(src), and we should copy at most size-1 bytes.
While we are there, make sure to null-terminate the dst buffer if we copied something.
Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 34d232c3 | 18-Feb-2024 |
Rodrigo Campos <rodrigo@sdfg.com.ar> |
tools/nolibc: Fix strlcat() return code and size usage
The return code should always be strlen(src) + strnlen(dst, size).
Let's make sure to copy at most size-1 bytes from src and null-terminate th
tools/nolibc: Fix strlcat() return code and size usage
The return code should always be strlen(src) + strnlen(dst, size).
Let's make sure to copy at most size-1 bytes from src and null-terminate the dst buffer if we did copied something.
While we can use strnlen() and strncpy() to implement strlcat(), this is simple enough and results in shorter code when compiled.
Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| 689230b6 | 18-Feb-2024 |
Rodrigo Campos <rodrigo@sdfg.com.ar> |
tools/nolibc/string: export strlen()
As with commit 8d304a374023, "tools/nolibc/string: export memset() and memmove()", gcc -Os without -ffreestanding may fail to compile with:
cc -fno-asynchronou
tools/nolibc/string: export strlen()
As with commit 8d304a374023, "tools/nolibc/string: export memset() and memmove()", gcc -Os without -ffreestanding may fail to compile with:
cc -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib -lgcc -static -o test test.c /usr/bin/ld: /tmp/cccIasKL.o: in function `main': test.c:(.text.startup+0x1e): undefined reference to `strlen' collect2: error: ld returned 1 exit status
As on the aforementioned commit, this patch adds a section to export this function so compilation works on those cases too.
Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
show more ...
|
| a0bb5f88 | 22-Nov-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: add support for getrlimit/setrlimit
The implementation uses the prlimit64 systemcall as that is available on all architectures.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
tools/nolibc: add support for getrlimit/setrlimit
The implementation uses the prlimit64 systemcall as that is available on all architectures.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/lkml/20231123-nolibc-rlimit-v1-2-a428b131de2a@weissschuh.net/ Acked-by: Willy Tarreau <w@1wt.eu>
show more ...
|