History log of /linux-master/tools/include/nolibc/errno.h
Revision Date Author Comments
# 1caa1154 10-Jan-2023 Willy Tarreau <w@1wt.eu>

tools/nolibc: make errno a weak symbol instead of a static one

Till now errno was declared static so that it could be eliminated if
unused. While the goal is commendable for tiny executables as it allows
to eliminate any data and bss segments when not used, this comes with
some limitations, one of which being that the errno symbol seen in
different units are not the same. Even though this has never been a
real issue given the nature of the programs involved till now, it
happens that referencing the same symbol from multiple units can also
be achieved using weak symbols, with a difference being that only one
of them will be used for all of them. Compared to weak symbols, static
basically have no benefit for regular programs since there are always
at least a few variables in most of these, so the bss segment cannot
be eliminated. E.g:

$ size nolibc-test-static-errno
text data bss dec hex filename
11531 0 48 11579 2d3b nolibc-test-static-errno

Furthermore, the weak symbol doesn't use bss storage at all, resulting
in a slightly section:

$ size nolibc-test-weak-errno
text data bss dec hex filename
11531 0 40 11571 2d33 nolibc-test-weak-errno

This patch thus converts errno from static to weak.

Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>


# 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
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>


# 45a794bf 07-Feb-2022 Willy Tarreau <w@1wt.eu>

tools/nolibc/errno: extract errno.h from sys.h

This allows us to provide a minimal errno.h to ease porting applications
that use it.

Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>