7.1.1 Sections
The compiler produces relocatable blocks of code and data called sections. The sections are allocated into memory in a variety of ways to conform to a variety of system configurations. For more information about sections and allocating them, see the introductory object file information in the TMS320C28x Assembly Language Tools User's Guide.
There are two basic types of sections:
- Initialized sections contain data or executable code. Initialized sections are usually, but not always, read-only. The C/C++ compiler creates the following initialized sections:
- The .binit section contains boot time copy tables. This is a read-only section. For details on BINIT, see the TMS320C28x Assembly Language Tools User's Guide.
- The .cinit section and the .pinit section contain tables for initializing variables and constants. These are read-only sections. The C28x .cinit record is limited to 16 bits. This limits initialized objects to 64K.
- The .ovly section contains copy tables other than boot time (.binit) copy tables. This is a read-only section.
- The .econst section contains string constants, string literals, switch tables, the declaration and initialization of global and static variables, and data defined with the C/C++ qualifier const (provided the constant is not also defined as volatile or one of the exceptions described in Section 6.6.1). This is a read-only section. String literals are placed in the .econst:.string subsection to enable greater link-time placement control.
- The .switch section contains tables for switch statements.
- The .text section contains all the executable code and compiler-generated constants. This section is usually read-only.
- The .TI.crctab section contains CRC checking tables. This is a read-only section.
- Uninitialized sections reserve space in memory (usually RAM). A program can use this space at run time to create and store variables. The compiler creates the following uninitialized sections:
- The .ebss section reserves space for global and static variables defined. At program startup time, the C/C++ boot routine copies data out of the .cinit section (which can be in ROM) and uses it for initializing variables in the .ebss section.
- The .stack section reserves memory for the C/C++ software stack. This memory is used to pass arguments to functions and to allocate space for local variables.
- The .esysmem section reserves space for dynamic memory allocation. The reserved space is used by dynamic memory allocation routines, such as malloc, calloc, realloc, or new. If a C/C++ program does not use these functions, the compiler does not create the .esysmem section.
The assembler creates the default sections .text, .ebss, and .data. You can instruct the compiler to create additional sections by using the CODE_SECTION and DATA_SECTION pragmas (see Section 6.10.5 and Section 6.10.7).
The linker takes the individual sections from different object files and combines sections that have the same name. The resulting output sections and the appropriate placement in memory for each section are listed in Table 7-1. You can place these output sections anywhere in the address space as needed to meet system requirements.
Table 7-1 Summary of Sections and Memory Placement
Section |
Type of Memory |
Page |
Section |
Type of Memory |
Page |
.cinit |
ROM or RAM |
0 |
.pinit |
ROM or RAM |
0 |
.data |
RAM |
|
.stack |
RAM |
1 |
.ebss |
RAM |
|
.switch |
ROM or RAM |
0, 1 |
.econst |
ROM or RAM |
1 |
.text |
ROM or RAM |
0 |
.esysmem |
RAM |
1 |
|
|
|
You can use the SECTIONS directive in the linker command file to customize the section-allocation process. For more information about allocating sections into memory, see the linker description chapter in the TMS320C28x Assembly Language Tools User's Guide.