4.6 Sections

Sections are independent, named, indivisible chunks of code or data that are manipulated by the linker.

ARM syntax

The AREA directive instructs the assembler to assemble a new code or data section.
Section attributes within the AREA directive provide information about the section. Available section attributes include the following:
  • CODE specifies that the section contains machine instructions.
  • READONLY specifies that the section must not be written to.
  • ALIGN=n specifies that the section is aligned on a 2n byte boundary
For example:
AREA mysection, CODE, READONLY, ALIGN=3

Note

The ALIGN attribute does not take the same values as the ALIGN directive. ALIGN=n (the AREA attribute) aligns on a 2n byte boundary. ALIGN n (the ALIGN directive) aligns on an n-byte boundary.

GNU syntax

The .section directive instructs the assembler to assemble a new code or data section.
Flags provide information about the section. Available section flags include the following:
  • x specifies that the section is executable.
  • w specifies that the section is writable.
For example:
.section  mysection,"x"
Not all ARM® syntax AREA attributes map onto GNU syntax .section flags. For example, the ARM syntax ALIGN attribute corresponds to the GNU syntax .balign directive, rather than a .section flag:
.section  mysection,"x"
.balign 8
Related information
GNU Binutils - Using as: .section
GNU Binutils - Using as: .align
armasm User Guide: AREA
Non-ConfidentialPDF file icon PDF versionARM DUI0742F
Copyright © 2014-2016 ARM. All rights reserved.