How to use reserved memory areas?

Sometimes it is necessary to reserve an area, e.g., at the beginning of a memory area to put configuration information in it. Such a region, myfirstSPRAM, is defined in the following linker script snippet.

Example

MEMORY
{
    myfirstSPRAM (w!x): org = 0xd0000000, len = 0x100
    restofSPRAM (w!x): org = 0xd0000100, len = 124K - 0x100
}

To make sure the linker is not putting any input sections in this memory region, you can use the following snippet in the linker script.

Example

SECTIONS
{
    .mysec :
    {
        MYSEC_BASE = .;
        *(.anysec)
        . = MYSEC_BASE + 0x100;
        MYSEC_END = .;

    } > myfirstSPRAM
}

This example will reserve the specified region, and ".anysec" can be used with a pragma instruction in case you want to use the reserved space for the aforementioned configuration.