The compiler produces relocatable blocks of code
and data called sections, which are allocated in memory in a variety of ways
to conform to various system configurations. For 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:
- 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 all static variables (initialized or uninitialized; global or
local). At program startup time, the C/C++ boot routine copies data out
of the .cinit section (which can be in ROM) and uses it to initialize
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)
- Initialized sections
contain data or executable code. Initialized sections are usually read-only;
exceptions are noted below. The C/C++ compiler creates the following initialized
sections:
- The .args section contains space
for the command-line arguments. See the --arg_size option.
- The .binit section
contains boot time copy tables. For details on BINIT, see the
TMS320C28x
Assembly Language
Tools User's Guide.
- The .cinit section contains tables
for initializing variables and constants. 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.
- 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. See the --exceptions option for details. (EABI only)
- The .ppdata section contains data
tables for compiler-based profiling. See the --gen_profile_info option
for details. This section is writable.
- The .ppinfo section contains
correlation tables for compiler-based profiling. See the
--gen_profile_info option for details.
- The .const section contains string
literals and variables defined with the C/C++ qualifier const
(even if the constant is defined as volatile, but not if the
constant is one of the exceptions described in Section 6.5.1). String literals are placed in the .const:.string subsection to
enable greater link-time placement control. (EABI only)
- The .econst section contains string
literals and global variables that are defined with the C/C++ qualifier
const (even if the constant is defined as volatile,
but not if the constant is one of the exceptions described in Section 6.5.1). 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 static variables, whether they are global or
local. (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.) This section is
writable.
- 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.
- The .TI.bound
section is used to associate a symbol to a specific memory
address. When either the LOCATION pragma (see Section 6.9.16) or
the "location" or "preserve" variable attribute (see Section 6.15.4) is
used to associate a symbol with a specific memory address, a .TI.bound
section is created for the symbol. In the case of "preserve" symbols,
when .TI.bound sections are contiguous in memory, the linker can
coalesce them into a single output section, which reduces the number of
CINIT records required to initialize them. This section may be writable
or read-only.
- The .TI.update
section contains symbols that need to be reinitialized when a
warm start occurs. Reinitialization is performed by the
__TI_auto_init_warm() RTS function. It is recommended that you add an
entry to the linker command file to place the .TI.update section in an
appropriate memory range. This section is writable.
The following table shows the placement of various
types of initialized variables:
|
EABI |
COFF |
|
global |
local |
global |
local |
const |
.const |
* |
.econst |
* |
static |
.data |
.data |
.ebss |
.ebss |
string constants, literals |
.const:.string |
.const:.string |
.econst:.string |
.econst:.string |
* Initialized const (non-static) local variables are
not placed in output sections; they are initialized in memory (usually RAM) at
run-time as needed.
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.9.4 and Section 6.9.6).
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.