Keil Logo

Arm Compiler User Guide

Arm® Compiler User Guide

Version 6.16

Table of Contents

About this book
Using this book
Typographic conventions
Other information
1 Getting Started
1.1 Introduction to Arm® Compiler 6
1.2 About the Arm® Compiler toolchain assemblers
1.3 Installing Arm® Compiler
1.4 Accessing Arm® Compiler from Arm® Development Studio
1.5 Accessing Arm® Compiler from the Arm® Keil® µVision® IDE
1.6 Compiling a Hello World example
1.7 Using the integrated assembler
1.8 Running bare-metal images
1.9 Architectures supported by Arm® Compiler
1.10 Using Arm® Compiler securely in a shared environment
2 Getting Started with the SVE features in Arm® Compiler
2.1 Introducing SVE
2.2 Assembling SVE code
2.3 Disassembling SVE object files
2.4 Running a binary in an AEMv8-A Base Fixed Virtual Platform (FVP)
3 Using Common Compiler Options
3.1 Mandatory armclang options
3.2 Common Arm® Compiler toolchain options
3.3 Selecting source language options
3.4 Selecting optimization options
3.5 Building to aid debugging
3.6 Linking object files to produce an executable
3.7 Linker options for mapping code and data to target memory
3.8 Passing options from the compiler to the linker
3.9 Controlling diagnostic messages
3.10 Selecting floating-point options
3.11 Compilation tools command-line option rules
4 Writing Optimized Code
4.1 Effect of the volatile keyword on compiler optimization
4.2 Optimizing loops
4.3 Inlining functions
4.4 Stack use in C and C++
4.5 Packing data structures
4.6 Optimizing for code size or performance
4.7 Methods of minimizing function parameter passing overhead
4.8 Optimizing across modules with Link-Time Optimization
4.8.1 Enabling Link-Time Optimization
4.8.2 Restrictions with Link-Time Optimization
4.8.3 Removing unused code across multiple object files
4.9 Scatter file section or object placement with Link-Time Optimization
4.10 How optimization affects the debug experience
5 Assembling Assembly Code
5.1 Assembling armasm and GNU syntax assembly code
5.2 Preprocessing assembly code
6 Using Assembly and Intrinsics in C or C++ Code
6.1 Using intrinsics
6.2 Custom Datapath Extension support
6.3 Writing inline assembly code
6.4 Calling assembly functions from C and C++
7 SVE Coding Considerations with Arm® Compiler
7.1 Embedding SVE assembly code directly into C and C++ code
7.2 Using SVE and SVE2 intrinsics directly in your C code
8 Mapping Code and Data to the Target
8.1 What the linker does to create an image
8.1.1 What you can control with a scatter file
8.1.2 Interaction of OVERLAY and PROTECTED attributes with armlink merge options
8.2 Placing data items for target peripherals with a scatter file
8.3 Placing the stack and heap with a scatter file
8.4 Root region
8.4.1 Effect of the ABSOLUTE attribute on a root region
8.4.2 Effect of the FIXED attribute on a root region
8.5 Placing functions and data in a named section
8.6 Loading armlink-generated ELF files that have complex scatter-files
8.7 Placement of functions and data at specific addresses
8.7.1 Placement of __at sections at a specific address
8.7.2 Restrictions on placing __at sections
8.7.3 Automatic placement of __at sections
8.7.4 Manual placement of __at sections
8.7.5 Place a key in flash memory with an __at section
8.7.6 Placing constants at fixed locations
8.7.7 Placing jump tables in ROM
8.7.8 Placing a variable at a specific address without scatter-loading
8.7.9 Placing a variable at a specific address with scatter-loading
8.8 Bare-metal Position Independent Executables
8.9 Placement of Arm® C and C++ library code
8.9.1 Placement of code in a root region
8.9.2 Placement of Arm® C library code
8.9.3 Placing Arm® C++ library code
8.10 Manual placement of unassigned sections
8.10.1 Default rules for placing unassigned sections
8.10.2 Command-line options for controlling the placement of unassigned sections
8.10.3 Prioritizing the placement of unassigned sections
8.10.4 Specify the maximum region size permitted for placing unassigned sections
8.10.5 Examples of using placement algorithms for .ANY sections
8.10.6 Example of next_fit algorithm showing behavior of full regions, selectors, and priority
8.10.7 Examples of using sorting algorithms for .ANY sections
8.10.8 Behavior when .ANY sections overflow because of linker-generated content
8.11 Placing veneers with a scatter file
8.12 Preprocessing a scatter file
8.12.1 Default behavior for armclang -E in a scatter file
8.12.2 Use of other preprocessors in a scatter file
8.13 Reserving an empty block of memory
8.13.1 Characteristics of a reserved empty block of memory
8.13.2 Example of reserving an empty block of memory
8.14 Alignment of regions to page boundaries
8.15 Alignment of execution regions and input sections
9 Overlays
9.1 Overlay support in Arm® Compiler
9.2 Automatic overlay support
9.2.1 Automatically placing code sections in overlay regions
9.2.2 Overlay veneer
9.2.3 Overlay data tables
9.2.4 Limitations of automatic overlay support
9.2.5 Writing an overlay manager for automatically placed overlays
9.3 Manual overlay support
9.3.1 Manually placing code sections in overlay regions
9.3.2 Writing an overlay manager for manually placed overlays
10 Embedded Software Development
10.1 About embedded software development
10.2 Default compilation tool behavior
10.3 C library structure
10.4 Default memory map
10.5 Application startup
10.6 Tailoring the C library to your target hardware
10.7 Reimplementing C library functions
10.8 Tailoring the image memory map to your target hardware
10.9 About the scatter-loading description syntax
10.10 Root regions
10.11 Placing the stack and heap
10.12 Run-time memory models
10.13 Reset and initialization
10.14 The vector table
10.15 ROM and RAM remapping
10.16 Local memory setup considerations
10.17 Stack pointer initialization
10.18 Hardware initialization
10.19 Execution mode considerations
10.20 Target hardware and the memory map
10.21 Execute-only memory
10.22 Building applications for execute-only memory
10.23 Vector table for ARMv6 and earlier, ARMv7-A and ARMv7-R profiles
10.24 Vector table for M-profile architectures
10.25 Vector Table Offset Register
10.26 Integer division-by-zero errors in C code
11 Building Secure and Non-secure Images Using Arm®v8‑M Security Extensions
11.1 Overview of building Secure and Non-secure images
11.2 Building a Secure image using the Arm®v8‑M Security Extensions
11.3 Building a Non-secure image that can call a Secure image
11.4 Building a Secure image using a previously generated import library
12 Overview of the Linker
12.1 About the linker
12.1.1 Summary of the linker features
12.1.2 What the linker can accept as input
12.1.3 What the linker outputs
12.2 armlink command-line syntax
12.3 What the linker does when constructing an executable image
13 Getting Image Details
13.1 Options for getting information about linker-generated files
13.2 Identifying the source of some link errors
13.3 Example of using the --info linker option
13.4 How to find where a symbol is placed when linking
14 SysV Dynamic Linking
14.1 Build a SysV shared object
14.2 Build a SysV executable
15 Overview of the fromelf Image Converter
15.1 About the fromelf image converter
15.2 fromelf execution modes
15.3 Getting help on the fromelf command
15.4 fromelf command-line syntax
16 Using fromelf
16.1 General considerations when using fromelf
16.2 Examples of processing ELF files in an archive
16.3 Options to protect code in image files with fromelf
16.4 Options to protect code in object files with fromelf
16.5 Option to print specific details of ELF files
16.6 Using fromelf to find where a symbol is placed in an executable ELF image
17 Overview of the Arm® Librarian
17.1 About the Arm® Librarian
17.2 Considerations when working with library files
17.3 armar command-line syntax
17.4 Option to get help on the armar command
18 Overview of the armasm Legacy Assembler
18.1 Key features of the armasm assembler
18.2 How the assembler works
A Supporting reference information
A.1 Support level definitions
A.2 Standards compliance in Arm® Compiler
A.3 Compliance with the ABI for the Arm® Architecture (Base Standard)
A.4 GCC compatibility provided by Arm® Compiler 6
A.5 Locale support in Arm® Compiler
A.6 Toolchain environment variables
A.7 Clang and LLVM documentation
A.8 Further reading
B Arm® Compiler User Guide Changes
B.1 Changes for the Arm® Compiler User Guide

