1 /* libunwind - a platform-independent unwind library
2 Copyright (C) 2001-2004 Hewlett-Packard Co
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4 Copyright (C) 2013 Linaro Limited
6 This file is part of libunwind.
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 "Software"), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
30 #if defined(__cplusplus) || defined(c_plusplus)
38 #define UNW_TARGET aarch64
39 #define UNW_TARGET_AARCH64 1
41 #define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
43 /* This needs to be big enough to accommodate "struct cursor", while
44 leaving some slack for future expansion. Changing this value will
45 require recompiling all users of this library. Stack allocation is
46 relatively cheap and unwind-state copying is relatively rare, so we
47 want to err on making it rather too big than too small. */
49 #define UNW_TDEP_CURSOR_LEN 4096
51 typedef uint64_t unw_word_t;
52 typedef int64_t unw_sword_t;
54 typedef long double unw_tdep_fpreg_t;
58 /* no aarch64-specific auxiliary proc-info */
59 /* ANDROID support update. */
61 /* End of ANDROID update. */
67 /* 64-bit general registers. */
78 /* Temporary registers. */
87 /* Intra-procedure-call temporary registers. */
91 /* Callee-saved registers. */
104 /* 64-bit frame pointer. */
107 /* 64-bit link register. */
110 /* 64-bit stack pointer. */
115 /* 128-bit FP/Advanced SIMD registers. */
152 /* For AArch64, the CFA is the value of SP (x31) at the call site of the
154 UNW_AARCH64_CFA = UNW_AARCH64_SP,
156 UNW_TDEP_LAST_REG = UNW_AARCH64_FPCR,
158 UNW_TDEP_IP = UNW_AARCH64_X30,
159 UNW_TDEP_SP = UNW_AARCH64_SP,
160 UNW_TDEP_EH = UNW_AARCH64_X0,
165 /* Use R0 through R3 to pass exception handling information. */
166 #define UNW_TDEP_NUM_EH_REGS 4
168 typedef struct unw_tdep_save_loc
170 /* Additional target-dependent info on a save location. */
171 /* ANDROID support update. */
173 /* End of ANDROID update. */
178 /* On AArch64, we can directly use ucontext_t as the unwind context. */
179 typedef ucontext_t unw_tdep_context_t;
181 #include "libunwind-common.h"
182 #include "libunwind-dynamic.h"
184 /* ANDROID support update. */
185 /* There is no getcontext in Android. */
186 #define unw_tdep_getcontext(uc) (({ \
187 unw_tdep_context_t *unw_ctx = (uc); \
188 register uint64_t *unw_base asm ("x0") = (uint64_t*) unw_ctx->uc_mcontext.regs; \
189 __asm__ __volatile__ ( \
190 "stp x0, x1, [%[base], #0]\n" \
191 "stp x2, x3, [%[base], #16]\n" \
192 "stp x4, x5, [%[base], #32]\n" \
193 "stp x6, x7, [%[base], #48]\n" \
194 "stp x8, x9, [%[base], #64]\n" \
195 "stp x10, x11, [%[base], #80]\n" \
196 "stp x12, x13, [%[base], #96]\n" \
197 "stp x14, x13, [%[base], #112]\n" \
198 "stp x16, x17, [%[base], #128]\n" \
199 "stp x18, x19, [%[base], #144]\n" \
200 "stp x20, x21, [%[base], #160]\n" \
201 "stp x22, x23, [%[base], #176]\n" \
202 "stp x24, x25, [%[base], #192]\n" \
203 "stp x26, x27, [%[base], #208]\n" \
204 "stp x28, x29, [%[base], #224]\n" \
205 "str x30, [%[base], #240]\n" \
207 "stp x1, x30, [%[base], #248]\n" \
208 : [base] "+r" (unw_base) : : "x1", "memory"); \
210 /* End of ANDROID update. */
211 #define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
213 extern int unw_tdep_is_fpreg (int);
215 #if defined(__cplusplus) || defined(c_plusplus)
219 #endif /* LIBUNWIND_H */