6.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 Section 8. For details about C7000 section names, see the C7000 Embedded Application Binary Interface (EABI) Reference Guide (SPRUIG4).
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 the command argument for a host-based loader. 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 Section 12.8.4.2.
- The .cinit section is created only if you are using the --rom_model option. It contains tables for explicitly initialized global and static variables.
- The .got section contains the global offset table.
- The .init_array section contains the table for calling global constructors.
- The .ovly section contains copy tables for unions in which different sections have the same run address. This is a read-only section.
- The .data section reserves space for non-const, initialized global and static variables.
- The .c7xabi.exidx section contains the index table for exception handling. The .c7xabi.extab section contains stack unwinding instructions for exception handling. These sections are read-only. See the --exceptions option for details.
- The .name.load section contains the compressed image of section name. This section is read-only. See Section 12.8 for information on copy tables.
- 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 5.5.2). This is a read-only section. 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. 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. These variables are allocated by the assembler.
- The .common section reserves space for uninitialized global and static variables. These variables are allocated by the linker. Unused uninitialized variables are usually created as common symbols (unless you specify --common=off), so that they can be excluded from the resulting application.
- The .stack section reserves memory for the system 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.
NOTE
Use Only Code in Program Memory
With the exception of code sections, the initialized and uninitialized sections cannot be allocated into internal program memory.
The assembler creates the default sections .text, , and .data. You can instruct the compiler to create additional sections by using the CODE_SECTION and DATA_SECTION pragmas (see Section 5.8.5 and Section 5.8.8).