| |||
| Home > Directives Reference > Miscellaneous directives > AREA | |||
The AREA directive instructs the assembler to
assemble a new code or data section. Sections are independent, named,
indivisible chunks of code or data that are manipulated by the linker.
See ELF sections and the AREA directive for more
information.
AREAsectionname{,attr}{,attr}...
where:
sectionnameis the name to give to the section.
You can choose any name for your sections. However, names starting with
a non-alphabetic character must be enclosed in bars or a missing
section name error is generated. For example, |1_DataArea|.
Certain names are conventional. For example, |.text| is
used for code sections produced by the C compiler, or for code sections otherwise
associated with the C library.
attrare one or more comma-delimited section attributes. Valid attributes are:
ALIGN=expressionBy default, ELF sections are aligned on a four-byte boundary. 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.expression
This is not the same as the way that the ALIGN directive is
specified. See ALIGN.
Do not use ALIGN=0 or ALIGN=1 for
ARM code sections.
Do not use ALIGN=0 for Thumb code sections.
ASSOC=section specifies
an associated ELF section. section must
be included in any link that includes sectionnamesection
CODEContains
machine instructions. READONLY is the default.
CODEALIGNCauses the assembler 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.
COMDEFIs a common section definition. This ELF section can contain code or data. It must be identical to any other section of the same name in other source files.
Identical ELF sections with the same name are overlaid in the same section of memory by the linker. If any are different, the linker generates a warning and does not overlay the sections. See Chapter 3 Using the Basic Linker Functionality in the Linker User Guide.
COMGROUP=symbol_nameIs a common group section. All sections within a common
group are common. When the object is linked, other object files
may have a GROUP with signature .
Only one group is kept in the final image.symbol_name
COMMONIs a common data section. You must not define any code or data in it. It is initialized to zeros by the linker. All common sections with the same name are overlaid in the same section of 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 common section of each name.
DATAContains
data, not instructions. READWRITE is the default.
FINI_ARRAYSets the ELF type of the current area to SHT_FINI_ARRAY.
GROUP=symbol_nameIs the signature for the group and must be defined
by the source file, or a file included by the source-file. All AREAS with
the same signature
are placed in the same group. Sections within a group are kept or discovered
together.symbol_name
INIT_ARRAYSets the ELF type of the current area to SHT_INIT_ARRAY.
LINKORDER=sectionSpecifies a relative location for the current section
in the image. It ensures that the order of all the sections with
the LINKORDER attribute, with respect to each other, is
the same as the order of the corresponding named in
the image.sections
MERGE=nIndicates that the linker can merge the current
section with other sections with the MERGE= attribute. nn is
the size of the elements in the section, for example n is
1 for characters. You must not assume that the section will be merged
because the attribute does not force the linker to merge the sections.
NOALLOCIndicates that no memory on the target system is allocated to this area.
NOINITIndicates 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. See Chapter 3 Using
the Basic Linker Functionality in the Linker
User Guide.
PREINIT_ARRAYSets the ELF type of the current area to SHT_PREINIT_ARRAY.
READONLYIndicates that this section should not be written to. This is the default for Code areas.
READWRITEIndicates that this section can be read from and written to. This is the default for Data areas.
SECFLAGS=nAdds one or more ELF flags, denoted by n, to
the current section.
SECTYPE=nSets the ELF type of the current section to n.
STRINGSAdds the SHF_STRINGS flag to
the 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
using the DCB directive.
Use the AREA directive to subdivide your source
file into ELF sections. You can use the same name in more than one AREA directive.
All areas with the same name are placed in the same ELF section.
Only the attributes of the first AREA directive of
a particular name are applied.
You should normally use separate ELF sections for code and data. Large programs can usually be conveniently divided into several code sections. Large independent data sets are also usually best placed in separate sections.
The scope of local labels is defined by AREA directives,
optionally subdivided by ROUT directives (see Local labels and ROUT).
There must be at least one AREA directive for
an assembly.
The assembler emits R_ARM_TARGET1 relocations
for the DCD and DCDU directives (see DCD and DCDU) if the directive
uses PC-relative expressions and is in any of the PREINIT_ARRAY, FINI_ARRAY,
or INIT_ARRAY ELF sections. You can override
the relocation using the RELOC directive (see RELOC) after each DCD or DCDU directive.
If this relocation is used, read-write sections might become read-only
sections at link time if the platform ABI permits this.