diff --git a/components/esp32/CMakeLists.txt b/components/esp32/CMakeLists.txt index 4ba59b647b..1296364f55 100644 --- a/components/esp32/CMakeLists.txt +++ b/components/esp32/CMakeLists.txt @@ -75,12 +75,6 @@ else() add_custom_target(esp32_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld) add_dependencies(${COMPONENT_LIB} esp32_linker_script) - # disable stack protection in files which are involved in initialization of that feature - set_source_files_properties( - cpu_start.c - PROPERTIES COMPILE_FLAGS - -fno-stack-protector) - if(CONFIG_SPIRAM_CACHE_WORKAROUND) # Note: Adding as a PUBLIC compile option here causes this option to propagate to all components that depend on esp32. # diff --git a/components/esp32/component.mk b/components/esp32/component.mk index 8f999b26d6..830939abf6 100644 --- a/components/esp32/component.mk +++ b/components/esp32/component.mk @@ -40,5 +40,3 @@ esp32_out.ld: $(COMPONENT_PATH)/ld/esp32.ld ../include/sdkconfig.h COMPONENT_EXTRA_CLEAN := esp32_out.ld $(COMPONENT_BUILD_DIR)/esp32.project.ld -# disable stack protection in files which are involved in initialization of that feature -cpu_start.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS)) diff --git a/components/esp32s2/CMakeLists.txt b/components/esp32s2/CMakeLists.txt index efcda1fe8e..024b08b95b 100644 --- a/components/esp32s2/CMakeLists.txt +++ b/components/esp32s2/CMakeLists.txt @@ -70,10 +70,4 @@ else() add_custom_target(esp32s2_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32s2_out.ld) add_dependencies(${COMPONENT_LIB} esp32s2_linker_script) - - # disable stack protection in files which are involved in initialization of that feature - set_source_files_properties( - cpu_start.c - PROPERTIES COMPILE_FLAGS - -fno-stack-protector) endif() diff --git a/components/esp_common/CMakeLists.txt b/components/esp_common/CMakeLists.txt index 4fad92dfeb..400419da99 100644 --- a/components/esp_common/CMakeLists.txt +++ b/components/esp_common/CMakeLists.txt @@ -28,6 +28,7 @@ else() "src/stack_check.c" PROPERTIES COMPILE_FLAGS -fno-stack-protector) + set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_LIBRARIES "-Wl,--gc-sections") set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-Wl,--gc-sections") set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 4) diff --git a/components/esp_system/CMakeLists.txt b/components/esp_system/CMakeLists.txt index 5da5b2b625..7095e550d5 100644 --- a/components/esp_system/CMakeLists.txt +++ b/components/esp_system/CMakeLists.txt @@ -16,4 +16,10 @@ target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app") if (NOT CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE) target_link_libraries(${COMPONENT_LIB} INTERFACE "-u start_app_other_cores") -endif() \ No newline at end of file +endif() + +# Disable stack protection in files which are involved in initialization of that feature +set_source_files_properties( + startup.c + PROPERTIES COMPILE_FLAGS + -fno-stack-protector) \ No newline at end of file diff --git a/components/esp_system/component.mk b/components/esp_system/component.mk index 7979a2664f..0d51d6f577 100644 --- a/components/esp_system/component.mk +++ b/components/esp_system/component.mk @@ -5,4 +5,7 @@ COMPONENT_ADD_INCLUDEDIRS := include COMPONENT_PRIV_INCLUDEDIRS := private_include port/include COMPONENT_ADD_LDFRAGMENTS += linker.lf --include $(COMPONENT_PATH)/port/$(SOC_NAME)/component.mk \ No newline at end of file +-include $(COMPONENT_PATH)/port/$(SOC_NAME)/component.mk + +# disable stack protection in files which are involved in initialization of that feature +startup.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS)) \ No newline at end of file diff --git a/tools/test_apps/system/startup/sdkconfig.ci.stack_check b/tools/test_apps/system/startup/sdkconfig.ci.stack_check new file mode 100644 index 0000000000..ff2493ddc5 --- /dev/null +++ b/tools/test_apps/system/startup/sdkconfig.ci.stack_check @@ -0,0 +1,2 @@ +CONFIG_COMPILER_STACK_CHECK_MODE_ALL=y +CONFIG_COMPILER_STACK_CHECK=y