Go forward to bss.
Go backward to as Sections.
Go up to Sections.
Sub-Sections
============
Assembled bytes conventionally fall into two sections: text and data.
You may have separate groups of data in named sections that you want to
end up near to each other in the object file, even though they are not
contiguous in the assembler source. `as' allows you to use
"subsections" for this purpose. Within each section, there can be
numbered subsections with values from 0 to 8192. Objects assembled
into the same subsection will be grouped with other objects in the same
subsection when they are all put into the object file. For example, a
compiler might want to store constants in the text section, but might
not want to have them interspersed with the program being assembled.
In this case, the compiler could issue a `.text 0' before each section
of code being output, and a `.text 1' before each group of constants
being output.
Subsections are optional. If you don't use subsections, everything
will be stored in subsection number zero.
Each subsection is zero-padded up to a multiple of four bytes.
(Subsections may be padded a different amount on different flavors of
`as'.)
Subsections appear in your object file in numeric order, lowest
numbered to highest. (All this to be compatible with other people's
assemblers.) The object file contains no representation of subsections;
`ld' and other programs that manipulate object files will see no trace
of them. They just see all your text subsections as a text section,
and all your data subsections as a data section.
To specify which subsection you want subsequent statements assembled
into, use a numeric argument to specify it, in a `.text EXPRESSION' or
a `.data EXPRESSION' statement. When generating COFF output, you can
also use an extra subsection argument with arbitrary named sections:
`.section NAME, EXPRESSION'. EXPRESSION should be an absolute
expression. (See Expressions.) If you just say `.text' then
`.text 0' is assumed. Likewise `.data' means `.data 0'. Assembly
begins in `text 0'. For instance:
.text 0 # The default subsection is text 0 anyway.
.ascii "This lives in the first text subsection. *"
.text 1
.ascii "But this lives in the second text subsection."
.data 0
.ascii "This lives in the data section,"
.ascii "in the first data subsection."
.text 0
.ascii "This lives in the first text section,"
.ascii "immediately following the asterisk (*)."
Each section has a "location counter" incremented by one for every
byte assembled into that section. Because subsections are merely a
convenience restricted to `as' there is no concept of a subsection
location counter. There is no way to directly manipulate a location
counter--but the `.align' directive will change it, and any label
definition will capture its current value. The location counter of the
section that statements are being assembled into is said to be the
"active" location counter.