How to get last address loaded, or size, from .ld file?
A live CAN loader resides in the first 0x8000 in a STM32L431RB. I want to do a CRC check on the application that loads, following the loader, e.g. 0x08008000. The goal is for the loader to run a CRC check upon reset and jump to the app if the CRC is OK. To run a CRC check requires obtaining the application size. (The expected CRC can be placed following the application but also requires knowing the size.)
The approach I've tried is to place a ".word" ahead of the ResetHandler in the startup .s file which would allow the loader to locate the address via the start address at 0x08005004. How can set the .ld linker script be modified to store the size?
If I assign that ".word" with '_sidata' from the ld script, I get a size that is 120 bytes shorter than the .bin file, or last byte of the .srec file. I haven't figured out just what those additional bytes are use for, however I would expect they are there for a purpose.
Is there a place in .ld script where a label could be inserted that has the full size of the binary?
.section .text.Reset_Handler
.weak Reset_Handler
.type Reset_Handler, %function
.word _sidata
Reset_Handler:
ldr sp, =_estack /* Set stack pointer */