I'm just starting out with the development of built-in leverage, and there is a piece of code that really listens to me:
pSrc = &_etext;
pDest = &_srelocate;
if (pSrc != pDest)
{
while (pDest < &_erelocate)
{
*pDest++ = *pSrc++;
}
}
Where _etextand _srelocateare the characters defined in the script builder:
. = ALIGN(4);
_etext = .;
.relocate : AT (_etext)
{
. = ALIGN(4);
_srelocate = .;
*(.ramfunc .ramfunc.*);
*(.data .data.*);
. = ALIGN(4);
_erelocate = .;
} > ram
Where ramis the segment of memory whose beginning 0x20000000. The problem, as I see it, is that _etext- it is a symbol that marks the final segment of the border .text, which is part of another memory segment rom. This means that if the aforementioned memory segment was not 100% full, _etext != _srelocateit will always be true. This means that we copy the memory outside the section .textwhere nothing is defined for life according to the linker script.
: A) , rom .text, .relocate ( .data), B ) .text , .relocate , C). , .data .text rom ram; s/relocate/data.
, , script, . - ?