linux/tools/include/nolibc
Zhangjin Wu bff60150f7 tools/nolibc: fix up startup failures for -O0 under gcc < 11.1.0
As gcc doc [1] shows:

  Most optimizations are completely disabled at -O0 or if an -O level is
  not set on the command line, even if individual optimization flags are
  specified.

Test result [2] shows, gcc>=11.1.0 deviates from the above description,
but before gcc 11.1.0, "-O0" still forcely uses frame pointer in the
_start function even if the individual optimize("omit-frame-pointer")
flag is specified.

The frame pointer related operations will change the stack pointer (e.g.
In x86_64, an extra "push %rbp" will be inserted at the beginning of
_start) and make it differs from the one we expected, as a result, break
the whole startup function.

To fix up this issue, as suggested by Thomas, the individual "Os" and
"omit-frame-pointer" optimize flags are used together on _start function
to disable frame pointer completely even if the -O0 is set on the
command line.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
[2]: https://lore.kernel.org/lkml/20230714094723.140603-1-falcon@tinylab.org/

Suggested-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/lkml/34b21ba5-7b59-4b3b-9ed6-ef9a3a5e06f7@t-8ch.de/
Fixes: 7f85485896 ("tools/nolibc: make compiler and assembler agree on the section around _start")
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
2023-08-23 04:40:22 +02:00
..
.gitignore tools/nolibc: Add gitignore to avoid git complaints about sysroot 2023-03-20 08:45:21 -07:00
arch-aarch64.h tools/nolibc: fix up startup failures for -O0 under gcc < 11.1.0 2023-08-23 04:40:22 +02:00
arch-arm.h tools/nolibc: fix up startup failures for -O0 under gcc < 11.1.0 2023-08-23 04:40:22 +02:00
arch-i386.h tools/nolibc: fix up startup failures for -O0 under gcc < 11.1.0 2023-08-23 04:40:22 +02:00
arch-loongarch.h tools/nolibc: fix up startup failures for -O0 under gcc < 11.1.0 2023-08-23 04:40:22 +02:00
arch-mips.h tools/nolibc: fix up startup failures for -O0 under gcc < 11.1.0 2023-08-23 04:40:22 +02:00
arch-riscv.h tools/nolibc: fix up startup failures for -O0 under gcc < 11.1.0 2023-08-23 04:40:22 +02:00
arch-s390.h tools/nolibc: fix up startup failures for -O0 under gcc < 11.1.0 2023-08-23 04:40:22 +02:00
arch-x86_64.h tools/nolibc: fix up startup failures for -O0 under gcc < 11.1.0 2023-08-23 04:40:22 +02:00
arch.h tools/nolibc: fix typo pint -> point 2023-06-09 11:46:08 -07:00
compiler.h tools/nolibc: fix segfaults on compilers without attribute no_stack_protector 2023-06-09 11:46:08 -07:00
ctype.h tools/nolibc: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00
errno.h tools/nolibc: make errno a weak symbol instead of a static one 2023-01-10 13:33:55 -08:00
Makefile tools/nolibc: add autodetection for stackprotector support 2023-06-09 11:46:08 -07:00
nolibc.h tools/nolibc: add missing my_syscall6() for mips 2023-08-23 04:38:02 +02:00
signal.h tools/nolibc: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00
stackprotector.h tools/nolibc: fix segfaults on compilers without attribute no_stack_protector 2023-06-09 11:46:08 -07:00
std.h tools/nolibc: add stdint.h 2023-03-20 08:45:21 -07:00
stdint.h selftests/nolibc: not include limits.h for nolibc 2023-06-09 11:46:09 -07:00
stdio.h tools/nolibc: implement fd-based FILE streams 2023-06-09 11:33:05 -07:00
stdlib.h tools/nolibc: completely remove optional environ support 2023-08-23 04:40:22 +02:00
string.h tools/nolibc: use standard __asm__ statements 2023-06-09 11:46:07 -07:00
sys.h tools/nolibc: add rmdir() support 2023-08-23 04:38:02 +02:00
time.h tools/nolibc: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00
types.h tools/nolibc: types.h: add RB_ flags for reboot() 2023-08-23 04:38:02 +02:00
unistd.h tools/nolibc: unistd.h: reorder the syscall macros 2023-08-06 12:27:53 +02:00