ARM® Compiler User Guide

Version 6.8

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 Installing ARM® Compiler
1.3 Accessing ARM® Compiler from ARM® DS-5
1.4 Accessing ARM® Compiler from Keil® µVision®
1.5 Compiling a Hello World example
1.6 Using the integrated assembler
1.7 Running bare-metal images
1.8 ARM architectures supported by the toolchain
2 Using Common Compiler Options
2.1 Mandatory armclang options
2.2 Selecting source language options
2.3 Selecting optimization options
2.4 Building to aid debugging
2.5 Linker options for mapping code and data to target memory
2.6 Controlling diagnostic messages
2.7 Selecting floating-point options
2.8 Compilation tools command-line option rules
3 Writing Optimized Code
3.1 Optimizing loops
3.2 Inlining functions
3.3 Examining stack usage
3.4 Packing data structures
4 Using Assembly and Intrinsics in C or C++ Code
4.1 Using intrinsics
4.2 Writing inline assembly code
4.3 Calling assembly functions from C and C++
5 Mapping Code and Data to the Target
5.1 What the linker does to create an image
5.1.1 What you can control with a scatter file
5.2 Placing data items for target peripherals with a scatter file
5.3 Placing the stack and heap with a scatter file
5.4 Root region
5.4.1 Effect of the ABSOLUTE attribute on a root region
5.4.2 Effect of the FIXED attribute on a root region
5.5 Placing functions and data in a named section
5.6 Placing functions and data at specific addresses
5.6.1 Placing __at sections at a specific address
5.6.2 Restrictions on placing __at sections
5.6.3 Automatically placing __at sections
5.6.4 Manually placing __at sections
5.6.5 Placing a key in flash memory with an __at section
5.6.6 Placing constants at fixed locations
5.6.7 Placing jump tables in ROM
5.6.8 Placing a variable at a specific address without scatter-loading
5.6.9 Placing a variable at a specific address with scatter-loading
5.7 Placement of ARM® C and C++ library code
5.7.1 Placing code in a root region
5.7.2 Placing ARM® C library code
5.7.3 Placing ARM® C++ library code
5.8 Placement of unassigned sections
5.8.1 Default rules for placing unassigned sections
5.8.2 Command-line options for controlling the placement of unassigned sections
5.8.3 Prioritizing the placement of unassigned sections
5.8.4 Specify the maximum region size permitted for placing unassigned sections
5.8.5 Examples of using placement algorithms for .ANY sections
5.8.6 Example of next_fit algorithm showing behavior of full regions, selectors, and priority
5.8.7 Examples of using sorting algorithms for .ANY sections
5.8.8 Behavior when .ANY sections overflow because of linker-generated content
5.9 Placing veneers with a scatter file
5.10 Preprocessing a scatter file
5.10.1 Default behavior for armclang -E in a scatter file
5.10.2 Using other preprocessors in a scatter file
5.11 Reserving an empty block of memory
5.11.1 Characteristics of a reserved empty block of memory
5.11.2 Example of reserving an empty block of memory
5.12 Aligning regions to page boundaries
5.13 Aligning execution regions and input sections
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 Toolchain environment variables
A.6 Clang and LLVM documentation
A.7 Further reading

List of Figures

1-1 A typical tool usage flow diagram
1-2 Accessing ARM Compiler settings from DS-5
1-3 Accessing the ARM Compiler version from Keil µVision
1-4 Debug configurations
3-1 Structure without packing attribute or pragma
3-2 Structure with attribute packed
3-3 Structure with pragma pack with 1 byte alignment
3-4 Structure with pragma pack with 2 byte alignment
3-5 Structure with pragma pack with 4 byte alignment
3-6 Structure with attribute packed on individual member
5-1 Memory map for fixed execution regions
5-2 .ANY contingency
5-3 Reserving a region for the stack
A-1 Integration boundaries in ARM Compiler 6.

List of Tables

2-1 Source language variants
2-2 Optimization example
2-3 Optimization example
2-4 Common diagnostic options
2-5 Options for floating-point selection
2-6 Floating-point linkage for AArch32
3-1 Loop unrolling pragmas
3-2 Loop optimizing example
3-3 Loop examples
3-4 Example loops
3-5 Assembly code from vectorizable and non-vectorizable loops
3-6 Function inlining
3-7 Effect of -fno-inline-functions
3-8 Packing members in a structure or union
3-9 Packing structures
3-10 Packing individual members
5-1 Input section properties for placement of .ANY sections
5-2 Input section properties for placement of sections with next_fit
5-3 Input section properties and ordering for sections_a.o and sections_b.o
5-4 Sort order for descending_size algorithm
5-5 Sort order for cmdline algorithm
A-1 Environment variables used by the toolchain

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.

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 signed written agreement covering this document with ARM, then the 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.

Words and logos marked with ® or ™ are registered trademarks or trademarks of ARM Limited or its affiliates in the EU 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, 2017, 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

Non-ConfidentialPDF file icon PDF versionARM 100748_0608_00_en
Copyright © 2016, 2017 ARM Limited or its affiliates. All rights reserved.