Mercurial > pub > dyncall > dyncall
annotate doc/manual/callconvs/callconv_arm32.tex @ 328:276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
author | Tassilo Philipp |
---|---|
date | Fri, 22 Nov 2019 23:11:56 +0100 |
parents | 703d102cb580 |
children | 06c9adae114d |
rev | line source |
---|---|
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
1 %////////////////////////////////////////////////////////////////////////////// |
0 | 2 % |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
3 % Copyright (c) 2007-2019 Daniel Adler <dadler@uni-goettingen.de>, |
0 | 4 % Tassilo Philipp <tphilipp@potion-studios.com> |
5 % | |
6 % Permission to use, copy, modify, and distribute this software for any | |
7 % purpose with or without fee is hereby granted, provided that the above | |
8 % copyright notice and this permission notice appear in all copies. | |
9 % | |
10 % THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 % WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 % MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 % ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 % WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 % ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 % OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 % | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
18 %////////////////////////////////////////////////////////////////////////////// |
0 | 19 |
20 % ================================================== | |
21 % ARM32 | |
22 % ================================================== | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
23 \subsection{ARM32 Calling Conventions} |
0 | 24 |
25 \paragraph{Overview} | |
26 | |
117 | 27 The ARM32 family of processors is based on the Advanced RISC Machines (ARM) |
28 processor architecture (32 bit RISC). | |
0 | 29 The word size is 32 bits (and the programming model is LLP64).\\ |
30 Basically, this family of microprocessors can be run in 2 major modes:\\ | |
31 \\ | |
77 | 32 \begin{tabular*}{0.95\textwidth}{2 B} |
0 | 33 Mode & Description\\ |
34 \hline | |
35 {\bf ARM} & 32bit instruction set\\ | |
36 {\bf THUMB} & compressed instruction set using 16bit wide instruction encoding\\ | |
76 | 37 \end{tabular*} |
0 | 38 \\ |
39 \\ | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
40 For more details, take a look at the ARM-THUMB Procedure Call Standard (ATPCS) |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
41 \cite{ATPCS}, the Procedure Call Standard for the ARM Architecture (AAPCS) |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
42 \cite{AAPCS}, as well as Debian's ARM EABI port \cite{armeabi} and hard-float |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
43 \cite{armhf} wiki pages.\\ \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
44 |
0 | 45 \paragraph{\product{dyncall} support} |
46 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
47 Currently, the \product{dyncall} library supports the ARM and THUMB mode of the |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
48 ARM32 family (ATPCS \cite{ATPCS}, EABI \cite{armeabi}, the ARM hard-float |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
49 (armhf) \cite{armeabi} varian, as well as Apple's calling convention based on |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
50 the ATPCS), excluding manually triggered ARM-THUMB interworking calls.\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
51 Also supported is armhf, a calling convention with register support to pass |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
52 floating point numbers. FPA and the VFP (scalar mode) procedure call standards, |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
53 as well as some instruction sets accelerating DSP and multimedia application |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
54 like the ARM Jazelle Technology (direct Java bytecode execution, providing |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
55 acceleration for some bytecodes while calling software code for others), etc., |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
56 are not supported by the dyncall library.\\ |
0 | 57 |
58 | |
59 \subsubsection{ATPCS ARM mode} | |
60 | |
61 | |
62 \paragraph{Registers and register usage} | |
63 | |
64 In ARM mode, the ARM32 processor has sixteen 32 bit general purpose registers, namely r0-r15:\\ | |
65 \\ | |
66 \begin{table}[h] | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
67 \begin{tabular*}{0.95\textwidth}{lll} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
68 Name & Alias & Brief description\\ |
0 | 69 \hline |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
70 {\bf r0} & {\bf a1} & parameter 0, scratch, return value\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
71 {\bf r1} & {\bf a2} & parameter 1, scratch, return value\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
72 {\bf r2,r3} & {\bf a3,a4} & parameters 2 and 3, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
73 {\bf r4-r9} & {\bf v1-v6} & permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
74 {\bf r10} & {\bf sl} & permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
75 {\bf r11} & {\bf fp} & frame pointer, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
76 {\bf r12} & {\bf ip} & scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
77 {\bf r13} & {\bf sp} & stack pointer, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
78 {\bf r14} & {\bf lr} & link register, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
79 {\bf r15} & {\bf pc} & program counter (note: due to pipeline, r15 points to 2 instructions ahead)\\ |
76 | 80 \end{tabular*} |
0 | 81 \caption{Register usage on arm32} |
82 \end{table} | |
83 | |
84 \paragraph{Parameter passing} | |
85 | |
86 \begin{itemize} | |
87 \item stack parameter order: right-to-left | |
88 \item caller cleans up the stack | |
89 \item first four words are passed using r0-r3 | |
90 \item subsequent parameters are pushed onto the stack (in right to left order, such that the stack pointer points to the first of the remaining parameters) | |
91 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words to a reserved stack area adjacent to the other parameters on the stack | |
92 \item parameters \textless=\ 32 bits are passed as 32 bit words | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
93 \item 64 bit parameters are passed as two 32 bit parts (even partly via the register and partly via the stack, although this doesn't seem to be specified in the ATPCS) |
0 | 94 \item structures and unions are passed by value, with the first four words of the parameters in r0-r3 |
95 \item if return value is a structure, a pointer pointing to the return value's space is passed in r0, the first parameter in r1, etc... (see {\bf return values}) | |
96 \item keeping the stack eight-byte aligned can improve memory access performance and is required by LDRD and STRD on ARMv5TE processors which are part of the ARM32 family, so, in order to avoid problems one should always align the stack (tests have shown, that GCC does care about the alignment when using the ellipsis) | |
97 \end{itemize} | |
98 | |
99 \paragraph{Return values} | |
100 \begin{itemize} | |
101 \item return values \textless=\ 32 bits use r0 | |
102 \item 64 bit return values use r0 and r1 | |
103 \item if return value is a structure, the caller allocates space for the return value on the stack in its frame and passes a pointer to it in r0 | |
104 \end{itemize} | |
105 | |
106 \paragraph{Stack layout} | |
107 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
108 % verified/amended: TP nov 2019 (see also doc/disas_examples/arm.atpcs_arm.disas) |
0 | 109 Stack directly after function prolog:\\ |
110 | |
111 \begin{figure}[h] | |
112 \begin{tabular}{5|3|1 1} | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
113 & \vdots & & \\ |
0 | 114 \hhline{~=~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
115 register save area & \hspace{4cm} & & \mrrbrace{5}{caller's frame} \\ |
0 | 116 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
117 local data & & & \\ |
117 | 118 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
119 \mrlbrace{7}{parameter area} & last arg & \mrrbrace{3}{stack parameters} & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
120 & \ldots & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
121 & 5th word of arg data & & \\ |
117 | 122 \hhline{~=~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
123 & r3 & \mrrbrace{4}{spill area (if needed)} & \mrrbrace{7}{current frame} \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
124 & r2 & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
125 & r1 & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
126 & r0 & & \\ |
117 | 127 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
128 register save area (with return address) & & & \\ %fp points here to 1st word of this area: $\leftarrow$ fp |
117 | 129 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
130 local data & & & \\ |
117 | 131 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
132 parameter area & \vdots & & \\ |
0 | 133 \end{tabular} |
134 \caption{Stack layout on arm32} | |
135 \end{figure} | |
136 | |
137 | |
138 \newpage | |
139 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
140 |
0 | 141 \subsubsection{ATPCS THUMB mode} |
142 | |
143 | |
144 \paragraph{Status} | |
145 | |
146 \begin{itemize} | |
147 \item The ATPCS THUMB mode is untested. | |
148 \item Ellipse calls may not work. | |
149 \item C++ this calls do not work. | |
150 \end{itemize} | |
151 | |
152 \paragraph{Registers and register usage} | |
153 | |
154 In THUMB mode, the ARM32 processor family supports eight 32 bit general purpose registers r0-r7 and access to high order registers r8-r15:\\ | |
155 \\ | |
156 \begin{table}[h] | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
157 \begin{tabular*}{0.95\textwidth}{lll} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
158 Name & Alias & Brief description\\ |
0 | 159 \hline |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
160 {\bf r0} & {\bf a1} & parameter 0, scratch, return value\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
161 {\bf r1} & {\bf a2} & parameter 1, scratch, return value\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
162 {\bf r2,r3} & {\bf a3,a4} & parameters 2 and 3, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
163 {\bf r4-r6} & {\bf v1-v3} & permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
164 {\bf r7} & {\bf v4} & frame pointer, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
165 {\bf r8-r11} & {\bf v5-v8} & permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
166 {\bf r12} & {\bf ip} & scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
167 {\bf r13} & {\bf sp} & stack pointer, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
168 {\bf r14} & {\bf lr} & link register, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
169 {\bf r15} & {\bf pc} & program counter (note: due to pipeline, r15 points to 2 instructions ahead)\\ |
76 | 170 \end{tabular*} |
0 | 171 \caption{Register usage on arm32 thumb mode} |
172 \end{table} | |
173 | |
174 \paragraph{Parameter passing} | |
175 | |
176 \begin{itemize} | |
177 \item stack parameter order: right-to-left | |
178 \item caller cleans up the stack | |
179 \item first four words are passed using r0-r3 | |
180 \item subsequent parameters are pushed onto the stack (in right to left order, such that the stack pointer points to the first of the remaining parameters) | |
181 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words to a reserved stack area adjacent to the other parameters on the stack | |
182 \item parameters \textless=\ 32 bits are passed as 32 bit words | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
183 \item 64 bit parameters are passed as two 32 bit parts (even partly via the register and partly via the stack), although this doesn't seem to be specified in the ATPCS) |
0 | 184 \item structures and unions are passed by value, with the first four words of the parameters in r0-r3 |
185 \item if return value is a structure, a pointer pointing to the return value's space is passed in r0, the first parameter in r1, etc. (see {\bf return values}) | |
186 \item keeping the stack eight-byte aligned can improve memory access performance and is required by LDRD and STRD on ARMv5TE processors which are part of the ARM32 family, so, in order to avoid problems one should always align the stack (tests have shown, that GCC does care about the alignment when using the ellipsis) | |
187 \end{itemize} | |
188 | |
189 \paragraph{Return values} | |
190 \begin{itemize} | |
191 \item return values \textless=\ 32 bits use r0 | |
192 \item 64 bit return values use r0 and r1 | |
193 \item if return value is a structure, the caller allocates space for the return value on the stack in its frame and passes a pointer to it in r0 | |
194 \end{itemize} | |
195 | |
196 \paragraph{Stack layout} | |
197 | |
198 Stack directly after function prolog:\\ | |
199 | |
200 \begin{figure}[h] | |
201 \begin{tabular}{5|3|1 1} | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
202 & \vdots & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
203 \hhline{~=~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
204 register save area & \hspace{4cm} & & \mrrbrace{5}{caller's frame} \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
205 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
206 local data & & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
207 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
208 \mrlbrace{7}{parameter area} & last arg & \mrrbrace{3}{stack parameters} & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
209 & \ldots & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
210 & 5th word of arg data & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
211 \hhline{~=~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
212 & r3 & \mrrbrace{4}{spill area (if needed)} & \mrrbrace{7}{current frame} \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
213 & r2 & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
214 & r1 & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
215 & r0 & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
216 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
217 register save area (with return address) & & & \\ %fp points here to 1st word of this area: $\leftarrow$ fp |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
218 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
219 local data & & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
220 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
221 parameter area & \vdots & & \\ |
0 | 222 \end{tabular} |
223 \caption{Stack layout on arm32 thumb mode} | |
224 \end{figure} | |
225 | |
226 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
227 \newpage |
0 | 228 |
229 | |
230 \subsubsection{EABI (ARM and THUMB mode)} | |
231 | |
232 | |
233 The ARM EABI is very similar to the ABI outlined in ARM-THUMB procedure call | |
234 standard (ATPCS) \cite{ATPCS} - however, the EABI requires the stack to be | |
41 | 235 8-byte aligned at function entries, as well as for 64 bit parameters. The latter |
236 are aligned on 8-byte boundaries on the stack and 2-registers for a parameter | |
0 | 237 passed via register. In order to achieve such an alignment, a register might |
238 have to be skipped for parameters passed via registers, or 4-bytes on the stack | |
35 | 239 for parameters passed via the stack. Refer to the Debian ARM EABI port wiki |
173 | 240 for more information \cite{armeabi}.\\ |
241 \\ | |
0 | 242 \paragraph{Status} |
243 | |
244 \begin{itemize} | |
245 \item The EABI THUMB mode is tested and works fine (contrary to the ATPCS). | |
246 \item Ellipse calls do not work. | |
247 \item C++ this calls do not work. | |
248 \end{itemize} | |
249 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
250 |
0 | 251 \newpage |
252 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
253 |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
254 \subsubsection{ARM on Apple's iOS (Darwin) Platform (ARM and THUMB mode)} |
0 | 255 |
256 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
257 The iOS runs on ARMv6 (iOS 2.0) and ARMv7 (iOS 3.0) architectures. Both, ARM and THUMB are available, |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
258 code is usually compiled in THUMB mode.\\ |
173 | 259 \\ |
0 | 260 \paragraph{Register usage} |
261 | |
262 \begin{table}[h] | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
263 \begin{tabular*}{0.95\textwidth}{lll} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
264 Name & Alias & Brief description\\ |
0 | 265 \hline |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
266 {\bf r0} & & parameter 0, scratch, return value\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
267 {\bf r1} & & parameter 1, scratch, return value\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
268 {\bf r2,r3} & & parameters 2 and 3, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
269 {\bf r4-r6} & & permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
270 {\bf r7} & & frame pointer, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
271 {\bf r8} & & permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
272 {\bf r9} & & permanent (iOS 2.0) / scratch (since iOS 3.0)\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
273 {\bf r10-r11}& & permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
274 {\bf r12} & & scratch, intra-procedure scratch register (IP) used by dynamic linker\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
275 {\bf r13} & {\bf sp} & stack pointer, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
276 {\bf r14} & {\bf lr} & link register, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
277 {\bf r15} & {\bf pc} & program counter (note: due to pipeline, r15 points to 2 instructions ahead)\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
278 {\bf cpsr} & & program status register\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
279 {\bf d0-d7} & & scratch, aliases s0-s15, on ARMv7 also as q0-q3; not accessible from Thumb mode on ARMv6\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
280 {\bf d8-d15} & & permanent, aliases s16-s31, on ARMv7 also as q4-q7; not accesible from Thumb mode on ARMv6\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
281 {\bf d16-d31}& & only available in ARMv7, aliases q8-q15\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
282 {\bf fpscr} & & VFP status register\\ |
76 | 283 \end{tabular*} |
0 | 284 \caption{Register usage on ARM Apple iOS} |
285 \end{table} | |
286 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
287 \paragraph{Parameter passing and Return values} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
288 |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
289 The ABI is based on the AAPCS but with the following important differences: |
0 | 290 |
291 \begin{itemize} | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
292 \item in ARM mode, r7 is used as frame pointer instead of r11 (so both, ARM and THUMB mode use the same convention) |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
293 \item r9 does not need to be preserved on iOS 3.0 and greater |
0 | 294 \end{itemize} |
295 | |
34 | 296 |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
297 \paragraph{Stack layout} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
298 |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
299 % verified/amended: TP nov 2019 (see also doc/disas_examples/arm.darwin_{arm,thumb}.disas) |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
300 Stack directly after function prolog:\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
301 |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
302 \begin{figure}[h] |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
303 \begin{tabular}{5|3|1 1} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
304 & \vdots & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
305 \hhline{~=~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
306 register save area & \hspace{4cm} & & \mrrbrace{5}{caller's frame} \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
307 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
308 local data & & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
309 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
310 \mrlbrace{7}{parameter area} & last arg & \mrrbrace{3}{stack parameters} & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
311 & \ldots & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
312 & 5th word of arg data @@@verify & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
313 \hhline{~=~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
314 & r3 & \mrrbrace{4}{spill area (if needed)} & \mrrbrace{7}{current frame} \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
315 & r2 & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
316 & r1 & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
317 & r0 & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
318 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
319 register save area (with return address) & & & \\ %fp points here to 1st word of this area: $\leftarrow$ fp |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
320 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
321 local data & & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
322 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
323 parameter area & \vdots & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
324 \end{tabular} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
325 \caption{Stack layout on arm32} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
326 \end{figure} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
327 |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
328 |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
329 \newpage |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
330 |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
331 |
34 | 332 \subsubsection{ARM hard float (armhf)} |
333 | |
334 | |
35 | 335 Most debian-based Linux systems on ARMv7 (or ARMv6 with FPU) platforms use a calling convention referred to |
41 | 336 as armhf, using 16 32-bit floating point registers of the FPU of the VFPv3-D16 extension to the ARM architecture. |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
337 Refer to the debian wiki for more information \cite{armhf}. % The following is for ARM mode, find platform that uses thumb+hard-float @@@ |
35 | 338 |
173 | 339 Code is little-endian, rest is similar to EABI with an 8-byte aligned stack, etc..\\ |
340 \\ | |
34 | 341 \paragraph{Register usage} |
342 | |
343 \begin{table}[h] | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
344 \begin{tabular*}{0.95\textwidth}{lll} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
345 Name & Alias & Brief description\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
346 \hline |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
347 {\bf r0} & {\bf a1} & parameter 0, scratch, non floating point return value\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
348 {\bf r1} & {\bf a2} & parameter 1, scratch, non floating point return value\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
349 {\bf r2,r3} & {\bf a3,a4} & parameters 2 and 3, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
350 {\bf r4-r9} & {\bf v1-v6} & permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
351 {\bf r10} & {\bf sl} & permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
352 {\bf r11} & {\bf fp} & frame pointer, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
353 {\bf r12} & {\bf ip} & scratch, intra-procedure scratch register (IP) used by dynamic linker\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
354 {\bf r13} & {\bf sp} & stack pointer, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
355 {\bf r14} & {\bf lr} & link register, permanent\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
356 {\bf r15} & {\bf pc} & program counter (note: due to pipeline, r15 points to 2 instructions ahead)\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
357 {\bf cpsr} & & program status register\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
358 {\bf s0} & & floating point argument, floating point return value, single precision\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
359 {\bf d0} & & floating point argument, floating point return value, double precision, aliases s0-s1\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
360 {\bf s1-s15} & & floating point arguments, single precision\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
361 {\bf d1-d7} & & aliases s2-s15, floating point arguments, double precision\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
362 {\bf fpscr} & & VFP status register\\ |
76 | 363 \end{tabular*} |
34 | 364 \caption{Register usage on armhf} |
365 \end{table} | |
366 | |
35 | 367 \paragraph{Parameter passing} |
368 | |
369 \begin{itemize} | |
370 \item stack parameter order: right-to-left | |
371 \item caller cleans up the stack | |
372 \item first four non-floating-point words are passed using r0-r3 | |
51 | 373 \item out of those, 64bit parameters use 2 registers, either r0,r1 or r2,r3 (skipped registers are left unused) |
41 | 374 \item first 16 single-precision, or 8 double-precision arguments are passed via s0-s15 or d0-d7, respectively (note that since s and d registers are aliased, already used ones are skipped) |
35 | 375 \item subsequent parameters are pushed onto the stack (in right to left order, such that the stack pointer points to the first of the remaining parameters) |
47 | 376 \item note that as soon one floating point parameter is passed via the stack, subsequent single precision floating point parameters are also pushed onto the stack even if there are still free S* registers |
51 | 377 \item float and double vararg function parameters (no matter if in ellipsis part of function, or not) are passed like int or long long parameters, vfp registers aren't used |
50 | 378 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words (for first 4 integer arguments) to a reserved stack area adjacent to the other parameters on the stack |
35 | 379 \item parameters \textless=\ 32 bits are passed as 32 bit words |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
380 \item structures and unions are passed by value, with the first four words of the parameters in r0-r3 |
35 | 381 \item if return value is a structure, a pointer pointing to the return value's space is passed in r0, the first parameter in r1, etc. (see {\bf return values}) |
148
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
382 \item callee spills, caller reserves spill area space, though |
35 | 383 \end{itemize} |
384 | |
385 \paragraph{Return values} | |
386 \begin{itemize} | |
42
ecc9403e214a
- final touch for complete armhf callback support, yay
cslag
parents:
41
diff
changeset
|
387 \item non floating point return values \textless=\ 32 bits use r0 |
ecc9403e214a
- final touch for complete armhf callback support, yay
cslag
parents:
41
diff
changeset
|
388 \item non floating point 64-bit return values use r0 and r1 |
ecc9403e214a
- final touch for complete armhf callback support, yay
cslag
parents:
41
diff
changeset
|
389 \item single precision floating point return value uses s0 |
ecc9403e214a
- final touch for complete armhf callback support, yay
cslag
parents:
41
diff
changeset
|
390 \item double precision floating point return value uses d0 |
35 | 391 \item if return value is a structure, the caller allocates space for the return value on the stack in its frame and passes a pointer to it in r0 |
392 \end{itemize} | |
393 | |
148
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
394 \paragraph{Stack layout} |
35 | 395 |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
396 % verified/amended: TP nov 2019 (see also doc/disas_examples/arm.armhf.disas) |
148
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
397 Stack directly after function prolog:\\ |
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
398 |
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
399 \begin{figure}[h] |
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
400 \begin{tabular}{5|3|1 1} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
401 & \vdots & & \\ |
148
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
402 \hhline{~=~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
403 register save area & \hspace{4cm} & & \mrrbrace{5}{caller's frame} \\ |
148
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
404 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
405 local data & & & \\ |
148
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
406 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
407 \mrlbrace{7}{parameter area} & last arg & \mrrbrace{3}{stack parameters} & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
408 & \ldots & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
409 & first arg passed via stack & & \\ |
148
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
410 \hhline{~=~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
411 & r3 & \mrrbrace{4}{spill area (if needed)} & \mrrbrace{7}{current frame} \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
412 & r2 & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
413 & r1 & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
414 & r0 & & \\ |
148
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
415 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
416 register save area (with return address) & & & \\ %fp points here to 1st word of this area: $\leftarrow$ fp |
148
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
417 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
418 local data & & & \\ |
148
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
419 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
420 parameter area & \vdots & & \\ |
148
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
421 \end{tabular} |
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
422 \caption{Stack layout on arm32 armhf} |
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
423 \end{figure} |
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
424 |
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
425 |
12729fd52ab7
- performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents:
117
diff
changeset
|
426 \newpage |
35 | 427 |
34 | 428 |
0 | 429 \subsubsection{Architectures} |
430 | |
431 The ARM architecture family contains several revisions with capabilities and | |
117 | 432 extensions (such as thumb-interworking, more vector registers, ...) |
433 The following table sums up the most important properties of the various | |
34 | 434 architecture standards, from a calling convention perspective. |
0 | 435 |
436 % iPhone 3GS : ARM Cortex-A8 | |
437 % Nintendo DS: ARM 7 and ARM 9 | |
438 % ARM 7: ARMv4T | |
439 % ARM 9: ARMv4T, HTC Wizard | |
34 | 440 % Cortex-*: ARMv7, Raspberry Pi 2, ... |
0 | 441 |
442 \begin{table}[h] | |
77 | 443 \begin{tabular*}{0.95\textwidth}{lll} |
0 | 444 Arch & Platforms & Details \\ |
445 \hline | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
446 ARMv4 & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
447 ARMv4T & ARM 7, ARM 9, Neo FreeRunner (OpenMoko) & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
448 ARMv5 & ARM 9E & BLX instruction available \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
449 ARMv6 & & No vector registers available in thumb \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
450 ARMv7 & iPod touch, iPhone 3GS/4, Raspberry Pi 2 & VFP, armhf convention on some platforms \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
451 ARMv8 & iPhone 6 and higher & 64bit support \\ |
76 | 452 \end{tabular*} |
0 | 453 \caption{Overview of ARM Architecture, Platforms and Details} |
454 \end{table} | |
455 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
277
diff
changeset
|
456 |
0 | 457 \newpage |
458 |