SPRU513Y August 2001 – June 2022 SM320F28335-EP
The smallest unit of an object file is a section. A section is a block of code or data that occupies contiguous space in the memory map. Each section of an object file is separate and distinct.
COFF format executable object files contain sections.
ELF format executable object files contain segments. An ELF segment is a meta-section. It represents a contiguous region of target memory. It is a collection of sections that have the same property, such as writeable or readable. An ELF loader needs the segment information, but does not need the section information. The ELF standard allows the linker to omit ELF section information entirely from the executable object file.
Object files usually contain three default sections:
.text section | Contains executable code (1) |
.data section | Usually contains initialized data |
.ebss section (for COFF) .bss section (for EABI) | Usually reserves space for uninitialized variables |
Note that the .data section is used mainly for EABI. For COFF, the compiler generates .cinit sections that are used to initialize the .ebss section. The assembler can be used to place initialized data in the .data section for both COFF and EABI.
The assembler and linker allow you to create, name, and link other kinds of sections. The .text, .data, and .ebss or .bss sections are archetypes for how sections are handled.
There are two basic types of sections:
Initialized sections | Contain data or code. The .text and .data sections are initialized; user-named sections created with the .sect assembler directive are also initialized. |
Uninitialized sections | Reserve space in the memory map for uninitialized data. The .ebss or .bss section is uninitialized; user-named sections created with the .usect assembler directive are also uninitialized. |
Several assembler directives allow you to associate various portions of code and data with the appropriate sections. The assembler builds these sections during the assembly process, creating an object file organized as shown in Figure 3-1.
One of the linker's functions is to relocate sections into the target system's memory map; this function is called placement. Because most systems contain several types of memory, using sections can help you use target memory more efficiently. All sections are independently relocatable; you can place any section into any allocated block of target memory. For example, you can define a section that contains an initialization routine and then allocate the routine in a portion of the memory map that contains ROM. For information on section placement, see the "Specifying Where to Allocate Sections in Memory" section of the TMS320C28x Optimizing C/C++ Compiler User's Guide.
Figure 3-1 shows the relationship between sections in an object file and a hypothetical target memory. (This figure shows COFF sections. For EABI, the .ebss section would be .bss.) ROM may be EEPROM, FLASH or some other type of physical memory in an actual system.