I'm trying to launch simple LED blinking application, all works fine but if I add -ffast-math, it goes to hard fault. I debugged via GDB and found that if I add -ffast-math, it inserts call to __arm_set_fast_math from __libc_init_array as part of initialization routine (from .init_array section)
Disassembling __arm_set_fast_math shows:
080001f4 <__arm_set_fast_math>:
80001f4: eef1 3a10 vmrs r3, fpscr
80001f8: f043 7380 orr.w r3, r3, #16777216 ;0x1000000
80001fc: eee1 3a10 vmsr fpscr, r3
8000200: 4770 bx lr
8000202: bf00 nop
According GDB:
0x080001f4 in __arm_set_fast_math ()
(gdb) stepi
HardFault_Handler () at src/stm32f4xx_it.c:61
it jumps to hardFault handler immediately. removing --fast-math fixes everything. any idea? thanks!