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
MSP430
Assembly Language Tools User's
Guide.
There are two basic types of
sections:
- 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 .binit section
contains boot time copy tables. For details on BINIT, see the
MSP430
Assembly Language
Tools User's Guide.
- The .cinit section contains tables
for initializing variables and constants. The compiler does not create
this section; instead, the linker does.
- The .init_array section contains
the table of pointers to initialization routines for global C++
objects.
- The .ovly section contains copy tables for unions
in which different sections have the same run address.
- The .data section contains
initialized global and static variables. This section is writable.
- For EABI only, the .mspabi.exidx
section contains the index table for exception handling. The
.mspabi.extab section contains unwinding instructions for
exception handling. See the --exceptions option for details.
- The .const section contains string
constants, string literals, switch tables, 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.8.1). String literals are placed in the .const:.string subsection to
enable greater link-time placement control.
- 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.
- 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 global and static variables. At boot or load time,
the C/C++ boot routine or the loader copies data out of the .cinit
section (which can be in ROM) and stores it in the .bss section.
- For EABI only, the
.bss section reserves space for uninitialized global and
static variables. Uninitialized variables that are also unused are
usually created as common symbols (unless you specify --common=off)
instead of being placed in .bss so that they can be excluded from the
resulting application.
- The .stack section
reserves memory for the C/C++ software
stack.
- The .sysmem
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 .sysmem section.
The
assembler creates the default sections .text, .bss, and .data. You can instruct the compiler to create additional
sections by using the CODE_SECTION and DATA_SECTION pragmas (see Section 6.12.5 and Section 6.12.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 6-1 Summary of Sections and Memory
Placement
Section |
Type of Memory |
Section |
Type of Memory |
.bss |
RAM |
.pinit or .init_array |
ROM or RAM |
.cinit |
ROM or RAM |
.stack |
RAM |
.const |
ROM or RAM |
.sysmem |
RAM |
.data |
RAM |
.text |
ROM or RAM |
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 MSP430 Assembly Language Tools
User's Guide.