linux/tools/include/nolibc
Willy Tarreau 1bfbe1f3e9 tools/nolibc: prevent gcc from making memset() loop over itself
When building on ARM in thumb mode with gcc-11.3 at -O2 or -O3,
nolibc-test segfaults during the select() tests. It turns out that at
this level, gcc recognizes an opportunity for using memset() to zero
the fd_set, but it miscompiles it because it also recognizes a memset
pattern as well, and decides to call memset() from the memset() code:

  000122bc <memset>:
     122bc:       b510            push    {r4, lr}
     122be:       0004            movs    r4, r0
     122c0:       2a00            cmp     r2, #0
     122c2:       d003            beq.n   122cc <memset+0x10>
     122c4:       23ff            movs    r3, #255        ; 0xff
     122c6:       4019            ands    r1, r3
     122c8:       f7ff fff8       bl      122bc <memset>
     122cc:       0020            movs    r0, r4
     122ce:       bd10            pop     {r4, pc}

Simply placing an empty asm() statement inside the loop suffices to
avoid this.

Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
2023-01-09 09:36:05 -08:00
..
arch-aarch64.h tools/nolibc: Remove .global _start from the entry point code 2022-04-20 17:05:46 -07:00
arch-arm.h tools/nolibc: Remove .global _start from the entry point code 2022-04-20 17:05:46 -07:00
arch-i386.h tools/nolibc: i386: Implement syscall with 6 arguments 2022-04-20 17:05:46 -07:00
arch-mips.h tools/nolibc: restore mips branch ordering in the _start block 2023-01-09 09:36:05 -08:00
arch-riscv.h tools/nolibc: make argc 32-bit in riscv startup code 2022-08-31 05:17:43 -07:00
arch-x86_64.h tools/nolibc: Remove .global _start from the entry point code 2022-04-20 17:05:46 -07:00
arch.h tools/nolibc/arch: split arch-specific code into individual files 2022-04-20 17:05:43 -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: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00
Makefile tools/nolibc: add a help target to list supported targets 2022-06-20 09:43:19 -07:00
nolibc.h tools/nolibc: also mention how to build by just setting the include path 2022-04-20 17:05:45 -07:00
signal.h tools/nolibc: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00
std.h tools/nolibc/std: move the standard type definitions to std.h 2022-04-20 17:05:33 -07:00
stdio.h tools/nolibc: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00
stdlib.h tools/nolibc: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00
string.h tools/nolibc: prevent gcc from making memset() loop over itself 2023-01-09 09:36:05 -08:00
sys.h tools/nolibc: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08: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: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00
unistd.h tools/nolibc: fix missing includes causing build issues at -O0 2023-01-09 09:36:05 -08:00