With -O1 (Default) on the M4F, run_pinit() is trying to call 0xE000E088, and creating a hard fault.
All global classes have empty constructors ( ClassName() = default; ).
What is the best way to handle this? Do I tell the MPU to allow execution here? Is it something tricky with compiler flags (I use example defaults + C++11)? There's no explicit .pinit section in the linker cmd file. Should there be?
My workaround so far, discovered by accident, is to use -Og. But I'd like to fix this so I can use normal optimizations in the long run. I have not tested what other optimizations crash beyond -O1.
<EDIT> After some more pain with this I figured out that the __STACK_END was starting at the address of .init_array. I've updated my linker cmd file with a buffer as follows:
.stack: {} palign(8) > M4F_IRAM /* This is where the main() stack goes */
.buffer: fill=0xff { . += 0x008; } palign(8) > M4F_IRAM
/* Sections needed for C++ projects */
.ARM.exidx: {} palign(8) > M4F_IRAM /* Needed for C++ exception handling */
.init_array: {} palign(8) > M4F_IRAM /* Contains function pointers called before main */
.fini_array: {} palign(8) > M4F_IRAM /* Contains function pointers called after main */
If this is due to a bad project configuration, I'd like to understand what that is. If it's a bug, that would also be good to know.