mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
![]() 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:
|
||
---|---|---|
.. | ||
.gitignore | ||
arch-aarch64.h | ||
arch-arm.h | ||
arch-i386.h | ||
arch-loongarch.h | ||
arch-mips.h | ||
arch-riscv.h | ||
arch-s390.h | ||
arch-x86_64.h | ||
arch.h | ||
compiler.h | ||
ctype.h | ||
errno.h | ||
Makefile | ||
nolibc.h | ||
signal.h | ||
stackprotector.h | ||
std.h | ||
stdint.h | ||
stdio.h | ||
stdlib.h | ||
string.h | ||
sys.h | ||
time.h | ||
types.h | ||
unistd.h |