Procedure Call Standard for the ARM Architecture
Procedure Call Standard for the
ARM® Architecture
ARM IHI 0042D, current through ABI release 2.08
16th October, 2009
Document number:
Date of Issue:
Abstract
This document describes the Procedure Call Standard use by the Application Binary Interface (ABI) for the
ARM architecture.
Keywords
Procedure call function call, calling conventions, data layout
How to find the latest release of this specification or report a defect in it
Please check the ARM Information Center (http://infocenter.arm.com/) for a later release if your copy is more than one year old
(navigate to the Software Development Tools section, Application Binary Interface for the ARM Architecture subsection).
Please report defects in this specification to arm dot eabi at arm dot com.
Licence
THE TERMS OF YOUR ROYALTY FREE LIMITED LICENCE TO USE THIS ABI SPECIFICATION ARE GIVEN IN SECTION
1.4, Your licence to use this specification (ARM contract reference LEC-ELA-00081 V2.0). PLEASE READ THEM
CAREFULLY.
BY DOWNLOADING OR OTHERWISE USING THIS SPECIFICATION, YOU AGREE TO BE BOUND BY ALL OF ITS
TERMS. IF YOU DO NOT AGREE TO THIS, DO NOT DOWNLOAD OR USE THIS SPECIFICATION.
THIS ABI SPECIFICATION IS PROVIDED “AS IS” WITH NO WARRANTIES (SEE SECTION 1.4 FOR DETAILS).
Proprietary notice
ARM, Thumb, RealView, ARM7TDMI and ARM9TDMI are registered trademarks of ARM Limited. The ARM logo
is a trademark of ARM Limited. ARM9, ARM926EJ-S, ARM946E-S, ARM1136J-S ARM1156T2F-S ARM1176JZ-S
Cortex, and Neon are trademarks of ARM Limited. All other products or services mentioned herein may be
trademarks of their respective owners.
ARM IHI 0042D
Copyright © 2003-2009 ARM Limited. All rights reserved.
Page 1 of 34
Procedure Call Standard for the ARM Architecture
Contents
1 ABOUT THIS DOCUMENT
1.1
Change Control
1.1.1 Current Status and Anticipated Changes
1.1.2 Change History
1.2
1.3
1.4
1.5
References
Terms and Abbreviations
Your Licence to Use This Specification
Acknowledgements
2 SCOPE
3
3.1
3.2
INTRODUCTION
Design Goals
Conformance
4 DATA TYPES AND ALIGNMENT
4.1
Fundamental Data Types
4.1.1 Half-precision Floating Point
4.1.2 Containerized Vectors
Endianness and Byte Ordering
Composite Types
Aggregates
4.3.1
4.3.2 Unions
4.3.3
Arrays
4.3.4
Bit-fields
4.3.5 Homogeneous Aggregates
4.2
4.3
5
5.1
THE BASE PROCEDURE CALL STANDARD
Machine Registers
5.1.1 Core registers
5.1.2 Co-processor Registers
5.1.1.1
5.1.2.1
Handling values larger than 32 bits
5.2
Processes, Memory and the Stack
5.2.1
5.2.1.1
The Stack
Universal stack constraints
VFP register usage conventions (VFP v2, v3 and the Advanced SIMD Extension)
5
5
5
5
6
6
7
8
9
10
10
10
11
11
11
12
12
13
13
13
13
13
14
15
15
15
16
16
17
17
18
18
ARM IHI 0042D
Copyright © 2003-2009 ARM Limited. All rights reserved.
Page 2 of 34
Procedure Call Standard for the ARM Architecture
5.2.1.2
Stack constraints at a public interface
Subroutine Calls
5.3.1.1
Use of IP by the linker
Result Return
Parameter Passing
Interworking
THE STANDARD VARIANTS
VFP and Advanced SIMD Register Arguments
6.1.1 Mapping between registers and memory format
6.1.2
Procedure Calling
6.1.2.1
6.1.2.2
6.1.2.3
VFP co-processor register candidates
Result return
Parameter passing
Alternative Format Half-precision Floating Point values
Read-Write Position Independence (RWPI)
5.3
5.4
5.5
5.6
6
6.1
6.2
6.3
6.4
18
18
19
19
19
21
23
23
23
23
23
23
24
24
24
24
24
25
25
25
26
26
26
27
27
28
28
29
29
29
30
30
31
31
31
33
33
Variant Compatibility
6.4.1
VFP and Base Standard Compatibility
6.4.2 RWPI and Base Standard Compatibility
6.4.3
VFP and RWPI Standard Compatibility
6.4.4 Half-precision Format Compatibility
7 ARM C AND C++ LANGUAGE MAPPINGS
7.1
Data Types
7.1.1
7.1.2
7.1.3
7.1.4
7.1.5
7.1.6
7.1.7
Arithmetic Types
Pointer Types
Enumerated Types
Additional Types
Volatile Data Types
Structure, Union and Class Layout
Bit-fields
Bit-fields no larger than their container
Bit-field extraction expressions
7.1.7.1
7.1.7.2
7.1.7.3 Over-sized bit-fields
7.1.7.4
7.1.7.5
Combining bit-field and non-bit-field members
Volatile bit-fields⎯preserving number and width of container accesses
7.2
Argument Passing Conventions
APPENDIX A
A.1
Introduction
SUPPORT FOR ADVANCED SIMD EXTENSIONS
ARM IHI 0042D
Copyright © 2003-2009 ARM Limited. All rights reserved.
Page 3 of 34
A.2
Advanced SIMD data types
A.2.1 C++ Mangling
Procedure Call Standard for the ARM Architecture
33
34
ARM IHI 0042D
Copyright © 2003-2009 ARM Limited. All rights reserved.
Page 4 of 34
Procedure Call Standard for the ARM Architecture
1 ABOUT THIS DOCUMENT
1.1 Change Control
1.1.1 Current Status and Anticipated Changes
This document has been released publicly. Anticipated changes to this document include:
Typographical corrections.
Clarifications.
Compatible extensions.
1.1.2 Change History
Issue
1.0
2.0
2.01
Date
30th October 2003
24th March 2005
5th July 2005
4th August 2005
7th October 2005
4th May 2006
19th January 2007
2nd October 2007
25th October 2007
2nd April 2008
10th October 2008
16th October 2009
2.02
2.03
2.04
2.05
2.06
A
B
C
D
By Change
LS First public release.
LS Second public release.
LS Added clarifying remark following Error! Reference source not
found. – word-sized enumeration contains are int if possible.
RE Clarify that a callee may modify stack space used for incoming
parameters.
LS Added notes concerning VFPv3 D16-D31 (§5.1.2.1); retracted
requirement that plain bit-fields be unsigned by default (§7.1.7)
RE Clarified when linking may insert veneers that corrupt r12 and the
condition codes (§5.3.1.1).
RE Update for the Advanced SIMD Extension.
RE Add support for half-precision floating point.
LS Document renumbered (formerly GENC-003534 v2.06).
RE Simplify duplicated text relating to VFP calling and clarify that
homogeneous aggregates of containerized vectors are limited to four
members in calling convention (§6.1.2.1).
RE Clarify that __va_list is in namespace std. Specify containers for
oversized enums. State truth values for _Bool/bool. Clarify some
wording with respect to homogeneous aggregates and argument
marshalling of VFP CPRCs
LS Re-wrote §7.1.3 to better reflect the intentions for enumerated types
in ABI-complying interfaces.
ARM IHI 0042D
Copyright © 2003-2009 ARM Limited. All rights reserved.
Page 5 of 34
URL or other reference
This document
1.2 References
This document refers to, or is referred to by, the following documents.
Ref
AAPCS
AAELF
BSABI
CPPABI
ARM ARM
ARM DDI 0100E, ISBN 0 201 737191
(Also from http://infocenter.arm.com/help/index.jsp
as the ARMv5 Architecture Reference Manual)
ARM DDI 0406
(Subject to licence terms; please apply to ARM)
GC++ABI
http://www.codesourcery.com/cxx-abi/abi.html
Procedure Call Standard for the ARM Architecture
Title
Procedure Call Standard for the ARM Architecture
ELF for the ARM Architecture
ABI for the ARM Architecture (Base Standard)
C++ ABI for the ARM Architecture
The ARM Architecture Reference Manual, 2nd
edition, edited by David Seal, published by
Addison-Wesley.
ARM Architecture Reference Manual ARM v7-A
and ARM v7-R edition
Generic C++ ABI
1.3 Terms and Abbreviations
This document uses the following terms and abbreviations.
Term
ABI
Meaning
Application Binary Interface:
1. The specifications to which an executable must conform in order to execute in a
specific execution environment. For example, the Linux ABI for the ARM Architecture.
2. A particular aspect of the specifications to which independently produced relocatable
files must conform in order to be statically linkable and executable. For example, the
C++ ABI for the ARM Architecture, the Run-time ABI for the ARM Architecture, the C
Library ABI for the ARM Architecture.
ARM-based … based on the ARM architecture …
EABI An ABI suited to the needs of embedded (sometimes called free standing) applications.
PCS
Procedure Call Standard.
AAPCS Procedure Call Standard for the ARM Architecture (this standard).
APCS ARM Procedure Call Standard (obsolete).
TPCS Thumb Procedure Call Standard (obsolete).
ATPCS ARM-Thumb Procedure Call Standard (precursor to this standard).
PIC, PID Position-independent code, position-independent data.
ARM IHI 0042D
Copyright © 2003-2009 ARM Limited. All rights reserved.
Page 6 of 34
Procedure Call Standard for the ARM Architecture
Routine,
subroutine
A fragment of program to which control can be transferred that, on completing its task,
returns control to its caller at an instruction following the call. Routine is used for clarity
where there are nested calls: a routine is the caller and a subroutine is the callee.
Procedure A routine that returns no result value.
Function A routine that returns a result value.
Activation stack,
call-frame stack
Activation record,
call frame
The stack of routine activation records (call frames).
The memory used by a routine for saving registers and holding local variables (usually
allocated on a stack, once per activation of the routine).
Term Meaning
Argument,
Parameter
Externally visible
[interface]
The terms argument and parameter are used interchangeably. They may denote a formal
parameter of a routine given the value of the actual parameter when the routine is called,
or an actual parameter, according to context.
[An interface] between separately compiled or separately assembled routines.
Variadic routine A routine is variadic if the number of arguments it takes, and their type, is determined by
the caller instead of the callee.
Global register
Program state
Scratch register,
temporary register
Variable register,
v-register
A register whose value is neither saved nor destroyed by a subroutine. The value may be
updated, but only in a manner defined by the execution environment.
The state of the program’s memory, including values in machine registers.
A register used to hold an intermediate value during a calculation (usually, such values
are not named in the program source and have a limited lifetime).
A register used to hold the value of a variable, usually one local to a routine, and often
named in the source code.
More specific terminology is defined when it is first used.
1.4 Your Licence to Use This Specification
IMPORTANT: THIS IS A LEGAL AGREEMENT (“LICENCE”) BETWEEN YOU (AN INDIVIDUAL OR SINGLE ENTITY WHO IS
RECEIVING THIS DOCUMENT DIRECTLY FROM ARM LIMITED) (“LICENSEE”) AND ARM LIMITED (“ARM”) FOR THE
SPECIFICATION DEFINED IMMEDITATELY BELOW. BY DOWNLOADING OR OTHERWISE USING IT, YOU AGREE TO
BE BOUND BY ALL OF THE TERMS OF THIS LICENCE. IF YOU DO NOT AGREE TO THIS, DO NOT DOWNLOAD OR
USE THIS SPECIFICATION.
“Specification” means, and is limited to, the version of the specification for the Applications Binary Interface for the
ARM Architecture comprised in this document. Notwithstanding the foregoing, “Specification” shall not include (i)
the implementation of other published specifications referenced in this Specification; (ii) any enabling technologies
that may be necessary to make or use any product or portion thereof that complies with this Specification, but are
not themselves expressly set forth in this Specification (e.g. compiler front ends, code generators, back ends,
libraries or other compiler, assembler or linker technologies; validation or debug software or hardware;
applications, operating system or driver software; RISC architecture; processor microarchitecture); (iii) maskworks
ARM IHI 0042D
Copyright © 2003-2009 ARM Limited. All rights reserved.
Page 7 of 34
Procedure Call Standard for the ARM Architecture
and physical layouts of integrated circuit designs; or (iv) RTL or other high level representations of integrated
circuit designs.
Use, copying or disclosure by the US Government is subject to the restrictions set out in subparagraph (c)(1)(ii) of
the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 or subparagraphs (c)(1) and
(2) of the Commercial Computer Software – Restricted Rights at 48 C.F.R. 52.227-19, as applicable.
This Specification is owned by ARM or its licensors and is protected by copyright laws and international copyright
treaties as well as other intellectual property laws and treaties. The Specification is licensed not sold.
1.
Subject to the provisions of Clauses 2 and 3, ARM hereby grants to LICENSEE, under any intellectual
property that is (i) owned or freely licensable by ARM without payment to unaffiliated third parties and (ii)
either embodied in the Specification or Necessary to copy or implement an applications binary interface
compliant with this Specification, a perpetual, non-exclusive, non-transferable, fully paid, worldwide limited
licence (without the right to sublicense) to use and copy this Specification solely for the purpose of
developing, having developed, manufacturing, having manufactured, offering to sell, selling, supplying or
otherwise distributing products which comply with the Specification.
2.
3.
THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO WARRANTIES EXPRESS, IMPLIED OR STATUTORY,
INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF SATISFACTORY QUALITY, MERCHANTABILITY,
NONINFRINGEMENT OR FITNESS FOR A PARTICULAR PURPOSE. THE SPECIFICATION MAY INCLUDE
ERRORS. ARM RESERVES THE RIGHT TO INCORPORATE MODIFICATIONS TO THE SPECIFICATION IN
LATER REVISIONS OF IT, AND TO MAKE IMPROVEMENTS OR CHANGES IN THE SPECIFICATION OR THE
PRODUCTS OR TECHNOLOGIES DESCRIBED THEREIN AT ANY TIME.
This Licence shall immediately terminate and shall be unavailable to LICENSEE if LICENSEE or any party
affiliated to LICENSEE asserts any patents against ARM, ARM affiliates, third parties who have a valid
licence from ARM for the Specification, or any customers or distributors of any of them based upon a
claim that a LICENSEE (or LICENSEE affiliate) patent is Necessary to implement the Specification. In this
Licence; (i) “affiliate” means any entity controlling, controlled by or under common control with a party (in
fact or in law, via voting securities, management control or otherwise) and “affiliated” shall be construed
accordingly; (ii) “assert” means to allege infringement in legal or administrative proceedings, or
proceedings before any other competent trade, arbitral or international authority; (iii) “Necessary” means
with respect to any claims of any patent, those claims which, without the appropriate permission of the
patent owner, will be infringed when implementing the Specification because no alternative, commercially
reasonable, non-infringing way of implementing the Specification is known; and (iv) English law and the
jurisdiction of the English courts shall apply to all aspects of this Licence, its interpretation and
enforcement. The total liability of ARM and any of its suppliers and licensors under or in relation to this
Licence shall be limited to the greater of the amount actually paid by LICENSEE for the Specification or
US$10.00. The limitations, exclusions and disclaimers in this Licence shall apply to the maximum extent
allowed by applicable law.
ARM Contract reference LEC-ELA-00081 V2.0 AB/LS (9 March 2005)
1.5 Acknowledgements
This specification has been developed with the active support of the following organizations. In alphabetical order:
ARM, CodeSourcery, Intel, Metrowerks, Montavista, Nexus Electronics, PalmSource, Symbian, Texas
Instruments, and Wind River.
ARM IHI 0042D
Copyright © 2003-2009 ARM Limited. All rights reserved.
Page 8 of 34