How do I reserve a specific number of bytes for a symbol?
There are two ways to reserve a specific number of bytes for a symbol.
Example 1
MEMORY
{
MYREGION (w!x): org = 0xd001ec00, len = 48
}
SECTIONS
{
.out_sec (NOLOAD) :
{
_lc_gb_FLS_STATE_VAR = .;
. += 48;
} > MYREGION
}
Define an output section, e.g., out_sec and define your global symbol. The statement _lc_gb_FLS_STATE_VAR = .;
will define a symbol and assign the start address of the memory region MYREGION. The movement of the location counter . += 48;
will reserve the next 48 bytes and prevent the linker from putting any data in between.
Another solution is to assign a fixed address to the output section out_sec.
Example 2
MEMORY
{
MYREGION (w!x): org = 0xd001ec00, len = 48
}
SECTIONS
{
.out_sec 0xd001ec00 (NOLOAD) :
{
_lc_gb_FLS_STATE_VAR = .;
. += 48;
} > MYREGION
}
In both examples, the linker will issue an error if the size of the output section does not fit with the memory region.