cancel
Showing results for 
Search instead for 
Did you mean: 

Using stack-protector with CubeIDE

Konami
Senior

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?

1 ACCEPTED SOLUTION

Accepted Solutions
FBL
ST Employee

Hello @DB.7ujak​ 

Indeed, it is supported.

In order to use -fstack-protector in STM32CubeIDE, you can follow these steps:

  1. Open your project in CubeIDE, and go to Project > Properties.
  2. In the Properties dialog box, navigate to C/C++ Build > Settings.
  3. In the Settings page, navigate to Tool Settings > MCU C Compiler > Miscellaneous.
  4. In the Miscellaneous page, check the box next to "-fstack-protector" to enable the flag.

0693W00000aHLA0QAO.pngOnce 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.

View solution in original post

1 REPLY 1
FBL
ST Employee

Hello @DB.7ujak​ 

Indeed, it is supported.

In order to use -fstack-protector in STM32CubeIDE, you can follow these steps:

  1. Open your project in CubeIDE, and go to Project > Properties.
  2. In the Properties dialog box, navigate to C/C++ Build > Settings.
  3. In the Settings page, navigate to Tool Settings > MCU C Compiler > Miscellaneous.
  4. In the Miscellaneous page, check the box next to "-fstack-protector" to enable the flag.

0693W00000aHLA0QAO.pngOnce 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.