问题
I'm working on a project for an embedded system, using an ARM M0.
A ROM application has to be created, whose sole purpose is to store stuff in rom, and initialize the data and bss sections whenever needed.
The loadscript so far is this:
MEMORY
{
rom (rx): ORIGIN = 0, LENGTH = 32K ;
ram (!rx): ORIGIN = 0x10000, LENGTH = 8K ;
}
SECTION
{
. = ORIGIN(rom) ;
.text:
{
KEEP(*(.text)) ;
} >.
.data:
{
KEEP(*(.data)) ;
} >ram AT>.
.bss:
{
KEEP(*(.bss)) ;
} > ram = 0x00
}
I want to change the loadscript so that the data and bss portions are loaded into ram at the top of the memory region, not at the bottom.
How can I do that?
回答1:
As far as my understanding currently goes, this is simply not possible. One can, however, define a size, and use that calculate the starting address.
e.g.
_ram_data_size = 0x1000 ;
_ram_data_address = ORIGIN(ram) + LENGTH(ram) - _ram_data_size ;
_rom_data_address = 0x100 ;
SECTION
{
.data _ram_data_address : AT _rom_data_address
{
KEEP(*(.data)) ;
}
ASSERT( SIZEOF(.data) <= _ram_data_size ) ;
}
来源:https://stackoverflow.com/questions/19096437/load-script-to-load-a-section-at-the-top-of-a-memory-region