2021-02-06 04:46 AM
Dear all,
I am trying an error injection for an STML432KC nucleo board of my own. When program is running, I change the SP value in order to inject a Hard Fault.
When Hard Fault routine is called after this error injection, function collapses due to the first sentence in assembler is a push instruction. I've solved this issue by using a naked function, and controlling all code which is employed:
__attribute__ ((naked)) void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
__asm ( "bl HardFault_Handler \n");
/* USER CODE END HardFault_IRQn 0 */
//while (1)
//{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
//}*/
}
Then, function work as expected and it generates an infinite loop. But it will be so interesting to use this function to perform some tasks on the event of a fault.
On IAR workbench there is a non standard keyword called __stackless which deals with this issue, and prevent the compiler to use the stack, so push is not generated when a __stackless function is called.
My question is the following one: Is there an GCC attribute like __stackless which avoids the use of stack push in a function calling?
Thanks in advance for your answers.
Regards,
Victor.