Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/string.c: Use freestanding environment

gcc can transform the loop in a naive implementation of memset/memcpy
etc into a call to the function itself. This optimization is enabled by
-ftree-loop-distribute-patterns.

This has been the case for a while, but gcc-10.x enables this option at
-O2 rather than -O3 as in previous versions.

Add -ffreestanding, which implicitly disables this optimization with
gcc. It is unclear whether clang performs such optimizations, but
hopefully it will also not do so in a freestanding environment.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Arvind Sankar and committed by
Linus Torvalds
33d0f96f 394b19d6

+6 -1
+6 -1
lib/Makefile
··· 15 15 KCOV_INSTRUMENT_dynamic_debug.o := n 16 16 KCOV_INSTRUMENT_fault-inject.o := n 17 17 18 + # string.o implements standard library functions like memset/memcpy etc. 19 + # Use -ffreestanding to ensure that the compiler does not try to "optimize" 20 + # them into calls to themselves. 21 + CFLAGS_string.o := -ffreestanding 22 + 18 23 # Early boot use of cmdline, don't instrument it 19 24 ifdef CONFIG_AMD_MEM_ENCRYPT 20 25 KASAN_SANITIZE_string.o := n 21 26 22 - CFLAGS_string.o := -fno-stack-protector 27 + CFLAGS_string.o += -fno-stack-protector 23 28 endif 24 29 25 30 # Used by KCSAN while enabled, avoid recursion.