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 .args section contains space for the command-line arguments. This section is read-only. See the --arg_size option for details.
- 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 contains tables for initializing variables and constants. This is a read-only section. The C28x .cinit record is limited to 16 bits. This limits initialized objects to 64K. (For EABI, the linker creates the .cinit section. For COFF, the compiler creates .cinit sections.)
- The .ovly section contains copy tables for unions in which different sections have the same run address. This is a read-only section.
- The .init_array section contains global constructor tables. (EABI only)
- The .pinit section contains global constructor tables. (COFF only)
- The .c28xabi.exidx section contains the index table for exception handling. The .c28xabi.extab section contains stack unwinding instructions for exception handling. These sections are read-only. See the --exceptions option for details. (EABI only)
- The .ppinfo section contains correlation tables and the .ppdata section contains data tables for compiler-based profiling. See the --gen_profile_info option for details.
- The .const section contains string literals, floating-point constants, 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 .const:.string subsection to enable greater link-time placement control. (EABI only)
- 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. (COFF only)
- The .data section reserves space for non-const, initialized global and static variables. (For EABI, the compiler generates this section and it is used for initialized global and static variables. For COFF, this section may be used by assembly code, but is not used otherwise.)
- The .switch section contains tables for switch statements. This section is placed in data memory by default. If the --unified_memory option is used, this section is placed in program memory.
- 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 .bss section reserves space for uninitialized global and static variables. Uninitialized variables that are also unused are usually created as common symbols instead of being placed in .bss so that they can be excluded from the resulting application. (EABI only for compiler; EABI and COFF for assembler)
- 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. (COFF only)
- 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. This 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. (COFF only)
- The .sysmem 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 .sysmem section. (EABI only)
The assembler creates the default sections .text, .ebss or .bss (depending on the ABI), 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.
The linker also creates some additional sections not referenced by the compiler. For example, the .common section contains common-block symbols allocated by the linker.
For EABI, it is encouraged that you use a unified memory scheme that places all sections on page 0. However, the default linker command file specifies page 0 or 1 for sections as indicated in the following table. In general, uninitialized and constant value sections are placed on page 1 by the linker command file; all other sections are generally placed on page 0.
Table 7-1 Summary of Sections and Memory Placement
Section |
Type of Memory |
Default Page |
.binit |
expected to be in FLASH/ROM |
1 |
.bss (EABI only) |
must be in RAM |
1 |
.ebss (COFF only) |
must be in RAM |
1 |
.c28xabi.exidx (EABI only) |
expected to be in FLASH/ROM |
1 |
.c28xabi.extab (EABI only) |
expected to be in FLASH/ROM |
1 |
.cinit (1) |
expected to be in FLASH/ROM |
0 |
.const (EABI only) |
expected to be in FLASH/ROM |
1 |
.econst (COFF only) |
expected to be in FLASH/ROM |
1 |
.data (used mainly by EABI) |
must be in RAM |
0 |
.init_array (EABI only) |
expected to be in FLASH/ROM |
0 |
.pinit (COFF only) |
expected to be in FLASH/ROM |
0 |
.ppdata |
must be in RAM |
1 |
.stack |
must be in RAM |
1 |
.switch |
depends on the --unified_memory option setting |
0, 1 |
.sysmem (EABI only) |
must be in RAM |
1 |
.esysmem (COFF only) |
must be in RAM |
1 |
.text |
expected to be in FLASH/ROM |
0 |
(1) The .cinit section is created by the compiler for COFF and by the linker for EABI.
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.