2020-12-09 08:01 AM
I had to enhance the stack size using __process_stack_size__ value to make my software running and I would like to know how to measure the stack remaining size. I tried commenting out the ram init in boot.s and fill the stack ram area with a 0x55AA pattern using the debugger, but the area is still initialized. Is there an easy way to know the stack occupied size??
Solved! Go to Solution.
2021-01-12 03:12 PM
Hello,
indeed stack occupied size depends on the application.
A simple way to know, at runtime if a stack allocated variable is still inside the defined stack memory is:
In sPC5Studio top of the stack is defined in the linker script file (__core0_process_stack_base__)
Also: PowerPC ABI defines R1 register as stack pointer. It can be used to know the occupied stack size by doing:
__process_stack_end__ is defined in linker script.
In SPC5Studio crt0.s file, R1 is initialized with address of __process_stack_end__
Regards,
Giuseppe
PS: unfortunately [PowerPC] FreeGCC compiler does not support -stack-protector option.
2021-01-12 03:12 PM
Hello,
indeed stack occupied size depends on the application.
A simple way to know, at runtime if a stack allocated variable is still inside the defined stack memory is:
In sPC5Studio top of the stack is defined in the linker script file (__core0_process_stack_base__)
Also: PowerPC ABI defines R1 register as stack pointer. It can be used to know the occupied stack size by doing:
__process_stack_end__ is defined in linker script.
In SPC5Studio crt0.s file, R1 is initialized with address of __process_stack_end__
Regards,
Giuseppe
PS: unfortunately [PowerPC] FreeGCC compiler does not support -stack-protector option.