Section Definition Directive

The .section directive defines new sections, switches from one section to another, and sets the current section. The .section directive has the following formats, with a different functionality for each format:

.section section-name

.section section-name,"flags","type"

.section section-name = "flags","type"

Where:

section-name

Represents a user-defined name using any valid identifier. Section names are case-sensitive.

flags

Represents a string constant composed of one or more characters that specify the attributes of a section. See Table Section Flag Characters for a list of the valid flag characters.

type

Represents a string constant specifying a type attribute of a section. See Table Section Types for a list of the section types.

In the first format, the .section directive sets the section-name as the current section. In the second format, the .section directive defines a new section, assigns flags and type attributes, and makes the newly-defined section the current section. If the newly-defined section has the same name, flag attributes, and type attribute as a previously-defined existing section, the assembler switches to the previously-defined section without defining a new one. For example, the following .section directive defines a new section (my_section), assigns flags ("aw") and type ("progbits") attributes, and makes it the current section.

.section my_section, "aw","progbits"

In the third format, the .section directive creates a new section with a previously-defined section name, and assigns it new flags and type attributes. The newly-created section becomes the current section; any reference to this section name refers to the newly-created section. The Using Section Directives section illustrates how to use the .section directive.