diff options
author | Willy Tarreau <w@1wt.eu> | 2023-01-10 10:24:13 +0300 |
---|---|---|
committer | Paul E. McKenney <paulmck@kernel.org> | 2023-01-11 00:33:55 +0300 |
commit | 7f8548589661d5edbde4c343e4971117585da2f5 (patch) | |
tree | d059ee6f8f66bca1ef79808d2f395e74f6d2ed0e /scripts/const_structs.checkpatch | |
parent | 28ef4c3753a4e57a347b2bf5f598645de966c137 (diff) | |
download | linux-7f8548589661d5edbde4c343e4971117585da2f5.tar.xz |
tools/nolibc: make compiler and assembler agree on the section around _start
The out-of-block asm() statement carrying _start does not allow the
compiler to know what section the assembly code is being emitted to,
and there's no easy way to push/pop the current section and restore
it. It sometimes causes issues depending on the include files ordering
and compiler optimizations. For example if a variable is declared
immediately before the asm() block and another one after, the compiler
assumes that the current section is still .bss and doesn't re-emit it,
making the second variable appear inside the .text section instead.
Forcing .bss at the end of the _start block doesn't work either because
at certain optimizations the compiler may reorder blocks and will make
some real code appear just after this block.
A significant number of solutions were attempted, but many of them were
still sensitive to section reordering. In the end, the best way to make
sure the compiler and assembler agree on the current section is to place
this code inside a function. Here the function is directly called _start
and configured not to emit a frame-pointer, hence to have no prologue.
If some future architectures would still emit some prologue, another
working approach consists in naming the function differently and placing
the _start label inside the asm statement. But the current solution is
simpler.
It was tested with nolibc-test at -O,-O0,-O2,-O3,-Os for arm,arm64,i386,
mips,riscv,s390 and x86_64.
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'scripts/const_structs.checkpatch')
0 files changed, 0 insertions, 0 deletions