2023-02-20 04:38 PM
I'm looking for some info about and help with using -fstack-protector and similar compiler options with STM32CubeIde. I've never used these flags before, but enabling them does seem to compile fine. Am I correct in assuming that the GCC supplied with Cube supports this? Where is the implementation of required functions (ie. __stack_chk_guard)? Can I just override these?
Any guidance on how to use these options for STM32?
Solved! Go to Solution.
2023-02-21 09:25 AM
Hello @DB.7ujak
Indeed, it is supported.
In order to use -fstack-protector in STM32CubeIDE, you can follow these steps:
Once you have enabled -fstack-protector, the required functions, including __stack_chk_guard, will be automatically generated by the compiler. You do not need to override these functions, as they are part of the compiler's implementation. It is a security feature that can prevent buffer overflow.
Hope this helps!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-02-21 09:25 AM
Hello @DB.7ujak
Indeed, it is supported.
In order to use -fstack-protector in STM32CubeIDE, you can follow these steps:
Once you have enabled -fstack-protector, the required functions, including __stack_chk_guard, will be automatically generated by the compiler. You do not need to override these functions, as they are part of the compiler's implementation. It is a security feature that can prevent buffer overflow.
Hope this helps!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-06-27 06:00 AM
Hi
According to the GCC documentation, stack-usage and stack-protection is not the same thing.
https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html
stack-usage is indeed useful, but it is not the feature that is requested by the OP.
Eric Stryger has made an excellent post about stack-protection here:
https://mcuoneclipse.com/2019/09/28/stack-canaries-with-gcc-checking-for-stack-overflow-at-runtime/
I have also made requests on the subject here on this forum
https://community.st.com/t5/stm32cubeide-mcus/please-change-gcc-stack-canary-to-be-weak/td-p/630140
Best regards
Martin