libc: Add GCC fno-builtin-malloc flag to common stdlib compilation
This prevents the compiler from optimizing calloc into an infinite recursive call. For example a call to malloc + memset zero at GCC -O2 will be replaced by a call to calloc. This causes infinite recursion if the function being implemented *is* calloc. fno-builtin-malloc forces the compiler to avoid this optimization. Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
This commit is contained in:
parent
c72b9f5048
commit
679d82c484
@ -6,3 +6,6 @@ zephyr_library_sources_ifdef(CONFIG_COMMON_LIBC_ABORT source/stdlib/abort.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_COMMON_LIBC_TIME source/time/time.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_COMMON_LIBC_MALLOC source/stdlib/malloc.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_COMMON_LIBC_STRNLEN source/string/strnlen.c)
|
||||
|
||||
# Prevent compiler from optimizing calloc into an infinite recursive call
|
||||
zephyr_library_cc_option(-fno-builtin-malloc)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user