加载脚本以加载内存区域顶部的部分 [英] load script to load a section at the top of a memory region
问题描述
必须创建一个ROM应用程序,其唯一目的是存储东西在rom中,并在需要时初始化数据和bss部分。
到目前为止的脚本是这样的:
MEMORY
{
rom(rx):ORIGIN = 0,LENGTH = 32K;
ram(!rx):ORIGIN = 0x10000,LENGTH = 8K;
}
部分
{
。 = ORIGIN(rom);
.text:
{
KEEP(*(。text));
}> ;.
.data:
{
KEEP(*(。data));
}> ram AT> ;.
.bss:
{
KEEP(*(。bss));
}> ram = 0x00
}
我想改变加载脚本,使得数据和bss部分被加载到内存区域顶部的内存中,而不是在底部。
我该怎么做?
据我目前的理解,这根本不可能。然而,人们可以定义一个大小,然后用它来计算起始地址。
例如
_ram_data_size = 0x1000;
_ram_data_address = ORIGIN(ram)+ LENGTH(ram) - _ram_data_size;
_rom_data_address = 0x100;
$ b b
{
.data _ram_data_address:AT _rom_data_address
{
KEEP(*(。data));
}
ASSERT(SIZEOF(.data)< = _ram_data_size);
}
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?
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 ) ;
}
这篇关于加载脚本以加载内存区域顶部的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!