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.
Output sections are used to reserve a dedicated memory range for selected sections.
However, in some cases, for example, suppose you have different memory regions available, such as DSPR0 and DSPR1 RAM for an AURIX CPU, the selected sections might not fit into one output section.
You can define an overflow section that is only created when the 'main' section size is not large enough to include all assigned sections. The size of the overflow output section can be static or adaptive, using a blocksize entry, which increases the section's size by the blocksize value if needed to store all sections.
You can apply the size keyword to an output section as well as to an overflow output section. However, the blocksize keyword can only be applied to a non-overflow output section.
/* Create some arrays with an overall size larger than the output section to provoke the need for the overflow section. */
unsigned int i_arr_1[0x800];
unsigned int i_arr_2[0x800];
unsigned int i_arr_3[0x800];
group ( ordered, run_addr = mem:mpe:dspr0 )
{
/* Define output section BSS_DATA with a size of 16kB in memory DSPR0 and
* assign the arrays defined in file_1.c to this section.
* Use overflow output section BSS_DATA_OVERFLOW for sections
* that do not fit in BSS_DATA. */
section "BSS_DATA" (size=16k, attributes=rw, overflow =
"BSS_DATA_OVERFLOW")
{
select ".bss.file_1.i_arr*";
}
}
group ( ordered, run_addr = mem:mpe:dspr1 )
{
/* If the available space of 16kB is not enough for all sections starting
* with the name .bss.file_1.i_arr
* this overflow section with a size
* of 8 kB is used for the remaining sections. */
section "BSS_DATA_OVERFLOW" (size=8k, attributes=rw)
/* Instead of using a fixed absolute size for the output section you can
* use the blocksize keyword to specify an adaptive size.
* Then the size of the output section increases to a multiple of
* the blocksize value. */
/* section "BSS_DATA_OVERFLOW" (blocksize=1k, attributes=rw) */
{
}
}
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:dspr1 | | BSS_DATA_OVERFLOW (371) | 0x00002000 | 0x60000000 | 0x0 | 0x00000002 |
| mpe:dspr0 | | BSS_DATA (370) | 0x00004000 | 0x70005000 | 0x00005000 | 0x00000002