To specify several ROM blocks in a .lcf file, the start address of the main memory block must be the ROM image address.
To prevent all executable code or constants allocated in other ROM blocks to be copied during startup, use the LOAD linker directive. To prevent a specific executable code or constant section from being copied to its runtime RAM destination, specify the final destination address in the LOAD directive.
Configuring linker file for an image with several ROM blocks shows an example .lcf file that specifies several ROM blocks.
MEMORY
{
APPL_INT_VECT : org= 0x00010000, len= 0x000000FF
// If org is changed, make sure to adjust start address in
// .applexctbl LOAD (0x00010000): {} > APPL_INT_VECT
// accordingly
CST_DATA : org= 0x00010100, len= 0x000000FF
APPL_CODE_FLASH : org= 0x00010200, len= 0x000EFE00
// APPL_CODE_FLASH= int. flash area for application
// external RAM
EXT_RAM_A : org= 0x00800000, len= 0x00100000
}
SECTIONS {
.applexctbl LOAD (0x0001000): {} > APPL_INT_VECT
.syscall: {} > APPL_CODE_FLASH
.reset : {} > APPL_CODE_FLASH
.init: {} > APPL_CODE_FLASH
GROUP : {
.text (TEXT) : {}
.rodata (CONST) : {
*(.rdata)
*(.rodata)
}
.ctors : {}
.dtors : {}
extab : {}
extabindex : {}
} > APPL_CODE_FLASH
GROUP : {
.bss : {}
.data : {}
.sdata : {}
.sbss : {}
.sdata2 : {}
.sbss2 : {}
.PPC.EMB.sdata0: {}
.PPC.EMB.sbss0 : {}
} > EXT_RAM_A //DPTRAM_AB
GROUP:{
.CstData LOAD (0x00010100): {}
} > CST_DATA
}
If several sections must be allocated in one of the secondary memory areas, use the linker's ROMADDR directive to evaluate the final destination address of the sections. Placing several sections in a secondary memory area shows an example.
.applexctbl LOAD (0x0010000): {} > APPL_INT_VECT
.syscall LOAD (ROMADDR(.applexctbl)+SIZEOF(.applexctbl)):{}
> APPL_INT_VECT
If the program contains an absolute code section, a section which contains object code that must not be copied at startup, the section must also be specified in the .lcf file with the LOAD directive. Absolute code example shows example C source code that generates an interrupt service routine that must be placed at a specific address at runtime. Linker commands for absolute code in ROM shows the linker directives that ensure that this routine's object code will be loaded at a specific address at runtime.
#pragma push
#pragma section code_type ".abs.00010000" code_mode=pc_rel
asm void _ISRVectorTable(void)
{
b InterruptHandler
nop
nop
b InterruptHandler
}
#pragma pop
MEMORY
{
//internal Flash
APPL_INT_VECT : org= 0x00010000, len= 0x000000FF;
// If org is changed, make sure to adjust start
// address in .abs.00010000 LOAD (0x00010000): {} >
// APPL_INT_VECT accordingly
// ...
}
SECTIONS {
.abs.00010000 LOAD (0x00010000): {} > APPL_INT_VECT
<...>
}