gcov: Disable stack checking

When enable CONFIG_STACK_CANARIES, in general, the stack check in the __gcov_fork function is:
" return fork();
18: e59f3020 ldr r3, [pc, #32] @ 40 <__gcov_fork+0x40>
1c: e5932000 ldr r2, [r3]
20: e59d3004 ldr r3, [sp, #4]
24: e0332002 eors r2, r3, r2
28: e3a03000 mov r3, #0
2c: 1a000002 bne 3c <__gcov_fork+0x3c>"
r3 is obtained by taking the value of sp offset. But after opening thumb, the second comparison value in
"8c6: 4a06 ldr r2, [pc, #24] @ (8e0 <__gcov_fork+0x30>)
8c8: 6811 ldr r1, [r2, #0]
8ca: 687a ldr r2, [r7, #4]
8cc: 4051 eors r1, r2"
is obtained through r7. Since r7 stores the stack address at this time, which stores the address of the parent process, the stack out of bounds will occur in the child process

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
This commit is contained in:
wangmingrong1 2024-12-13 15:35:29 +08:00 committed by Xiang Xiao
parent 3d99bae59a
commit b99ca3f27b

View file

@ -25,7 +25,8 @@ endif()
if(CONFIG_COVERAGE_MINI AND CONFIG_ARCH_TOOLCHAIN_GCC) if(CONFIG_COVERAGE_MINI AND CONFIG_ARCH_TOOLCHAIN_GCC)
nuttx_add_system_library(libcoverage) nuttx_add_system_library(libcoverage)
target_compile_options(libcoverage PRIVATE -fno-profile-arcs target_compile_options(
-fno-test-coverage) libcoverage PRIVATE -fno-profile-arcs -fno-test-coverage
-fno-stack-protector)
target_sources(libcoverage PRIVATE gcov.c) target_sources(libcoverage PRIVATE gcov.c)
endif() endif()