From 2a8411b6a3d35ec7e4093086d0bd7f7e2575035c Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Wed, 18 Dec 2013 02:25:48 +0100 Subject: [PATCH] fix main return for msp430 mspgcc handles main specially, this introduces code to make main behave normally --- cpu/msp430-common/cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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 //----------------------------------------------------------------------------