.section_name ALIGN( vma_alignment ) : ALIGN( lma_alignment ){
...section contents
}
所以你的整体脚本应该像下面这样。..
.text :
{
*(.text)
} > FLASH
_etext = .;
PROVIDE (etext = .);
.rodata ALIGN(4) : ALIGN(4)
{
PROVIDE(__VMA_COPY_DATA_START__ = ADDR(.rodata)); /*The runtime address of .rodata*/
PROVIDE(__LMA_COPY_DATA_START__ = LOADADDR(.rodata)); /*The load address of .rodata*/
*(.rodata)
} > ram AT>flash
PROVIDE (__SDATA2_START__ = .);
.sdata2 :
{
*(.sdata2)
} > ram AT>flash
PROVIDE (__sbss2_start = . );
.sbss2 : {
*(.sbss2)
. = ALIGN(4)
} > ram AT>flash
PROVIDE (__sbss2_end = . );
PROVIDE (__SBSS2_END__ = .);
.data :
{
*(.data)
*(.gnu.linkonce.d*)
CONSTRUCTORS
*(.eh_frame)
} > ram AT>flash
/*
*align address so that (__END_COPY__ - __VMA_COPY_DATA_START__) / 4 does not round down.
*If alignment is not done then the copy routine could potentially drop up to 3 bytes at
*the end of the .data section if the section does not end on a multiple of 4 bytes.
*/
. = ALIGN(4)
PROVIDE (__END_COPY__ = .);
r3 = address in flash of __LMA_COPY_DATA_START__
r4 = address in ram of __VMA_COPY_DATA_START__
words_to_copy = (__END_COPY__ - __VMA_COPY_DATA_START__) / 4
while (words_to_copy){
* r4++ = *r3++
words_to_copy--
}