11.3 Locating Attributed Objects
Some object attributes, such as the keep attribute, might require that the
object be placed in a uniquely named section. There are also some command-line options, such
as -fdata-sections, that alter the section name. When using any of these
attributes or options, the name of the section allocated to the object requires consideration
if you are placing the sections at specific memory locations via a linker script.
Check the object file for the exact name used by the compiler, but to safely ensure the desired section is linked appropriately, consider using wildcards in the section name, similar to the following linker script entries.
MEMORY {
rom (LRX) : ORIGIN = ROM_ORIGIN, LENGTH = ROM_LENGTH-0x2000
reserved_flash (LRX) : ORIGIN = 0xFE000, LENGTH = 0x2000
}
.mydata :{KEEP(*(.mydata .mydata.*)) } > reserved_flashThe last line additionally specifies .mydata.* sections in the
.mydata output section specification, which is allocated to the
reserved_flash memory region. Even if the name of the
.mydata section is adjusted by the use of other attributes or options, it
will continue to be linked to the desired location.