List of Tables

3-1 armclang common options
3-2 armlink common options
3-3 armar common options
3-4 fromelf common options
3-5 armasm common options
3-6 Source language variants
3-7 Exceptions to the support for the language standards
3-8 Optimization goals
3-9 Example code generation with -O0
3-10 Example code generation with -O1
3-11 armclang linker control options
3-12 Common diagnostic options
3-13 Options for floating-point selection
3-14 Floating-point linkage for AArch32
4-1 C code for nonvolatile and volatile buffer loops
4-2 Disassembly for nonvolatile and volatile buffer loop
4-3 Loop unrolling pragmas
4-4 Loop optimizing example
4-5 Loop examples
4-6 Example loops
4-7 Assembly code from vectorizable and non-vectorizable loops
4-8 C code for incrementing and decrementing loops
4-9 C disassembly for incrementing and decrementing loops
4-10 Function inlining
4-11 Effect of -fno-inline-functions
4-12 Packing members in a structure or union
4-13 Packing structures
4-14 Packing individual members
7-1 Element selection by predicate type svbool_t
7-2 Common addressing mode disambiguators
8-1 Input section properties for placement of .ANY sections
8-2 Input section properties for placement of sections with next_fit
8-3 Input section properties and ordering for sections_a.o and sections_b.o
8-4 Sort order for descending_size algorithm
8-5 Sort order for cmdline algorithm
9-1 Using relative offset in overlays
A-1 Environment variables used by the toolchain
B-1 Changes between 6.16 and 6.15
B-2 Changes between 6.15 and 6.14

