分散加载文件中定义如下:
Exec_Sram 0x80000000 0x40000
{
* (sram)
}
“PI” 属性使用示例:
LR_1 0x010000 PI ; The first load region is at 0x010000.
{
ER_RO +0 ; The PI attribute is inherited from parent.
; The default execution address is 0x010000, but the code can be moved.
{
*(+RO) ; All the RO sections go here.
}
ER_RW +0 ABSOLUTE ; PI attribute is overridden by ABSOLUTE.
{
*(+RW) ; The RW sections are placed next. They cannot be moved.
}
ER_ZI +0 ; ER_ZI region placed after ER_RW region.
{
*(+ZI) ; All the ZI sections are placed consecutively here.
}
}
LR_1 0x010000 ; The first load region is at 0x010000.
{
ER_RO +0 ; Default ABSOLUTE attribute is inherited from parent. The execution address
; is 0x010000. The code and ro data cannot be moved.
{
*(+RO) ; All the RO sections go here.
}
ER_RW 0x018000 PI ; PI attribute overrides ABSOLUTE
{
*(+RW) ; The RW sections are placed at 0x018000 and they can be moved.
}
ER_ZI +0 ; ER_ZI region placed after ER_RW region.
{
*(+ZI) ; All the ZI sections are placed consecutively here.
}
}
程序中对某区域地址等的引用方法:
Load$region_name$Base Load address of the region.
Image$region_name$Base Execution address of the region.
Image$region_name$Length Execution region length in bytes (multiple of 4).
Image$region_name$Limit Address of the byte beyond the end of the execution region.
Image$region_name$ZI$Base Execution address of the ZI output section in this region.
Image$region_name$ZI$Length Length of the ZI output section in bytes (multiple of 4).
Image$region_name$ZI$Limit Address of the byte beyond the end of the ZI output sectionin the execution region.
SectionName$Base Input Address of the start of the consolidated section called SectionName.
SectionName$Limit Input Address of the byte beyond the end of the consolidated section called SectionName.
Load: 加载区,即存放地址;
Image: 执行区,即运行地址;
Base: 区首地址;
Limit: 区尾地址;
Length: 区长度;
region_name: RO、RW、ZI、load_region_name、execution_region_name;
例如:
“RAM1”区域的首地址: Image$RAM1$Base
上例中“sram”段首地址: sram$Base
汇编引用示例:
IMPORT |Load$Exec_RAM1$Base| // Exec_RAM1 为“RW”段
IMPORT |Image$Exec_RAM1$Base|
IMPORT |Image$Exec_RAM1$Length|
IMPORT |Image$Exec_RAM1$Limit|
LDR R0, =|Load$Exec_RAM1$Base|
LDR R1, =|Image$Exec_RAM1$Base|
LDR R2, =|Image$Exec_RAM1$Limit|
0
CMP R1, R2
LDRCC R3, [R0], #4
STRCC R3, [R1], #4
BCC %b0
C 引用:
extern unsigned char Load$Exec_RAM1$Base;
extern unsigned char Image$Exec_RAM1$Base;
extern unsigned char Image$Exec_RAM1$Length;
void MoveRO(void)
{
unsigned char * psrc, *pdst;
unsigned int count;
count = (unsigned int) &Image$Exec_RAM1$Length;
psrc = (unsigned char *)&Load$Exec_RAM1$Base;
pdst = (unsigned char *)&Image$Exec_RAM1$Base;
while (count--) {
*pdst++ = *psrc++;
}
}