[fpc-devel] Unaligned access on Cortex-M0 in Initialization code

Florian Klämpfl florian at freepascal.org
Sun Mar 31 21:35:15 CEST 2024



> Am 31.03.2024 um 17:11 schrieb Michael Ring via fpc-devel <fpc-devel at lists.freepascal.org>:
> 
> Hi,
> 
> it has been a while since I have been deep,deep down in the rabbit hole of Cortex Assembly, so please forgive me if I am overlooking something...
> 
> I have an application for Raspberry Pico (target embedded) and it fails during initialization as soon as I add a unit that includes an object and I reference the object in my code...
> 
> In that case fpc_initialize (for rtti?) is called and I cannot find source code for fpc_initialize
> 
> In the debugger I see that R0 is $1000177E and R1 is $28 This is in the flash area, so far, so good but $1000177E is obviously not word alligned, it is halfword aligned so this then triggers _HardFault_Handler.
> 
> 10001778 4648                     ldr             r0, [pc, #280] ; (0x10001894 <fpc_initialize+316>)
> 1000177A 4058                     ldr             r0, [r0, r1] ; Crash Boom Bang !!!!!
> 
> Looking at the map file the address is within fpc_initialize, but as I cannot find the proper source I am a bit lost...
> 
> .text.n_fpc_initialize
>                 0x0000000010001758      0x144 /Users/tgdrimi9/fpcupdeluxe/fpc/units/arm-embedded/armv6m/eabi/rtl/system.o
>                 0x0000000010001758                fpc_initialize
>                 0x0000000010001758                FPC_INITIALIZE
>  .text.n_fpc_finalize
>                 0x000000001000189c      0x164 /Users/tgdrimi9/fpcupdeluxe/fpc/units/arm-embedded/armv6m/eabi/rtl/system.o
> 
> Any help appreciated,

Can you post some more context? fpc_initalize is not that big so it should be possible to identify where this comes from.



More information about the fpc-devel mailing list