Look at this very strange code:
N_CDECL(void, NimMain)(void) {
void (*volatile inner)(void); // <------ volatile?!! Why?
PreMain();
inner = NimMainInner;
(*inner)();
}
This code turns into strange asm (ARM v6, dangerous build):
800002e: 4b05 ldr r3, [pc, #20] ; (8000044 <NimMain+0x28>)
8000030: 9300 str r3, [sp, #0]
8000032: 9b00 ldr r3, [sp, #0]
8000034: f000 f808 bl 8000048 <NimMain+0x2c>
...
8000044: 08000015 .word 0x08000015
8000048: 4718 bx r3
WAT?
Thank you for the clarification.
I also found that clang generates much better asm than arm-none-eabi-gcc.