SLAA534A June 2013 – June 2020
In a relocatable object file output by the compiler or assembler, variables are allocated into sections using default rules and compiler directives. A section is an indivisible unit of allocation in a relocatable file. Sections often contain objects with similar properties. Various sections are designated for data, depending on whether the section is initialized, whether it is writable or read-only, how it will be addressed, and what kind of data it contains.
Conventions for placement of static variables into sections and for how they are addressed are covered in Section 4.4.2.
The linker combines sections from object files to form segments in an ELF load module (executable ). A segment is a continuous range of memory allocated to a load module, representing part of the execution image of the program.
A load module may contain one or more data segments, into which the linker allocates stack, heap, and static variables. Items may be grouped into a single segment or multiple segments, subject only to these restrictions:
The run-time environment can dynamically allocate or resize uninitialized data segments, to allocate space for items such as the stack and heap.
Figure 4-1 shows the data sections defined by the ABI, and an abstract mapping of sections into segments. The mapping is only representative; the specific configuration may vary by platform or system. Initialized sections are shaded blue; uninitialized sections are shaded gray.
The .const section contains read-only constants. The .const section may be located in read-only memory, and may be addressed using absolute addressing.
The .data section contains initialized read-write data.
The .bss section contains uninitialized read-write data.
The .common section contains common-block symbols allocated by the linker. This is not an actual section in the object files. Instead, the section name is a convention in the linker command file for placing variables. This section should not be used for other purposes.
Additional special sections that can be placed by the linker command file are listed in Section 11.4.5.