diff options
author | Arvind Sankar <nivedita@alum.mit.edu> | 2020-08-19 10:08:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-08-19 11:23:45 -0700 |
commit | 33d0f96ffd7394ffb208bb366be312d12dfd24a4 (patch) | |
tree | 786d9469c3f97b255001d323964ad23b83118728 /lib/Makefile | |
parent | 394b19d6cb58ae292c0e1ad6b893fed8ece477ce (diff) | |
download | linux-33d0f96ffd7394ffb208bb366be312d12dfd24a4.tar.gz linux-33d0f96ffd7394ffb208bb366be312d12dfd24a4.tar.bz2 linux-33d0f96ffd7394ffb208bb366be312d12dfd24a4.zip |
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>
Diffstat (limited to 'lib/Makefile')
-rw-r--r-- | lib/Makefile | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Makefile b/lib/Makefile index e290fc5707ea..a4a4c6864f51 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -15,11 +15,16 @@ KCOV_INSTRUMENT_debugobjects.o := n KCOV_INSTRUMENT_dynamic_debug.o := n KCOV_INSTRUMENT_fault-inject.o := n +# string.o implements standard library functions like memset/memcpy etc. +# Use -ffreestanding to ensure that the compiler does not try to "optimize" +# them into calls to themselves. +CFLAGS_string.o := -ffreestanding + # Early boot use of cmdline, don't instrument it ifdef CONFIG_AMD_MEM_ENCRYPT KASAN_SANITIZE_string.o := n -CFLAGS_string.o := -fno-stack-protector +CFLAGS_string.o += -fno-stack-protector endif # Used by KCSAN while enabled, avoid recursion. |