This article is for the TriCore toolset. A similar approach applies to our other products, like SmartCode, and Arm. Note that the keywords or naming conventions are different in Arm.
By default, the linker places sections according to the 'priority' value entered for the memory block. Memories with a higher priority value will be filled up first, and the memories will be loaded from lower to higher addresses.
If a certain memory range should not be used, you can apply the reserved keyword to prevent a section placement within that memory range.
section_layout :vtc:linear
{
group ( ordered, run_addr = mem:mpe:pflash0[0x100] )
{
reserved "MY_RESERVE" ( size = 16k );
}
}
The above-listed LSL entry reserves 16 kB in pflash0 memory, starting at offset 0x100, within this memory range.
+ Space mpe:vtc:linear (MAU = 8bit)
+------------------------------------------------------------------------------------------------------------------------+
| Chip | Group | Section | Size (MAU) | Space addr | Chip addr | Alignment|
|========================================================================================================================|
|
...
| mpe:pflash0 | | MY_RESERVE (354) | 0x00004000 | 0x80000100 |0x00000100 |0x00000001|
...
If you need to place a section or some sections in a reserved range, you can add an alloc_allowed entry to the reserve group.
Here, the SPECIAL_FUNCTIONS group is placed at the absolute start address offset 0x110 in memory pflash0, which is within the reserved range.
section_layout :vtc:linear
{
group ( ordered, run_addr = mem:mpe:pflash0[0x100] )
{
reserved "MY_RESERVE" ( alloc_allowed=absolute, size = 16k );
}
group SPECIAL_FUNCTIONS ( ordered, contiguous, run_addr = mem:mpe:pflash0[0x110] )
{
select ".text.file_1.func_1";
select ".text.file_1.func_2";
}
}Here, the SPECIAL_FUNCTIONS group is placed in an address range, starting at offset 0x110 and ending at offset 0x200 in memory pflash0, which is within the reserved range.
section_layout :vtc:linear
{
group ( ordered, run_addr = mem:mpe:pflash0[0x100] )
{
reserved "MY_RESERVE" ( alloc_allowed=ranged, size = 16k );
}
group SPECIAL_FUNCTIONS ( ordered, contiguous, run_addr =
mem:mpe:pflash0[0x110..0x200] )
{
select ".text.file_1.func_1";
select ".text.file_1.func_2";
}
}
The linker-generated map file includes the following entries:
+ Space mpe:vtc:linear (MAU = 8bit)
+------------------------------------------------------------------------------------------------------------------------+
| Chip | Group | Section | Size (MAU) | Space addr | Chip addr | Alignment |
|========================================================================================================================|
...
| mpe:pflash0 | | MY_RESERVE (371) | 0x00004000 | 0x80000100 | 0x00000100 | 0x00000001 |
| mpe:pflash0 |SPECIAL_FUNCTIONS | .text.file_1.func_1 (168) | 0x00000008 | 0x80000110 | 0x00000110 | 0x00000002 |
| mpe:pflash0 |SPECIAL_FUNCTIONS | .text.file_1.func_2 (169) | 0x00000008 | 0x80000118 | 0x00000118 | 0x00000002 |
| mpe:pflash0 | |.text._c_init_entry.libcs_fpu (222)| 0x00000120 | 0x80004100 | 0x00004100 | 0x00000002 |