I'm writing a microcontroller firmware which has a main loop function that never returns. It's called from the reset_handler function:
void reset_handler() { // relocate data section memcpy(&_data_vma, &_data_lma, (&_data_evma - &_data_vma) * sizeof(size_t)); main(); } Since main never returns, creating a stack frame for it would just waste RAM space (just 8 bytes, but still ...). I considered the following ways to reclaim this space:
- mark function as
inline(would have to put function definition in header file, which is not very nice); - add
nakedattribute to the function (breaks function calls insidemain, which pass arguments on stack); - adjust
spmanually (feels like a dirty hack)
but they bring more problems than they solve.
Is there a better way to instruct GCC not to create a stack frame for a particular function?