You can create an executable file by concatenating input sections from the
object files (.o files). The compiler, by default,
creates code across standard and well-defined sections. Each section is named based on
its associated meaning and purpose. See the various standard sections of the object file
in the following table.
In addition to these sections, you can also create your own custom sections and assign them to memories of your choice.
Note: You do not typically modify the reserved sections, including
.init, .fini,
.ctors, .dtors,
.got, .got2, and
.eh_frame.| Section | Description |
|---|---|
| .text | Text section |
| .rodata | Read only data section |
| .sdata2 | Small read only data section |
| .sbss2 | Small read only uninitialized data section |
| .data | Read/write data section |
| .sdata | Small read/write data section |
| .sbss | Small uninitialized data section |
| .bss | Uninitialized data section |
| .heap | Program heap memory section |
| .stack | Program stack memory section |
-
.text - This section of the object file contains executable program instructions.
This section has the
x(executable),r(read-only) andi(initialized) flags. You can assign it to an initialized read-only memory (ROM) that is addressable from the processor instruction bus. -
.rodata - This section contains read-only data. This section has the
r(read-only) and thei(initialized) flags. Like the.textsection, you can also assign this section to an initialized, read-only memory addressable from the processor data bus. -
.sdata2 - This section is similar to the
.rodatasection. It contains small read-only data of size less than 8 bytes. All data in this section is accessed with reference to the read-only small data anchor. This ensures that all the contents of this section are accessed using a single instruction. You can change the size of the data going into this section with the-Goption to the compiler. This section has ther(read-only) and thei(initialized) flags. -
.data - This section contains read-write data and has the
w(read-write) and thei(initialized) flags. You must map and initialized it to random access memory (RAM). You cannot map it to a ROM. -
.sdata - This section contains small read-write data of a size less than 8 bytes. You
can change the size of the data going into this section with the
-Goption. All data in this section is accessed with reference to the read-write small data anchor. This ensures that all contents of the section can be accessed using a single instruction. This section has thew(read-write) and thei(initialized) flags. You must map it to initialized RAM. -
.sbss2 - This section contains small, read-only uninitialized data of a size less
than 8 bytes. You can change the size of the data going into this section with
the
-Goption. This section has ther(read) flag. You can map it to ROM. -
.sbss - This section contains small uninitialized data of a size less than 8 bytes.
You can change the size of the data going into this section with the
-Goption. This section has thew(read-write) flag. You must map it to RAM. -
.bss - This section contains uninitialized data. This section has the
w(read-write) flag. You must map it to RAM. -
.heap - This section contains uninitialized data that is used as the global program heap. Dynamic memory allocation routines allocate memory from this section. You must map this section to RAM.
-
.stack - This section contains uninitialized data that is used as the program stack.
You must map this section to RAM. This section is typically laid out right after
the
.heapsection. In some versions of the linker, the.stackand.heapsections can appear merged together into a section named.bss_stack. -
.init - This section contains language initialization code and has the same flags
as
.text. You must map it to initialized ROM. -
.fini - This section contains language cleanup code and has the same flags as
.text. You must map it to initialized ROM. -
.ctors - This section contains a list of functions that must be invoked at program
startup and the same flags as
.data. You must map it to initialized RAM. -
.dtors - This section contains a list of functions that must be invoked at program
end, the same flags as
.data. You must map it to initialized RAM. -
.got2/.got - This section contains pointers to program data, the same flags as
.data. You must map it to initialized RAM. -
.eh_frame - This section contains frame unwind information for exception handling. It
contains the same flags as
.rodata. You can map it to initialized ROM. -
.tbss - This section holds uninitialized thread-local data that contribute to the
program memory image. This section has the same flags as
.bss. You must map it to RAM. -
.tdata - This section holds initialized thread-local data that contribute to the program memory image. You must map it to initialized RAM.
-
.gcc_except_table - This section holds language specific data. You must map this section to initialized RAM.
-
.jcr - This section contains information necessary for registering compiled Java classes. The contents are compiler-specific and used by compiler initialization functions. You must map this section to initialized RAM.
-
.fixup - This section contains information necessary for doing fixup, such as the fixup page table and the fixup record table. You must map this section to initialized RAM.