You copied the Doc URL to your clipboard.

21.6 AREA

The AREA directive instructs the assembler to assemble a new code or data section.


AREA sectionname{,attr}{,attr}...



is the name to give to the section. Sections are independent, named, indivisible chunks of code or data that are manipulated by the linker.

You can choose any name for your sections. However, namesstarting with a non-alphabetic character must be enclosed in barsor a missing section name error is generated. For example, |1_DataArea|.

Certain names are conventional. For example, |.text| isused for code sections produced by the C compiler, or for code sectionsotherwise associated with the C library.


are one or more comma-delimited section attributes.Valid attributes are:


By default, ELF sections are aligned on a four-byteboundary. expression can have any integer value from 0 to 31. The section is aligned on a 2expression-byte boundary. For example, if expression is 10,the section is aligned on a 1KB boundary.

This is not the same as the way that the ALIGN directiveis specified.


Do not use ALIGN=0 or ALIGN=1 forARM code sections.

Do not use ALIGN=0 for Thumb code sections.


section specifiesan associated ELF section. sectionname must beincluded in any link that includes section


Contains machine instructions. READONLY isthe default.


Causes armasm to insert NOP instructions when the ALIGN directive is used after ARM or Thumb instructions within the section, unless the ALIGN directive specifies a different padding. CODEALIGN is the default for execute-only sections.


Is a common section definition. This ELF sectioncan contain code or data. It must be identical to any other sectionof the same name in other source files.

Identical ELF sections with the same name are overlaid inthe same section of memory by the linker. If any are different,the linker generates a warning and does not overlay the sections.


Is the signature that makes the AREA partof the named ELF section group. See the GROUP=symbol_name formore information. The COMGROUP attributemarks the ELF section group with the GRP_COMDAT flag.


Is a common data section. You must not define anycode or data in it. It is initialized to zeros by the linker. Allcommon sections with the same name are overlaid in the same sectionof memory by the linker. They do not all have to be the same size.The linker allocates as much space as is required by the largest commonsection of each name.


Contains data, not instructions. READWRITE isthe default.


Indicates that the section is execute-only. Execute-only sections must also have the CODE attribute, and must not have any of the following attributes:

  • DATA.

armasm faults if any of the following occur in an execute-only section:

  • Explicit data definitions, for example DCD and DCB.
  • Implicit data definitions, for example LDR r0, =0xaabbccdd.
  • Literal pool directives, for example LTORG, if there is literal data to be emitted.
  • INCBIN or SPACE directives.
  • ALIGN directives, if the required alignment cannot be accomplished by padding with NOP instructions. armasm implicitly applies the CODEALIGN attribute to sections with the EXECONLY attribute.

Sets the ELF type of the current area to SHT_FINI_ARRAY.


Is the signature that makes the AREA partof the named ELF section group. It must be defined by the sourcefile, or a file included by the source file. All AREAS withthe same symbol_name signatureare part of the same group. Sections within a group are kept ordiscarded together.


Sets the ELF type of the current area to SHT_INIT_ARRAY.


Specifies a relative location for the current sectionin the image. It ensures that the order of all the sections withthe LINKORDER attribute, with respect toeach other, is the same as the order of the corresponding named sections inthe image.


Indicates that the linker can merge the currentsection with other sections with the MERGE=n attribute. n isthe size of the elements in the section, for example n is1 for characters. You must not assume that the section is merged,because the attribute does not force the linker to merge the sections.


Indicates that no memory on the target system isallocated to this area.


Indicates that the data section is uninitialized, or initialized to zero. It contains only space reservation directives SPACE or DCB, DCD, DCDU, DCQ, DCQU, DCW, or DCWU with initialized values of zero. You can decide at link time whether an area is uninitialized or zero-initialized.


ARM Compiler does not support systems with ECC or parity protection where the memory is not initialized.

Sets the ELF type of the current area to SHT_PREINIT_ARRAY.


Indicates that this section must not be writtento. This is the default for Code areas.


Indicates that this section can be read from andwritten to. This is the default for Data areas.


Adds one or more ELF flags, denoted by n,to the current section.


Sets the ELF type of the current section to n.


Adds the SHF_STRINGS flag tothe current section. To use the STRINGS attribute,you must also use the MERGE=1 attribute.The contents of the section must be strings that are nul-terminated usingthe DCB directive.


Causes armasm to insert zeros when the ALIGN directive is used after ARM or Thumb instructions within the section, unless the ALIGN directive specifies a different padding. ZEROALIGN is the default for sections that are not execute-only.


Use the AREA directive to subdivideyour source file into ELF sections. You can use the same name inmore than one AREA directive. All areas withthe same name are placed in the same ELF section. Only the attributesof the first AREA directive of a particularname are applied.

In general, ARM recommends that you use separate ELF sectionsfor code and data. However, you can put data in code sections. Largeprograms can usually be conveniently divided into several code sections.Large independent data sets are also usually best placed in separate sections.

The scope of numeric local labels is defined by AREA directives,optionally subdivided by ROUT directives.

There must be at least one AREA directivefor an assembly.


armasm emits R_ARM_TARGET1 relocationsfor the DCD and DCDU directivesif the directive uses PC-relative expressions and is in any of the PREINIT_ARRAY, FINI_ARRAY,or INIT_ARRAY ELF sections. You can overridethe relocation using the RELOC directiveafter each DCD or DCDU directive.If this relocation is used, read-write sections might become read-onlysections at link time if the platform ABI permits this.


The following example defines a read-only code section named Example:

    AREA    Example,CODE,READONLY   ; An example code section.            ; code