diff --git a/cpu/msp430-common/cpu.c b/cpu/msp430-common/cpu.c index d853369315..c9e854c430 100644 --- a/cpu/msp430-common/cpu.c +++ b/cpu/msp430-common/cpu.c @@ -39,6 +39,14 @@ void cpu_switch_context_exit(void) __restore_context(); } +/** + * mspgcc handles main specially - it does not return but falls + * through to section .fini9. + * To "fix" this, we put a return in section .fini9 to make main + * behave like a regular function. This enables a common + * thread_stack_init behavior. */ +__attribute__((section (".fini9"))) void __main_epilogue(void) { __asm__("ret"); } + //---------------------------------------------------------------------------- // Processor specific routine - here for MSP //----------------------------------------------------------------------------