SPARC Assembly Language Reference Manual

Exit Print View

Updated: July 2014
 
 

2.1.2 Predefined User Sections

A section that can be manipulated by the section control directives is known as a user section. You can use the section control directives to change the user section in which code or data is generated. Table 2–3 lists some of the predefined user sections that can be named in the section control directives. For details and additional information, see Special Sections in Oracle Solaris 11.2 Linkers and Libraries Guide

Table 2-3  User Sections In Section Control Directives
Section Name
Description
.bss
Section contains uninitialized read-write data.
.comment
Comment section.
.data & .data1
Section contains initialized read-write data.
.debug
Section contains debugging information.
.fini
Section contains runtime finalization instructions.
.init
Section contains runtime initialization instructions.
.rodata & .rodata1
Section contains read-only data.
.text
Section contains executable text.
.line
Section contains line # info for symbolic debugging.
.note
Section contains note information.

2.1.2.1 Creating an .init Section in an Object File

The .init sections contain codes that are to be executed before the the main program is executed. To create an .init section in an object file, use the assembler pseudo-ops shown in Example 2–1 .

Example 2-1  Creating an .init Section
.section ".init"

.align   4

<instructions>

At link time, the .init sections in a sequence of .o files are concatenated into an .init section in the linker output file. The code in the .init section are executed before the main program is executed.

Because the whole .init section is treated as a single function body, it is recommented that the only code added to these sections be in the following form:.

call routine_name
nop

The called routine should be located in another section. This will prevent conflicting register and stack usage within the .init sections.

2.1.2.2 Creating a .fini Section in an Object File

.fini sections contain codes that are to be executed after the the main program is executed. To create an .fini section in an object file, use the assembler pseudo-ops shown in Example 2–2 .

Example 2-2  Creating an .fini Section
.section ".fini"

.align   4

<instructions>

At link time, the .fini sections in a sequence of .o files are concatenated into a .fini section in the linker output file. The codes in the .fini section are executed after the main program is executed.

Because the whole .fini section is treated as a single function body, it is recommended that the only code added to these section be in the following form:.

call routine_name
nop

The called routine should be located in another section. This will prevent conflicting register and stack usage within the .fini sections.