Release Information

Document History
Issue Date Confidentiality Change
0606-00 04 November 2016 Non-Confidential Arm Compiler v6.6 Release
0607-00 05 April 2017 Non-Confidential Arm Compiler v6.7 Release
0608-00 30 July 2017 Non-Confidential Arm Compiler v6.8 Release.
0609-00 25 October 2017 Non-Confidential Arm Compiler v6.9 Release.
0610-00 14 March 2018 Non-Confidential Arm Compiler v6.10 Release.
0611-00 25 October 2018 Non-Confidential Arm Compiler v6.11 Release.
0612-00 27 February 2019 Non-Confidential Arm Compiler v6.12 Release.
0613-00 09 October 2019 Non-Confidential Arm Compiler v6.13 Release.
0614-00 26 February 2020 Non-Confidential Arm Compiler v6.14 Release.
0615-00 07 October 2020 Non-Confidential Arm Compiler v6.15 Release.
0615-01 14 December 2020 Non-Confidential Documentation update 1 for Arm Compiler v6.15 Release.
0616-00 03 March 2021 Non-Confidential Arm Compiler v6.16 Release.
0616-01 12 March 2021 Non-Confidential Documentation update 1 for Arm Compiler v6.16 Release.

Non-Confidential Proprietary Notice

This document is protected by copyright and other related rights and the practice or implementation of the information contained in this document may be protected by one or more patents or pending patent applications. No part of this document may be reproduced in any form by any means without the express prior written permission of Arm. No license, express or implied, by estoppel or otherwise to any intellectual property rights is granted by this document unless specifically stated.

Your access to the information in this document is conditional upon your acceptance that you will not use or permit others to use the information for the purposes of determining whether implementations infringe any third party patents.

THIS DOCUMENT IS PROVIDED “AS IS”. ARM PROVIDES NO REPRESENTATIONS AND NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY, NON-INFRINGEMENT OR FITNESS FOR A PARTICULAR PURPOSE WITH RESPECT TO THE DOCUMENT. For the avoidance of doubt, Arm makes no representation with respect to, and has undertaken no analysis to identify or understand the scope and content of, third party patents, copyrights, trade secrets, or other rights.

This document may include technical inaccuracies or typographical errors.


This document consists solely of commercial items. You shall be responsible for ensuring that any use, duplication or disclosure of this document complies fully with any relevant export laws and regulations to assure that this document or any portion thereof is not exported, directly or indirectly, in violation of such export laws. Use of the word “partner” in reference to Arm’s customers is not intended to create or refer to any partnership relationship with any other company. Arm may make changes to this document at any time and without notice.

If any of the provisions contained in these terms conflict with any of the provisions of any click through or signed written agreement covering this document with Arm, then the click through or signed written agreement prevails over and supersedes the conflicting provisions of these terms. This document may be translated into other languages for convenience, and you agree that if there is any conflict between the English version of this document and any translation, the terms of the English version of the Agreement shall prevail.

The Arm corporate logo and words marked with ® or ™ are registered trademarks or trademarks of Arm Limited (or its subsidiaries) in the US and/or elsewhere. All rights reserved. Other brands and names mentioned in this document may be the trademarks of their respective owners. Please follow Arm’s trademark usage guidelines at

Copyright © 2016–2021 Arm Limited (or its affiliates). All rights reserved.

Arm Limited. Company 02557590 registered in England.

110 Fulbourn Road, Cambridge, England CB1 9NJ.


Confidentiality Status

This document is Non-Confidential. The right to use, copy and disclose this document may be subject to license restrictions in accordance with the terms of the agreement entered into by Arm and the party that Arm delivered this document to.

Unrestricted Access is an Arm internal classification.

Product Status

The information in this document is Final, that is for a developed product.

Web Address

Progressive terminology commitment

Arm values inclusive communities. Arm recognizes that we and our industry have used terms that can be offensive. Arm strives to lead the industry and create change.

We believe that this document contains no offensive terms. If you find offensive terms in this document, please contact

Non-ConfidentialPDF file icon PDF version100748_0616_01_en
Copyright © 2016–2021 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.