4.6. Directives that Control Section Use

A “section” is a continuous range of addresses. Anything that requires space – be it code, read-only data, or read-write data – will be contained in the assembly language’s notion of a section. All data within a section is handled the same. For example, a range of memory may be a “read only” section.

Some sections are manipulated by the linker; others are used by the assembler and may have no meaning except during assembly.

Object files written by the assembler have at least three sections, any of which may be empty. These are named the .text, .data and .bss sections. The assembler can generate additional named sections if you use the .section directive.

Within the object file, the .text section starts at address 0, the .data section follows, and the .bss section follows the .data section. If you do not use any directives that place output in the .text or .data sections, these sections still exist, but are empty.

Addresses used by the assembler are relative to the start of the section that contains them. The {secname N} or (section) + (offset into section) notation can be used to describe an address relative to the start of its section.

If the section for an address is unknown at assembly time, it is treated as part of the undefined section – {undefined U} – where U is filled in later. Since numbers are always defined, the only way to generate an undefined address is to mention an undefined symbol. A reference to a named common block would be such a symbol; its value is unknown at assembly time so it has section undefined.

The assembler keeps a stack of section/subsection combinations used. The .previous. .popsection, and .pushsection directives can be used to manipulate this stack.

The following directives control section use.

.org new-location-counter,fill
.pushsection name[,subsection][, “flags”[,%type[,arguments]]]
.section name[,”flags”[,%type[,arguments]]]