I have a use-case where I want to reserve a configurable AREA of Flash for user-data at the end of the FLASH. I wan't the linker to produce an error (or at minimum a warning) if the code section overlap with the "user-data" area. Here is what I have defined in my linker script:
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 160K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
}
SECTIONS
{
.text :
{
*(.text)
*(.text*)
*(.glue_7)
*(.glue_7t)
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
_etext = .;
} >FLASH
/* Reserved FLASH area for user data (r/w data in Flash) */
__flash_data_size__ = DEFINED(FLASH_DATA_SIZE) ? FLASH_DATA_SIZE : 0K;
.flash_data ORIGIN(FLASH) + LENGTH(FLASH) - __flash_data_size__ (NOLOAD) :
{
. = ALIGN(2048);
__flash_data_start__ = .;
. = . + __flash_data_size__;
__flash_data_end__ = .;
} >FLASH
}
When I define the symbol FLASH_DATA_SIZE I can see that the elf file contains a NOLOAD section at the end of the Flash as expected. However if the section overlaps with the code section (.text) I don't get any linker error. Any idea why the linker does not complain about this?
Alternatively any other ideas how I can have a "compile time" configurable section of the Flash reserved for user data, which is checked against overlapping of code sections?
Thanks in advance, Thomas