How can I place a section at a minimum address?
The following steps will locate the section .section into the memory area RAM at a minimum address of 0xd0005000.
-
Define a new memory region in the linker script.
Example MEMORY
MEMORY { RAM (w) : org = 0xd0000000, len = 0x10000 }
-
Define an output section (e.g., .somesec) and assign it to the memory region defined in step 1.
-
Locate the section at a minimum address. The usage of the ternary condition operator (?:) is possible here. It checks whether the address of the section is lower than the minimum address (0xd0005000).
Example SECTIONS
SECTIONS { .somesec : { /* output section commands */ } > RAM .section(. < 0xd0005000) ? 0xd0005000 : . : { /* output section commands */ } > RAM }