macro_rules! init_sections {
($($section_name:ident$(,)?)+) => { ... };
}
Expand description
Defines pre-init function initializing linker section memory.
This macro accepts linker section names as arguments and assumes the linker symbols are named after given section names prefixed with
__s
for section VMA’s start (usually points to RAM)__e
for section VMA’s end (usually points to RAM)__si
for section LMA’s start (usually points to FLASH)
If the symbols in the linker script are named __scustom_data
, __ecustom_data
and __sicustom_data
,
as depicted in an example below, the macro call should be
init_sections!(custom_data)
MEMORY
{
FLASH : ORIGIN = 0x08000000, LENGTH = 32K
RAM : ORIGIN = 0x20000000, LENGTH = 16K
DATA : ORIGIN = 0x20004000, LENGTH = 16K
}
SECTIONS
{
.custom_data : ALIGN(4)
{
. = ALIGN(4);
__scustom_data = .;
*(.custom_data .custom_data.*);
. = ALIGN(4);
__ecustom_data = .;
} > DATA AT>FLASH
__sicustom_data = LOADADDR(.custom_data);
} INSERT BEFORE .uninit;
Multiple section names could be passed as
init_sections!(section_a, section_b, section_c);
init_sections!(section_a, section_b, section_c,);
init_sections!(section_a section_b section_c);