I have a hardfault wrapper copying the registers before going to the real hardfault function (Made for CM0) which I got from
here:
LDR R1, =HardFault_Handler_cp
It always worked in all conditions, until I tried enabling flto optimization (Got additional 10KB flash in CM3), then I got;
"Error: invalid offset, value too big (0x00003B4C)".
I understand the literal is too large (Largest literal for LDR in CM0 is 1020), how could I split this instruction into several ones?
Like: Load first byte, load second byte, or whatever? My knowledge in ARM assembly is close to zero.
I checked the
CM0 LDR instruction docs.
I tried searching how to make a const-struc expression, perhabs I could find a way to load it in steps, but found nothing.
STR R2, [R0,#const-struc] ; const-struc is an expression evaluating to a constant in the range 0-1020.
Also it seems strange to me that it works without flto, it's loading the literal for HardFault_Handler_cp address after all?