Revision tags: v6.6.25, v6.6.24, v6.6.23, v6.6.16, v6.6.15, v6.6.14, v6.6.13, v6.6.12, v6.6.11, v6.6.10, v6.6.9, v6.6.8, v6.6.7, v6.6.6, v6.6.5, v6.6.4, v6.6.3, v6.6.2, v6.5.11, v6.6.1, v6.5.10, v6.6, v6.5.9, v6.5.8, v6.5.7, v6.5.6, v6.5.5, v6.5.4, v6.5.3, v6.5.2, v6.1.51, v6.5.1, v6.1.50, v6.5, v6.1.49, v6.1.48, v6.1.46, v6.1.45, v6.1.44, v6.1.43, v6.1.42, v6.1.41, v6.1.40, v6.1.39 |
|
#
67d108e2 |
| 10-Jul-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: completely remove optional environ support
In commit 52e423f5b93e ("tools/nolibc: export environ as a weak symbol on i386") and friends the asm startup logic was extended to directly p
tools/nolibc: completely remove optional environ support
In commit 52e423f5b93e ("tools/nolibc: export environ as a weak symbol on i386") and friends the asm startup logic was extended to directly populate the "environ" array.
This makes it impossible for "environ" to be dropped by the linker. Therefore also drop the other logic to handle non-present "environ".
Also add a testcase to validate the initialization of environ.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu>
show more ...
|
Revision tags: v6.1.38, v6.1.37, v6.1.36, v6.4, v6.1.35, v6.1.34, v6.1.33, v6.1.32, v6.1.31, v6.1.30, v6.1.29, v6.1.28, v6.1.27, v6.1.26, v6.3, v6.1.25, v6.1.24 |
|
#
0738c2d7 |
| 06-Apr-2023 |
Thomas Weißschuh <linux@weissschuh.net> |
tools/nolibc: use __inline__ syntax
When building in strict C89 mode the "inline" keyword is unknown. While "__inline__" is non-standard it is used by the kernel headers themselves. So the used comp
tools/nolibc: use __inline__ syntax
When building in strict C89 mode the "inline" keyword is unknown. While "__inline__" is non-standard it is used by the kernel headers themselves. So the used compilers would have to support it or the users shim it with a #define.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
Revision tags: v6.1.23, v6.1.22, v6.1.21, v6.1.20, v6.1.19, v6.1.18, v6.1.17, v6.1.16, v6.1.15, v6.1.14, v6.1.13, v6.2, v6.1.12, v6.1.11, v6.1.10, v6.1.9, v6.1.8, v6.1.7, v6.1.6, v6.1.5, v6.0.19 |
|
#
c61a0780 |
| 10-Jan-2023 |
Ammar Faizi <ammarfaizi2@gnuweeb.org> |
nolibc/stdlib: Implement `getauxval(3)` function
Previous commits save the address of the auxiliary vector into a global variable @_auxv. This commit creates a new function 'getauxval()' as a helper
nolibc/stdlib: Implement `getauxval(3)` function
Previous commits save the address of the auxiliary vector into a global variable @_auxv. This commit creates a new function 'getauxval()' as a helper function to get the auxv value based on the given key.
The behavior of this function is identic with the function documented in 'man 3 getauxval'. This function is also needed to implement 'getpagesize()' function that we will wire up in the next patches.
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
#
55abdd1f |
| 09-Jan-2023 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc: fix missing includes causing build issues at -O0
After the nolibc includes were split to facilitate portability from standard libcs, programs that include only what they need may miss
tools/nolibc: fix missing includes causing build issues at -O0
After the nolibc includes were split to facilitate portability from standard libcs, programs that include only what they need may miss some symbols which are needed by libgcc. This is the case for raise() which is needed by the divide by zero code in some architectures for example.
Regardless, being able to include only the apparently needed files is convenient.
Instead of trying to move all exported definitions to a single file, since this can change over time, this patch takes another approach consisting in including the nolibc header at the end of all standard include files. This way their types and functions are already known at the moment of inclusion, and including any single one of them is sufficient to bring all the required ones.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
Revision tags: v6.0.18, v6.1.4, v6.1.3, v6.0.17, v6.1.2, v6.0.16, v6.1.1, v6.0.15, v6.0.14, v6.0.13, v6.1, v6.0.12, v6.0.11, v6.0.10, v5.15.80, v6.0.9, v5.15.79, v6.0.8, v5.15.78, v6.0.7, v5.15.77, v5.15.76, v6.0.6, v6.0.5, v5.15.75, v6.0.4, v6.0.3, v6.0.2, v5.15.74, v5.15.73, v6.0.1, v5.15.72, v6.0, v5.15.71, v5.15.70, v5.15.69, v5.15.68, v5.15.67, v5.15.66, v5.15.65, v5.15.64, v5.15.63, v5.15.62, v5.15.61, v5.15.60, v5.15.59, v5.19, v5.15.58, v5.15.57, v5.15.56, v5.15.55, v5.15.54, v5.15.53, v5.15.52, v5.15.51, v5.15.50, v5.15.49, v5.15.48, v5.15.47, v5.15.46, v5.15.45, v5.15.44, v5.15.43, v5.15.42, v5.18 |
|
#
1ef150cf |
| 19-May-2022 |
Ammar Faizi <ammarfaizi2@gnuweeb.org> |
tools/nolibc/stdlib: Support overflow checking for older compiler versions
Previously, we used __builtin_mul_overflow() to check for overflow in the multiplication operation in the calloc() function
tools/nolibc/stdlib: Support overflow checking for older compiler versions
Previously, we used __builtin_mul_overflow() to check for overflow in the multiplication operation in the calloc() function. However, older compiler versions don't support this built-in. This patch changes the overflow checking mechanism to make it work on any compiler version by using a division method to check for overflow. No functional change intended. While in there, remove the unused variable `void *orig`.
Link: https://lore.kernel.org/lkml/20220330024114.GA18892@1wt.eu Suggested-by: Willy Tarreau <w@1wt.eu> Cc: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org> Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Acked-by: Willy Tarreau <w@1wt.eu> Reviewed-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
Revision tags: v5.15.41, v5.15.40, v5.15.39, v5.15.38, v5.15.37, v5.15.36, v5.15.35, v5.15.34, v5.15.33 |
|
#
0e0ff638 |
| 29-Mar-2022 |
Ammar Faizi <ammarfaizi2@gnuweeb.org> |
tools/nolibc/stdlib: Implement `malloc()`, `calloc()`, `realloc()` and `free()`
Implement basic dynamic allocator functions. These functions are currently only available on architectures that have n
tools/nolibc/stdlib: Implement `malloc()`, `calloc()`, `realloc()` and `free()`
Implement basic dynamic allocator functions. These functions are currently only available on architectures that have nolibc mmap() syscall implemented. These are not a super-fast memory allocator, but at least they can satisfy basic needs for having heap without libc.
Cc: David Laight <David.Laight@ACULAB.COM> Acked-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
Revision tags: v5.15.32, v5.15.31 |
|
#
2475d37a |
| 23-Mar-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/stdlib: only reference the external environ when inlined
When building with gcc at -O0 we're seeing link errors due to the "environ" variable being referenced by getenv(). The problem i
tools/nolibc/stdlib: only reference the external environ when inlined
When building with gcc at -O0 we're seeing link errors due to the "environ" variable being referenced by getenv(). The problem is that at -O0 gcc will not inline getenv() and will not drop the external reference. One solution would be to locally declare the variable as weak, but then it would appear in all programs even those not using it, and would be confusing to users of getenv() who would forget to set environ to envp.
An alternate approach used in this patch consists in always inlining the outer part of getenv() that references this extern so that it's always dropped when not used. The biggest part of the function was now moved to a new function called _getenv() that's still not inlined by default.
Reported-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Signed-off-by: Willy Tarreau <w@1wt.eu> Tested-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
#
077d0a39 |
| 21-Mar-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/stdlib: add a simple getenv() implementation
This implementation relies on an extern definition of the environ variable, that the caller must declare and initialize from envp.
Signed-o
tools/nolibc/stdlib: add a simple getenv() implementation
This implementation relies on an extern definition of the environ variable, that the caller must declare and initialize from envp.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
Revision tags: v5.17, v5.15.30, v5.15.29, v5.15.28, v5.15.27, v5.15.26, v5.15.25, v5.15.24, v5.15.23, v5.15.22 |
|
#
f0f04f28 |
| 07-Feb-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/stdlib: implement abort()
libgcc uses it for certain divide functions, so it must be exported. Like for memset() we do that in its own section so that the linker can strip it when not n
tools/nolibc/stdlib: implement abort()
libgcc uses it for certain divide functions, so it must be exported. Like for memset() we do that in its own section so that the linker can strip it when not needed.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
#
99cb50ab |
| 07-Feb-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/signal: move raise() to signal.h
This function is normally found in signal.h, and providing the file eases porting of existing programs. Let's move it there.
Signed-off-by: Willy Tarre
tools/nolibc/signal: move raise() to signal.h
This function is normally found in signal.h, and providing the file eases porting of existing programs. Let's move it there.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
#
4619de34 |
| 07-Feb-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/unistd: extract msleep(), sleep(), tcsetpgrp() to unistd.h
These functions are normally provided by unistd.h. For ease of porting, let's create the file and move them there.
Signed-off
tools/nolibc/unistd: extract msleep(), sleep(), tcsetpgrp() to unistd.h
These functions are normally provided by unistd.h. For ease of porting, let's create the file and move them there.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
#
07f47ea0 |
| 07-Feb-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc: move exported functions to their own section
Some functions like raise() and memcpy() are permanently exported because they're needed by libgcc on certain platforms. However most of th
tools/nolibc: move exported functions to their own section
Some functions like raise() and memcpy() are permanently exported because they're needed by libgcc on certain platforms. However most of the time they are not needed and needlessly take space.
Let's move them to their own sub-section, called .text.nolibc_<function>. This allows ld to get rid of them if unused when passed --gc-sections.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
#
6e277371 |
| 07-Feb-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/stdlib: make raise() use the lower level syscalls only
raise() doesn't set errno, so there's no point calling kill(), better call sys_kill(), which also reduces the function's size.
Si
tools/nolibc/stdlib: make raise() use the lower level syscalls only
raise() doesn't set errno, so there's no point calling kill(), better call sys_kill(), which also reduces the function's size.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
#
ac90226d |
| 07-Feb-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/stdlib: avoid a 64-bit shift in u64toh_r()
The build of printf() on mips requires libgcc for functions __ashldi3 and __lshrdi3 due to 64-bit shifts when scanning the input number. These
tools/nolibc/stdlib: avoid a 64-bit shift in u64toh_r()
The build of printf() on mips requires libgcc for functions __ashldi3 and __lshrdi3 due to 64-bit shifts when scanning the input number. These are not really needed in fact since we scan the number 4 bits at a time. Let's arrange the loop to perform two 32-bit shifts instead on 32-bit platforms.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
#
5f493178 |
| 07-Feb-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/stdlib: add utoh() and u64toh()
This adds a pair of functions to emit hex values.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
|
#
b1c21e7d |
| 07-Feb-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/stdlib: add i64toa() and u64toa()
These are 64-bit variants of the itoa() and utoa() functions. They also support reentrant ones, and use the same itoa_buffer. The functions are a bit l
tools/nolibc/stdlib: add i64toa() and u64toa()
These are 64-bit variants of the itoa() and utoa() functions. They also support reentrant ones, and use the same itoa_buffer. The functions are a bit larger than the previous ones in 32-bit mode (86 and 98 bytes on x86_64 and armv7 respectively), which is why we continue to provide them as separate functions.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
#
66c397c4 |
| 07-Feb-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/stdlib: replace the ltoa() function with more efficient ones
The original ltoa() function and the reentrant one ltoa_r() present a number of drawbacks. The divide by 10 generates calls
tools/nolibc/stdlib: replace the ltoa() function with more efficient ones
The original ltoa() function and the reentrant one ltoa_r() present a number of drawbacks. The divide by 10 generates calls to external code from libgcc_s, and the number does not necessarily start at the beginning of the buffer.
Let's rewrite these functions so that they do not involve a divide and only use loops on powers of 10, and implement both signed and unsigned variants, always starting from the buffer's first character. Instead of using a static buffer for each function, we're now using a common one.
In order to avoid confusion with the ltoa() name, the new functions are called itoa_r() and utoa_r() to distinguish the signed and unsigned versions, and for convenience for their callers, these functions now reutrn the number of characters emitted. The ltoa_r() function is just an inline mapping to the signed one and which returns the buffer.
The functions are quite small (86 bytes on x86_64, 68 on armv7) and do not depend anymore on external code.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
#
56d68a3c |
| 07-Feb-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/stdlib: move ltoa() to stdlib.h
This function is not standard and performs the opposite of atol(). Let's move it with atol(). It's been split between a reentrant function and one using
tools/nolibc/stdlib: move ltoa() to stdlib.h
This function is not standard and performs the opposite of atol(). Let's move it with atol(). It's been split between a reentrant function and one using a static buffer.
There's no more definition in nolibc.h anymore now.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|
#
06fdba53 |
| 07-Feb-2022 |
Willy Tarreau <w@1wt.eu> |
tools/nolibc/stdlib: extract the stdlib-specific functions to their own file
The new file stdlib.h contains the definitions of functions that are usually found in stdlib.h. Many more could certainly
tools/nolibc/stdlib: extract the stdlib-specific functions to their own file
The new file stdlib.h contains the definitions of functions that are usually found in stdlib.h. Many more could certainly be added.
Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
show more ...
|