Technical Support
On-Line Manuals
Compiler Reference Guide
Preface
Arm Compiler Tools Overview
armclang Reference
armclang Command-line Options
Summary of armclang command-line options
-C (armclang)
-c (armclang)
-D (armclang)
-E
-e
-fbare-metal-pie
-fbracket-depth=N
-fcommon, -fno-common
-fdata-sections, -fno-data-sections
-ffast-math, -fno-fast-math
-ffixed-rN
-ffp-mode
-ffunction-sections, -fno-function-sections
-fident, -fno-ident
@file
-fldm-stm, -fno-ldm-stm
-fno-builtin
-fno-inline-functions
-flto, -fno-lto
-fexceptions, -fno-exceptions
-fomit-frame-pointer, -fno-omit-frame-pointer
-fpic, -fno-pic
-fropi, -fno-ropi
-fropi-lowering, -fno-ropi-lowering
-frwpi, -fno-rwpi
-frwpi-lowering, -fno-rwpi-lowering
-fsanitize
-fshort-enums, -fno-short-enums
-fshort-wchar, -fno-short-wchar
-fstack-protector, -fstack-protector-all, -fstack-
-fstrict-aliasing, -fno-strict-aliasing
-fsysv, -fno-sysv
-ftrapv
-fvectorize, -fno-vectorize
-fvisibility
-fwrapv
-g, -gdwarf-2, -gdwarf-3, -gdwarf-4 (armclang)
-I
-include
-L
-l
-M, -MM
-MD, -MMD
-MF
-MG
-MP
-MT
-march
-marm
-masm
-mbig-endian
-mbranch-protection
-mcmodel
-mcmse
-mcpu
-mexecute-only
-mfloat-abi
-mfpu
-mimplicit-it
-mlittle-endian
-mno-neg-immediates
-moutline, -mno-outline
-mpixolib
-munaligned-access, -mno-unaligned-access
-mthumb
-nostdlib
-nostdlibinc
-O (armclang)
-o (armclang)
-pedantic
-pedantic-errors
-Rpass
-S (armclang)
-save-temps
-shared (armclang)
-std
--target
-U
-u (armclang)
-v (armclang)
--version (armclang)
--version_number (armclang)
--vsn (armclang)
-W (armclang)
-Wl
-Xlinker
-x (armclang)
-###
Compiler-specific Keywords and Operators
Compiler-specific keywords and operators
__alignof__
__asm
__declspec attributes
__declspec(noinline)
__declspec(noreturn)
__declspec(nothrow)
__inline
__promise
__unaligned
Global named register variables
Compiler-specific Function, Variable, and Type Att
Function attributes
__attribute__((always_inline)) function attribute
__attribute__((cmse_nonsecure_call)) function attr
__attribute__((cmse_nonsecure_entry)) function att
__attribute__((const)) function attribute
__attribute__((constructor(priority))) function at
__attribute__((format_arg(string-index))) function
__attribute__((interrupt("type"))) function attrib
__attribute__((malloc)) function attribute
__attribute__((naked)) function attribute
__attribute__((noinline)) function attribute
__attribute__((nomerge)) function attribute
__attribute__((nonnull)) function attribute
__attribute__((noreturn)) function attribute
__attribute__((not_tail_called)) function attribut
__attribute__((nothrow)) function attribute
__attribute__((pcs("calling_convention"))) functio
__attribute__((pure)) function attribute
__attribute__((section("name"))) function attribut
__attribute__((target("options"))) function attrib
__attribute__((unused)) function attribute
__attribute__((used)) function attribute
__attribute__((value_in_regs)) function attribute
__attribute__((visibility("visibility_type"))) fun
__attribute__((weak)) function attribute
__attribute__((weakref("target"))) function attrib
Type attributes
__attribute__((aligned)) type attribute
__attribute__((packed)) type attribute
__attribute__((transparent_union)) type attribute
Variable attributes
__attribute__((alias)) variable attribute
__attribute__((aligned)) variable attribute
__attribute__((deprecated)) variable attribute
__attribute__((packed)) variable attribute
__attribute__((section("name"))) variable attribut
__attribute__((unused)) variable attribute
__attribute__((used)) variable attribute
__attribute__((visibility("visibility_type"))) var
__attribute__((weak)) variable attribute
__attribute__((weakref("target"))) variable attrib
Compiler-specific Intrinsics
__breakpoint intrinsic
__current_pc intrinsic
__current_sp intrinsic
__disable_fiq intrinsic
__disable_irq intrinsic
__enable_fiq intrinsic
__enable_irq intrinsic
__force_stores intrinsic
__memory_changed intrinsic
__schedule_barrier intrinsic
__semihost intrinsic
__vfp_status intrinsic
Compiler-specific Pragmas
#pragma clang system_header
#pragma clang diagnostic
#pragma clang section
#pragma once
#pragma pack(...)
#pragma unroll[(n)], #pragma unroll_completely
#pragma weak symbol, #pragma weak symbol1 = symbol
Other Compiler-specific Features
ACLE support
Predefined macros
Inline functions
Volatile variables
Half-precision floating-point data types
Half-precision floating-point number format
Half-precision floating-point intrinsics
Library support for _Float16 data type
BFloat16 floating-point number format
TT instruction intrinsics
Non-secure function pointer intrinsics
Supported architecture feature combinations for sp
armclang Integrated Assembler
Syntax of assembly files for integrated assembler
Assembly expressions
Alignment directives
Data definition directives
String definition directives
Floating-point data definition directives
Section directives
Conditional assembly directives
Macro directives
Symbol binding directives
Org directive
AArch32 target selection directives
AArch64 target selection directives
Space-filling directives
Type directive
Integrated assembler support for the CSDB instruct
armclang Inline Assembler
Inline Assembly
File-scope inline assembly
Inline assembly statements within a function
Assembly string
Output and input operands
Clobber list
volatile
Inline assembly constraint strings
Constraint modifiers
Constraint codes
Constraint codes common to AArch32 state and AArch
Constraint codes for AArch32 state
Constraint codes for AArch64 state
Using multiple alternative operand constraints
Inline assembly template modifiers
Template modifiers common to AArch32 state and AAr
Template modifiers for AArch32 state
Template modifiers for AArch64 state
Forcing inline assembly operands into specific reg
Symbol references and branches into and out of inl
Duplication of labels in inline assembly statement
armlink Reference
fromelf Reference
armar Reference
armasm Legacy Assembler Reference
Appendixes
|
Home / Compiler Reference Guide Version 6.16
Section directives
B7.7 Section directives
The section directives instruct the assembler to change the ELF section that code and data are emitted into.
Syntax
.section name [, "flags " [, %type [, entry_size ] [, group_name [, linkage ]] [, link_order_symbol ] [, unique , unique_id ] ]]
.pushsection .section name [, "flags " [, %type [, entry_size ] [, group_name [, linkage ]] [, link_order_symbol ] [, unique , unique_id ] ]]
.popsection
.text
.data
.rodata
.bss
Description
name
-
The name argument
gives the name of the section to switch to.
By default, if the name is identical to a previous section, or one of the
built-in sections, the assembler switches back to that section. Any
code or data that is assembled is appended to the end of that
section. You can use the unique-id argument to override this
behavior.
flags
-
The optional flags
argument is a quoted string containing any of the following
characters, which correspond to the sh_flags field in the ELF
section header.
Table
B7-14 Section flags
Flag |
Meaning |
a |
SHF_ALLOC: the section is
allocatable. |
w |
SHF_WRITE: the section is
writable. |
y |
SHF_ARM_PURECODE: the section is
not readable. |
x |
SHF_EXECINSTR: the section is
executable. |
o |
SHF_LINK_ORDER: the section has
a link-order restriction. |
M |
SHF_MERGE: the section can be merged. |
S |
SHF_STRINGS: the section
contains null-terminated string. |
T |
SHF_TLS: the section is
thread-local storage. |
G |
SHF_GROUP: the section is a
member of a section group. |
? |
If the previous section was part of a group, this section is in the same group, otherwise it is ignored. |
The flags can be specified as a numeric value, with the same encoding as the sh_flags field in the ELF section header. This field cannot be combined with the flag characters listed in this table. When using this syntax, the quotes around the flags value are still required.
Note: Certain flags need extra arguments, as described in the respective
arguments.
type
-
The optional type argument is accepted with two different syntaxes, %type and "type " . It corresponds to the sh_type field in the ELF section header. The following values for the type argument are accepted:
Table
B7-15 Section Type
Argument |
ELF type |
Meaning |
%progbits |
SHT_PROGBITS |
Section contains either initialized data and instructions or instructions only. |
%nobits |
SHT_NOBITS |
Section contains only zero-initialized data. |
%note |
SHT_NOTE |
Section contains information that the linker or loader use to check compatibility. |
%init_array |
SHT_INIT_ARRAY |
Section contains an array of
pointers to initialization functions. |
%fini_array |
SHT_FINI_ARRAY |
Section contains an array of
pointers to termination functions. |
%preinit_array |
SHT_PREINIT_ARRAY |
Section contains an array of
pointers to pre-initialization functions. |
The type can be specified as a numeric value, with the same encoding as
the sh_type field in the ELF section header. When using
this syntax, the quotes around the type value are still
required.
entry_size
-
If the M flag is specified, the
entry_size argument is required. This
argument must be an integer value, which is the size of the records
that are contained within this section, that the linker can
merge.
group_name
-
If the G flag is specified, the
group_name argument is required. This
argument is a symbol name to be used as the signature to identify
the section group. All sections in the same object file and with the
same group_name
are part of the same section group.
If the ? flag is specified, the section
is implicitly in the same group as the previous section, and the
group_name and linkage options are not
accepted.
It is an error to specify both the G and ? flags on the same section.
linkage
-
If the G flag is specified, the
optional linkage argument is allowed. The only valid value for this
argument is comdat , which has the
same effect as not providing the linkage argument. If any arguments
after the group_name and
linkage arguments are to
be provided, then the linkage argument must be provided.
If the ? flag is specified, the section
is implicitly in the same group as the previous section, and the
group_name and
linkage options are not
accepted.
It is an error to specify both the G and
? flags on the same section.
link_order_symbol
-
If the o flag is specified, the
link_order_symbol argument is required.
This argument must be a symbol which is defined earlier in the same
file. If multiple sections with the o flag are present at link time, the linker ensures
that they are in the same order in the image as the sections that
define the symbols they reference.
unique and
unique_id
-
If the optional unique argument is provided, then the
unique_id argument must also be provided.
This argument must be a constant expression that evaluates to a
positive integer. If a section has previously been created with the
same name and unique ID, then the assembler switches to the existing
section, appending content to it. Otherwise, a new section is
created. Sections without a unique ID specified are never merged
with sections that do have one. Not merging allows creating multiple
sections with the same name. The exact value of the unique ID is not
important, and it has no effect on the generated object file.
Operation
The .section directive switches the current
target section to the one described by its arguments. The .pushsection directive pushes the current target section onto a stack,
and switches to the section described by its arguments. The .popsection directive takes no arguments, and reverts the current
target section to the previous one on the stack. The rest of the directives (.text , .data ,
.rodata , .bss ) switch to one of the built-in sections.
If the name argument of
the .section directive is the same as that of an
existing section, but any of the flags , type , or entry_size arguments do not match the previous
definition of the section, then an error is reported. If the flags , type , and entry_size arguments all match the previous
definition of the section, then the existing section is extended, unless prevented
by the unique and unique_id arguments.
Default
Some section names and section name prefixes implicitly have some flags set. Extra flags can be set using the flags argument, but it is not possible to clear these implicit flags. The section names that have implicit flags are listed in the following table. For sections names not mentioned in the table, the default is to have no flags.
If the %type argument is
not provided, the type is inferred from the section name. For sections names not
mentioned in the following table, the default section type is %progbits .
Table
B7-16 Sections with implicit flags and default types
Section name |
Implicit Flags |
Default Type |
.rodata |
a |
%progbits |
.rodata.* |
a |
%progbits |
.rodata1 |
a |
%progbits |
.text |
ax |
%progbits |
.text.* |
ax |
%progbits |
.init |
ax |
%progbits |
.fini |
ax |
%progbits |
.data |
aw |
%progbits |
.data.* |
aw |
%progbits |
.data1 |
aw |
%progbits |
.bss |
aw |
%nobits |
.bss.* |
aw |
%nobits |
.init_array |
aw |
%init_array |
.init_array.* |
aw |
%init_array |
.fini_array |
aw |
%fini_array |
.fini_array.* |
aw |
%fini_array |
.preinit_array |
aw |
%preinit_array |
.preinit_array.* |
aw |
%preinit_array |
.tdata |
awT |
%progbits |
.tdata.* |
awT |
%progbits |
.tbss |
awT |
%nobits |
.tbss.* |
awT |
%nobits |
.note* |
No default |
%note |
Examples
Splitting code and data into the built-in .text and .data sections. The linker can place these sections independently, for example to place the code in flash memory, and the writable data in RAM.
.text
get_value:
movw r0, #:lower16:value
movt r0, #:upper16:value
ldr r0, [r0]
bx lr
.data
value:
.word 42
Creating a section containing constant, mergeable records. This section contains a series of 8-byte records, where the linker is allowed to merge two records with identical content (possibly coming from different object files) into one record to reduce the image size.
.section mergable, "aM", %progbits, 8
entry1:
.word label1
.word 42
entry2:
.word label2
.word 0x1234
Creating two sections with the same name:
.section .data, "aw", %progbits, unique, 1
.word 1
.section .data, "aw", %progbits, unique, 2
.word 2
Creating a section group containing two sections. Here, the
G flag is used for the first section, using the
group_signature symbol. The second section uses the
? flag to simplify making it part of the same group. Any
further sections in this file using the G flag and
group_signature symbol are placed in the same group.
.section foo, "axG", %progbits, group_signature
get_value:
movw r0, #:lower16:value
movt r0, #:upper16:value
ldr r0, [r0]
bx lr
.section bar, "aw?"
.local value
value:
.word 42
|