summaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/libunwind/libunwind-1.1
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-support/libunwind/libunwind-1.1')
-rw-r--r--meta/recipes-support/libunwind/libunwind-1.1/AArch64-port.patch2529
-rw-r--r--meta/recipes-support/libunwind/libunwind-1.1/Support-building-with-older-compilers.patch72
2 files changed, 2601 insertions, 0 deletions
diff --git a/meta/recipes-support/libunwind/libunwind-1.1/AArch64-port.patch b/meta/recipes-support/libunwind/libunwind-1.1/AArch64-port.patch
new file mode 100644
index 0000000000..228ec322d5
--- /dev/null
+++ b/meta/recipes-support/libunwind/libunwind-1.1/AArch64-port.patch
@@ -0,0 +1,2529 @@
1From ac6c0a6535975f1dc2da6e4e2766614baac2a14a Mon Sep 17 00:00:00 2001
2From: Yvan Roux <yvan.roux@linaro.org>
3Date: Sat, 11 May 2013 09:18:23 -0600
4Subject: [PATCH] AArch64 port.
5
6Upstream-Status: Backport
7
8---
9 Makefile.am | 6
10 README | 1
11 configure.ac | 6
12 include/libunwind-aarch64.h | 187 ++++++++++++++++++++++
13 include/libunwind.h.in | 4
14 include/tdep-aarch64/dwarf-config.h | 52 ++++++
15 include/tdep-aarch64/jmpbuf.h | 33 +++
16 include/tdep-aarch64/libunwind_i.h | 294 +++++++++++++++++++++++++++++++++++
17 include/tdep/dwarf-config.h | 4
18 include/tdep/jmpbuf.h | 2
19 include/tdep/libunwind_i.h.in | 4
20 src/Makefile.am | 39 ++++
21 src/aarch64/Gcreate_addr_space.c | 60 +++++++
22 src/aarch64/Gget_proc_info.c | 39 ++++
23 src/aarch64/Gget_save_loc.c | 100 +++++++++++
24 src/aarch64/Gglobal.c | 57 ++++++
25 src/aarch64/Ginit.c | 187 ++++++++++++++++++++++
26 src/aarch64/Ginit_local.c | 55 ++++++
27 src/aarch64/Ginit_remote.c | 45 +++++
28 src/aarch64/Gis_signal_frame.c | 64 +++++++
29 src/aarch64/Gregs.c | 113 +++++++++++++
30 src/aarch64/Gresume.c | 177 +++++++++++++++++++++
31 src/aarch64/Gstep.c | 129 +++++++++++++++
32 src/aarch64/Lcreate_addr_space.c | 5
33 src/aarch64/Lget_proc_info.c | 5
34 src/aarch64/Lget_save_loc.c | 5
35 src/aarch64/Lglobal.c | 5
36 src/aarch64/Linit.c | 5
37 src/aarch64/Linit_local.c | 5
38 src/aarch64/Linit_remote.c | 5
39 src/aarch64/Lis_signal_frame.c | 5
40 src/aarch64/Lregs.c | 5
41 src/aarch64/Lresume.c | 5
42 src/aarch64/Lstep.c | 5
43 src/aarch64/gen-offsets.c | 68 ++++++++
44 src/aarch64/init.h | 127 +++++++++++++++
45 src/aarch64/is_fpreg.c | 32 +++
46 src/aarch64/offsets.h | 49 +++++
47 src/aarch64/regname.c | 106 ++++++++++++
48 src/aarch64/siglongjmp.S | 12 +
49 src/aarch64/unwind_i.h | 43 +++++
50 src/coredump/_UCD_access_reg_linux.c | 5
51 src/ptrace/_UPT_reg_offset.c | 36 ++++
52 43 files changed, 2184 insertions(+), 7 deletions(-)
53 create mode 100644 include/libunwind-aarch64.h
54 create mode 100644 include/tdep-aarch64/dwarf-config.h
55 create mode 100644 include/tdep-aarch64/jmpbuf.h
56 create mode 100644 include/tdep-aarch64/libunwind_i.h
57 create mode 100644 src/aarch64/Gcreate_addr_space.c
58 create mode 100644 src/aarch64/Gget_proc_info.c
59 create mode 100644 src/aarch64/Gget_save_loc.c
60 create mode 100644 src/aarch64/Gglobal.c
61 create mode 100644 src/aarch64/Ginit.c
62 create mode 100644 src/aarch64/Ginit_local.c
63 create mode 100644 src/aarch64/Ginit_remote.c
64 create mode 100644 src/aarch64/Gis_signal_frame.c
65 create mode 100644 src/aarch64/Gregs.c
66 create mode 100644 src/aarch64/Gresume.c
67 create mode 100644 src/aarch64/Gstep.c
68 create mode 100644 src/aarch64/Lcreate_addr_space.c
69 create mode 100644 src/aarch64/Lget_proc_info.c
70 create mode 100644 src/aarch64/Lget_save_loc.c
71 create mode 100644 src/aarch64/Lglobal.c
72 create mode 100644 src/aarch64/Linit.c
73 create mode 100644 src/aarch64/Linit_local.c
74 create mode 100644 src/aarch64/Linit_remote.c
75 create mode 100644 src/aarch64/Lis_signal_frame.c
76 create mode 100644 src/aarch64/Lregs.c
77 create mode 100644 src/aarch64/Lresume.c
78 create mode 100644 src/aarch64/Lstep.c
79 create mode 100644 src/aarch64/gen-offsets.c
80 create mode 100644 src/aarch64/init.h
81 create mode 100644 src/aarch64/is_fpreg.c
82 create mode 100644 src/aarch64/offsets.h
83 create mode 100644 src/aarch64/regname.c
84 create mode 100644 src/aarch64/siglongjmp.S
85 create mode 100644 src/aarch64/unwind_i.h
86
87--- a/Makefile.am
88+++ b/Makefile.am
89@@ -2,6 +2,9 @@ include_HEADERS = include/libunwind-dyna
90 include/libunwind-ptrace.h \
91 include/libunwind-coredump.h
92
93+if ARCH_AARCH64
94+include_HEADERS += include/libunwind-aarch64.h
95+endif
96 if ARCH_ARM
97 include_HEADERS += include/libunwind-arm.h
98 endif
99@@ -41,6 +44,9 @@ SUBDIRS = src tests doc
100 noinst_HEADERS = include/dwarf.h include/dwarf_i.h include/dwarf-eh.h \
101 include/compiler.h include/libunwind_i.h include/mempool.h \
102 include/remote.h \
103+ include/tdep-aarch64/dwarf-config.h \
104+ include/tdep-aarch64/jmpbuf.h \
105+ include/tdep-aarch64/libunwind_i.h \
106 include/tdep-arm/dwarf-config.h include/tdep-arm/ex_tables.h \
107 include/tdep-arm/jmpbuf.h include/tdep-arm/libunwind_i.h \
108 include/tdep-ia64/jmpbuf.h include/tdep-ia64/rse.h \
109--- a/README
110+++ b/README
111@@ -9,6 +9,7 @@ several architecture/operating-system co
112 Linux/IA-64: Fully tested and supported.
113 Linux/PARISC: Works well, but C library missing unwind-info.
114 HP-UX/IA-64: Mostly works but known to have some serious limitations.
115+ Linux/AArch64: Newly added.
116 Linux/PPC64: Newly added.
117 Linux/SuperH: Newly added.
118 FreeBSD/i386: Newly added.
119--- a/configure.ac
120+++ b/configure.ac
121@@ -104,7 +104,7 @@ SET_ARCH([$target_cpu],[target_arch])
122
123 AC_ARG_ENABLE(coredump,
124 AS_HELP_STRING([--enable-coredump],[building libunwind-coredump library]),,
125- [AS_CASE([$host_arch], [arm*|mips*|sh*|x86*], [enable_coredump=yes], [enable_coredump=no])]
126+ [AS_CASE([$host_arch], [aarch64*|arm*|mips*|sh*|x86*], [enable_coredump=yes], [enable_coredump=no])]
127 )
128
129 AC_MSG_CHECKING([if we should build libunwind-coredump])
130@@ -121,6 +121,7 @@ AC_MSG_RESULT([$target_os])
131
132 AM_CONDITIONAL(BUILD_COREDUMP, test x$enable_coredump = xyes)
133 AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch)
134+AM_CONDITIONAL(ARCH_AARCH64, test x$target_arch = xaarch64)
135 AM_CONDITIONAL(ARCH_ARM, test x$target_arch = xarm)
136 AM_CONDITIONAL(ARCH_IA64, test x$target_arch = xia64)
137 AM_CONDITIONAL(ARCH_HPPA, test x$target_arch = xhppa)
138@@ -137,7 +138,7 @@ AM_CONDITIONAL(OS_FREEBSD, expr x$target
139 AC_MSG_CHECKING([for ELF helper width])
140 case "${target_arch}" in
141 (arm|hppa|ppc32|x86|sh) use_elf32=yes; AC_MSG_RESULT([32]);;
142-(ia64|ppc64|x86_64) use_elf64=yes; AC_MSG_RESULT([64]);;
143+(aarch64|ia64|ppc64|x86_64) use_elf64=yes; AC_MSG_RESULT([64]);;
144 (mips) use_elfxx=yes; AC_MSG_RESULT([xx]);;
145 *) AC_MSG_ERROR([Unknown ELF target: ${target_arch}])
146 esac
147@@ -186,6 +187,7 @@ AS_HELP_STRING([--enable-cxx-exceptions]
148 # C++ exception handling doesn't work too well on x86
149 case $target_arch in
150 x86*) enable_cxx_exceptions=no;;
151+ aarch64*) enable_cxx_exceptions=no;;
152 arm*) enable_cxx_exceptions=no;;
153 mips*) enable_cxx_exceptions=no;;
154 *) enable_cxx_exceptions=yes;;
155--- /dev/null
156+++ b/include/libunwind-aarch64.h
157@@ -0,0 +1,187 @@
158+/* libunwind - a platform-independent unwind library
159+ Copyright (C) 2001-2004 Hewlett-Packard Co
160+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
161+ Copyright (C) 2013 Linaro Limited
162+
163+This file is part of libunwind.
164+
165+Permission is hereby granted, free of charge, to any person obtaining
166+a copy of this software and associated documentation files (the
167+"Software"), to deal in the Software without restriction, including
168+without limitation the rights to use, copy, modify, merge, publish,
169+distribute, sublicense, and/or sell copies of the Software, and to
170+permit persons to whom the Software is furnished to do so, subject to
171+the following conditions:
172+
173+The above copyright notice and this permission notice shall be
174+included in all copies or substantial portions of the Software.
175+
176+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
177+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
178+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
179+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
180+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
181+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
182+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
183+
184+#ifndef LIBUNWIND_H
185+#define LIBUNWIND_H
186+
187+#if defined(__cplusplus) || defined(c_plusplus)
188+extern "C" {
189+#endif
190+
191+#include <inttypes.h>
192+#include <stddef.h>
193+#include <ucontext.h>
194+
195+#define UNW_TARGET aarch64
196+#define UNW_TARGET_AARCH64 1
197+
198+#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
199+
200+/* This needs to be big enough to accommodate "struct cursor", while
201+ leaving some slack for future expansion. Changing this value will
202+ require recompiling all users of this library. Stack allocation is
203+ relatively cheap and unwind-state copying is relatively rare, so we
204+ want to err on making it rather too big than too small. */
205+
206+#define UNW_TDEP_CURSOR_LEN 4096
207+
208+typedef uint64_t unw_word_t;
209+typedef int64_t unw_sword_t;
210+
211+typedef long double unw_tdep_fpreg_t;
212+
213+typedef struct
214+ {
215+ /* no aarch64-specific auxiliary proc-info */
216+ }
217+unw_tdep_proc_info_t;
218+
219+typedef enum
220+ {
221+ /* 64-bit general registers. */
222+ UNW_AARCH64_X0,
223+ UNW_AARCH64_X1,
224+ UNW_AARCH64_X2,
225+ UNW_AARCH64_X3,
226+ UNW_AARCH64_X4,
227+ UNW_AARCH64_X5,
228+ UNW_AARCH64_X6,
229+ UNW_AARCH64_X7,
230+ UNW_AARCH64_X8,
231+
232+ /* Temporary registers. */
233+ UNW_AARCH64_X9,
234+ UNW_AARCH64_X10,
235+ UNW_AARCH64_X11,
236+ UNW_AARCH64_X12,
237+ UNW_AARCH64_X13,
238+ UNW_AARCH64_X14,
239+ UNW_AARCH64_X15,
240+
241+ /* Intra-procedure-call temporary registers. */
242+ UNW_AARCH64_X16,
243+ UNW_AARCH64_X17,
244+
245+ /* Callee-saved registers. */
246+ UNW_AARCH64_X18,
247+ UNW_AARCH64_X19,
248+ UNW_AARCH64_X20,
249+ UNW_AARCH64_X21,
250+ UNW_AARCH64_X22,
251+ UNW_AARCH64_X23,
252+ UNW_AARCH64_X24,
253+ UNW_AARCH64_X25,
254+ UNW_AARCH64_X26,
255+ UNW_AARCH64_X27,
256+ UNW_AARCH64_X28,
257+
258+ /* 64-bit frame pointer. */
259+ UNW_AARCH64_X29,
260+
261+ /* 64-bit link register. */
262+ UNW_AARCH64_X30,
263+
264+ /* 64-bit stack pointer. */
265+ UNW_AARCH64_SP = 31,
266+ UNW_AARCH64_PC,
267+ UNW_AARCH64_PSTATE,
268+
269+ /* 128-bit FP/Advanced SIMD registers. */
270+ UNW_AARCH64_V0 = 64,
271+ UNW_AARCH64_V1,
272+ UNW_AARCH64_V2,
273+ UNW_AARCH64_V3,
274+ UNW_AARCH64_V4,
275+ UNW_AARCH64_V5,
276+ UNW_AARCH64_V6,
277+ UNW_AARCH64_V7,
278+ UNW_AARCH64_V8,
279+ UNW_AARCH64_V9,
280+ UNW_AARCH64_V10,
281+ UNW_AARCH64_V11,
282+ UNW_AARCH64_V12,
283+ UNW_AARCH64_V13,
284+ UNW_AARCH64_V14,
285+ UNW_AARCH64_V15,
286+ UNW_AARCH64_V16,
287+ UNW_AARCH64_V17,
288+ UNW_AARCH64_V18,
289+ UNW_AARCH64_V19,
290+ UNW_AARCH64_V20,
291+ UNW_AARCH64_V21,
292+ UNW_AARCH64_V22,
293+ UNW_AARCH64_V23,
294+ UNW_AARCH64_V24,
295+ UNW_AARCH64_V25,
296+ UNW_AARCH64_V26,
297+ UNW_AARCH64_V27,
298+ UNW_AARCH64_V28,
299+ UNW_AARCH64_V29,
300+ UNW_AARCH64_V30,
301+ UNW_AARCH64_V31,
302+
303+ UNW_AARCH64_FPSR,
304+ UNW_AARCH64_FPCR,
305+
306+ /* For AArch64, the CFA is the value of SP (x31) at the call site of the
307+ previous frame. */
308+ UNW_AARCH64_CFA = UNW_AARCH64_SP,
309+
310+ UNW_TDEP_LAST_REG = UNW_AARCH64_FPCR,
311+
312+ UNW_TDEP_IP = UNW_AARCH64_X30,
313+ UNW_TDEP_SP = UNW_AARCH64_SP,
314+ UNW_TDEP_EH = UNW_AARCH64_X0,
315+
316+ }
317+aarch64_regnum_t;
318+
319+/* Use R0 through R3 to pass exception handling information. */
320+#define UNW_TDEP_NUM_EH_REGS 4
321+
322+typedef struct unw_tdep_save_loc
323+ {
324+ /* Additional target-dependent info on a save location. */
325+ }
326+unw_tdep_save_loc_t;
327+
328+
329+/* On AArch64, we can directly use ucontext_t as the unwind context. */
330+typedef ucontext_t unw_tdep_context_t;
331+
332+#include "libunwind-common.h"
333+#include "libunwind-dynamic.h"
334+
335+#define unw_tdep_getcontext(uc) (getcontext (uc), 0)
336+#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
337+
338+extern int unw_tdep_is_fpreg (int);
339+
340+#if defined(__cplusplus) || defined(c_plusplus)
341+}
342+#endif
343+
344+#endif /* LIBUNWIND_H */
345--- a/include/libunwind.h.in
346+++ b/include/libunwind.h.in
347@@ -3,7 +3,9 @@
348
349 #ifndef UNW_REMOTE_ONLY
350
351-#if defined __arm__
352+#if defined __aarch64__
353+#include "libunwind-aarch64.h"
354+#elif defined __arm__
355 # include "libunwind-arm.h"
356 #elif defined __hppa__
357 # include "libunwind-hppa.h"
358--- /dev/null
359+++ b/include/tdep-aarch64/dwarf-config.h
360@@ -0,0 +1,52 @@
361+/* libunwind - a platform-independent unwind library
362+ Copyright (C) 2008 CodeSourcery
363+ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
364+ Copyright (C) 2013 Linaro Limited
365+
366+This file is part of libunwind.
367+
368+Permission is hereby granted, free of charge, to any person obtaining
369+a copy of this software and associated documentation files (the
370+"Software"), to deal in the Software without restriction, including
371+without limitation the rights to use, copy, modify, merge, publish,
372+distribute, sublicense, and/or sell copies of the Software, and to
373+permit persons to whom the Software is furnished to do so, subject to
374+the following conditions:
375+
376+The above copyright notice and this permission notice shall be
377+included in all copies or substantial portions of the Software.
378+
379+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
380+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
381+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
382+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
383+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
384+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
385+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
386+
387+#ifndef dwarf_config_h
388+#define dwarf_config_h
389+
390+/* This matches the value udes by GCC (see
391+ gcc/config/aarch64/aarch64.h:DWARF_FRAME_REGISTERS. */
392+#define DWARF_NUM_PRESERVED_REGS 97
393+
394+/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */
395+#define dwarf_is_big_endian(addr_space) 0
396+
397+#define dwarf_to_unw_regnum(reg) (((reg) <= UNW_AARCH64_V31) ? (reg) : 0)
398+
399+/* Convert a pointer to a dwarf_cursor structure to a pointer to
400+ unw_cursor_t. */
401+#define dwarf_to_cursor(c) ((unw_cursor_t *) (c))
402+
403+typedef struct dwarf_loc
404+ {
405+ unw_word_t val;
406+#ifndef UNW_LOCAL_ONLY
407+ unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */
408+#endif
409+ }
410+dwarf_loc_t;
411+
412+#endif /* dwarf_config_h */
413--- /dev/null
414+++ b/include/tdep-aarch64/jmpbuf.h
415@@ -0,0 +1,33 @@
416+/* libunwind - a platform-independent unwind library
417+ Copyright (C) 2008 CodeSourcery
418+ Copyright (C) 2013 Linaro Limited
419+
420+This file is part of libunwind.
421+
422+Permission is hereby granted, free of charge, to any person obtaining
423+a copy of this software and associated documentation files (the
424+"Software"), to deal in the Software without restriction, including
425+without limitation the rights to use, copy, modify, merge, publish,
426+distribute, sublicense, and/or sell copies of the Software, and to
427+permit persons to whom the Software is furnished to do so, subject to
428+the following conditions:
429+
430+The above copyright notice and this permission notice shall be
431+included in all copies or substantial portions of the Software.
432+
433+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
434+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
435+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
436+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
437+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
438+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
439+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
440+
441+/* Use glibc's jump-buffer indices; NPTL peeks at SP: */
442+
443+/* FIXME for AArch64 */
444+
445+#define JB_SP 13
446+#define JB_RP 14
447+#define JB_MASK_SAVED 15
448+#define JB_MASK 16
449--- /dev/null
450+++ b/include/tdep-aarch64/libunwind_i.h
451@@ -0,0 +1,294 @@
452+/* libunwind - a platform-independent unwind library
453+ Copyright (C) 2001-2005 Hewlett-Packard Co
454+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
455+ Copyright (C) 2013 Linaro Limited
456+
457+This file is part of libunwind.
458+
459+Permission is hereby granted, free of charge, to any person obtaining
460+a copy of this software and associated documentation files (the
461+"Software"), to deal in the Software without restriction, including
462+without limitation the rights to use, copy, modify, merge, publish,
463+distribute, sublicense, and/or sell copies of the Software, and to
464+permit persons to whom the Software is furnished to do so, subject to
465+the following conditions:
466+
467+The above copyright notice and this permission notice shall be
468+included in all copies or substantial portions of the Software.
469+
470+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
471+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
472+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
473+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
474+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
475+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
476+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
477+
478+#ifndef AARCH64_LIBUNWIND_I_H
479+#define AARCH64_LIBUNWIND_I_H
480+
481+/* Target-dependent definitions that are internal to libunwind but need
482+ to be shared with target-independent code. */
483+
484+#include <stdlib.h>
485+#include <libunwind.h>
486+
487+#include "elf64.h"
488+#include "mempool.h"
489+#include "dwarf.h"
490+
491+typedef struct
492+ {
493+ /* no aarch64-specific fast trace */
494+ }
495+unw_tdep_frame_t;
496+
497+#ifdef UNW_LOCAL_ONLY
498+
499+typedef unw_word_t aarch64_loc_t;
500+
501+#else /* !UNW_LOCAL_ONLY */
502+
503+typedef struct aarch64_loc
504+ {
505+ unw_word_t w0, w1;
506+ }
507+aarch64_loc_t;
508+
509+#endif /* !UNW_LOCAL_ONLY */
510+
511+struct unw_addr_space
512+ {
513+ struct unw_accessors acc;
514+ int big_endian;
515+ unw_caching_policy_t caching_policy;
516+#ifdef HAVE_ATOMIC_OPS_H
517+ AO_t cache_generation;
518+#else
519+ uint32_t cache_generation;
520+#endif
521+ unw_word_t dyn_generation; /* see dyn-common.h */
522+ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */
523+ struct dwarf_rs_cache global_cache;
524+ struct unw_debug_frame_list *debug_frames;
525+ };
526+
527+struct cursor
528+ {
529+ struct dwarf_cursor dwarf; /* must be first */
530+ enum
531+ {
532+ AARCH64_SCF_NONE,
533+ AARCH64_SCF_LINUX_RT_SIGFRAME,
534+ }
535+ sigcontext_format;
536+ unw_word_t sigcontext_addr;
537+ unw_word_t sigcontext_sp;
538+ unw_word_t sigcontext_pc;
539+ };
540+
541+#define DWARF_GET_LOC(l) ((l).val)
542+
543+#ifdef UNW_LOCAL_ONLY
544+# define DWARF_NULL_LOC DWARF_LOC (0, 0)
545+# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0)
546+# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) })
547+# define DWARF_IS_REG_LOC(l) 0
548+# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \
549+ tdep_uc_addr((c)->as_arg, (r)), 0))
550+# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0)
551+# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \
552+ tdep_uc_addr((c)->as_arg, (r)), 0))
553+
554+static inline int
555+dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val)
556+{
557+ if (!DWARF_GET_LOC (loc))
558+ return -1;
559+ *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc);
560+ return 0;
561+}
562+
563+static inline int
564+dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val)
565+{
566+ if (!DWARF_GET_LOC (loc))
567+ return -1;
568+ *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val;
569+ return 0;
570+}
571+
572+static inline int
573+dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val)
574+{
575+ if (!DWARF_GET_LOC (loc))
576+ return -1;
577+ *val = *(unw_word_t *) DWARF_GET_LOC (loc);
578+ return 0;
579+}
580+
581+static inline int
582+dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val)
583+{
584+ if (!DWARF_GET_LOC (loc))
585+ return -1;
586+ *(unw_word_t *) DWARF_GET_LOC (loc) = val;
587+ return 0;
588+}
589+
590+#else /* !UNW_LOCAL_ONLY */
591+# define DWARF_LOC_TYPE_FP (1 << 0)
592+# define DWARF_LOC_TYPE_REG (1 << 1)
593+# define DWARF_NULL_LOC DWARF_LOC (0, 0)
594+# define DWARF_IS_NULL_LOC(l) \
595+ ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; })
596+# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) })
597+# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0)
598+# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0)
599+# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG)
600+# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0)
601+# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \
602+ | DWARF_LOC_TYPE_FP))
603+
604+static inline int
605+dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val)
606+{
607+ char *valp = (char *) &val;
608+ unw_word_t addr;
609+ int ret;
610+
611+ if (DWARF_IS_NULL_LOC (loc))
612+ return -UNW_EBADREG;
613+
614+ if (DWARF_IS_REG_LOC (loc))
615+ return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc),
616+ val, 0, c->as_arg);
617+
618+ addr = DWARF_GET_LOC (loc);
619+ if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp,
620+ 0, c->as_arg)) < 0)
621+ return ret;
622+
623+ return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0,
624+ c->as_arg);
625+}
626+
627+static inline int
628+dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val)
629+{
630+ char *valp = (char *) &val;
631+ unw_word_t addr;
632+ int ret;
633+
634+ if (DWARF_IS_NULL_LOC (loc))
635+ return -UNW_EBADREG;
636+
637+ if (DWARF_IS_REG_LOC (loc))
638+ return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc),
639+ &val, 1, c->as_arg);
640+
641+ addr = DWARF_GET_LOC (loc);
642+ if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp,
643+ 1, c->as_arg)) < 0)
644+ return ret;
645+
646+ return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1,
647+ 1, c->as_arg);
648+}
649+
650+static inline int
651+dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val)
652+{
653+ if (DWARF_IS_NULL_LOC (loc))
654+ return -UNW_EBADREG;
655+
656+ /* If a code-generator were to save a value of type unw_word_t in a
657+ floating-point register, we would have to support this case. I
658+ suppose it could happen with MMX registers, but does it really
659+ happen? */
660+ assert (!DWARF_IS_FP_LOC (loc));
661+
662+ if (DWARF_IS_REG_LOC (loc))
663+ return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val,
664+ 0, c->as_arg);
665+ else
666+ return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val,
667+ 0, c->as_arg);
668+}
669+
670+static inline int
671+dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val)
672+{
673+ if (DWARF_IS_NULL_LOC (loc))
674+ return -UNW_EBADREG;
675+
676+ /* If a code-generator were to save a value of type unw_word_t in a
677+ floating-point register, we would have to support this case. I
678+ suppose it could happen with MMX registers, but does it really
679+ happen? */
680+ assert (!DWARF_IS_FP_LOC (loc));
681+
682+ if (DWARF_IS_REG_LOC (loc))
683+ return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val,
684+ 1, c->as_arg);
685+ else
686+ return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val,
687+ 1, c->as_arg);
688+}
689+
690+#endif /* !UNW_LOCAL_ONLY */
691+
692+
693+
694+#define tdep_getcontext_trace unw_getcontext
695+#define tdep_init_done UNW_OBJ(init_done)
696+#define tdep_init UNW_OBJ(init)
697+/* Platforms that support UNW_INFO_FORMAT_TABLE need to define
698+ tdep_search_unwind_table. */
699+#define tdep_search_unwind_table dwarf_search_unwind_table
700+#define tdep_find_unwind_table dwarf_find_unwind_table
701+#define tdep_uc_addr UNW_OBJ(uc_addr)
702+#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image)
703+#define tdep_access_reg UNW_OBJ(access_reg)
704+#define tdep_access_fpreg UNW_OBJ(access_fpreg)
705+#define tdep_fetch_frame(c,ip,n) do {} while(0)
706+#define tdep_cache_frame(c,rs) do {} while(0)
707+#define tdep_reuse_frame(c,rs) do {} while(0)
708+#define tdep_stash_frame(c,rs) do {} while(0)
709+#define tdep_trace(cur,addr,n) (-UNW_ENOINFO)
710+
711+#ifdef UNW_LOCAL_ONLY
712+# define tdep_find_proc_info(c,ip,n) \
713+ dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \
714+ (c)->as_arg)
715+# define tdep_put_unwind_info(as,pi,arg) \
716+ dwarf_put_unwind_info((as), (pi), (arg))
717+#else
718+# define tdep_find_proc_info(c,ip,n) \
719+ (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \
720+ (c)->as_arg)
721+# define tdep_put_unwind_info(as,pi,arg) \
722+ (*(as)->acc.put_unwind_info)((as), (pi), (arg))
723+#endif
724+
725+#define tdep_get_as(c) ((c)->dwarf.as)
726+#define tdep_get_as_arg(c) ((c)->dwarf.as_arg)
727+#define tdep_get_ip(c) ((c)->dwarf.ip)
728+#define tdep_big_endian(as) ((as)->big_endian)
729+
730+extern int tdep_init_done;
731+
732+extern void tdep_init (void);
733+extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
734+ unw_dyn_info_t *di, unw_proc_info_t *pi,
735+ int need_unwind_info, void *arg);
736+extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg);
737+extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
738+ unsigned long *segbase, unsigned long *mapoff,
739+ char *path, size_t pathlen);
740+extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
741+ unw_word_t *valp, int write);
742+extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
743+ unw_fpreg_t *valp, int write);
744+
745+#endif /* AARCH64_LIBUNWIND_I_H */
746--- a/include/tdep/dwarf-config.h
747+++ b/include/tdep/dwarf-config.h
748@@ -1,7 +1,9 @@
749 /* Provide a real file - not a symlink - as it would cause multiarch conflicts
750 when multiple different arch releases are installed simultaneously. */
751
752-#if defined __arm__
753+#if defined __aarch64__
754+# include "tdep-aarch64/dwarf-config.h"
755+#elif defined __arm__
756 # include "tdep-arm/dwarf-config.h"
757 #elif defined __hppa__
758 # include "tdep-hppa/dwarf-config.h"
759--- a/include/tdep/jmpbuf.h
760+++ b/include/tdep/jmpbuf.h
761@@ -3,6 +3,8 @@
762
763 #ifndef UNW_REMOTE_ONLY
764
765+#if defined __aarch64__
766+# include "tdep-aarch64/jmpbuf.h"
767 #if defined __arm__
768 # include "tdep-arm/jmpbuf.h"
769 #elif defined __hppa__
770--- a/include/tdep/libunwind_i.h.in
771+++ b/include/tdep/libunwind_i.h.in
772@@ -3,7 +3,9 @@
773
774 #ifndef UNW_REMOTE_ONLY
775
776-#if defined __arm__
777+#if defined __aarch64__
778+# include "tdep-aarch64/libunwind_i.h"
779+#elif defined __arm__
780 # include "tdep-arm/libunwind_i.h"
781 #elif defined __hppa__
782 # include "tdep-hppa/libunwind_i.h"
783--- a/src/Makefile.am
784+++ b/src/Makefile.am
785@@ -170,6 +170,28 @@ libunwind_elfxx_la_SOURCES = elfxx.c
786 noinst_LTLIBRARIES += $(LIBUNWIND_ELF)
787 libunwind_la_LIBADD += $(LIBUNWIND_ELF)
788
789+# The list of files that go into libunwind and libunwind-aarch64:
790+noinst_HEADERS += aarch64/init.h aarch64/offsets.h aarch64/unwind_i.h
791+libunwind_la_SOURCES_aarch64_common = $(libunwind_la_SOURCES_common) \
792+ aarch64/is_fpreg.c aarch64/regname.c
793+
794+# The list of files that go into libunwind:
795+libunwind_la_SOURCES_aarch64 = $(libunwind_la_SOURCES_aarch64_common) \
796+ $(libunwind_la_SOURCES_local) \
797+ aarch64/Lcreate_addr_space.c aarch64/Lget_proc_info.c \
798+ aarch64/Lget_save_loc.c aarch64/Lglobal.c aarch64/Linit.c \
799+ aarch64/Linit_local.c aarch64/Linit_remote.c \
800+ aarch64/Lis_signal_frame.c aarch64/Lregs.c aarch64/Lresume.c \
801+ aarch64/Lstep.c
802+
803+libunwind_aarch64_la_SOURCES_aarch64 = $(libunwind_la_SOURCES_aarch64_common) \
804+ $(libunwind_la_SOURCES_generic) \
805+ aarch64/Gcreate_addr_space.c aarch64/Gget_proc_info.c \
806+ aarch64/Gget_save_loc.c aarch64/Gglobal.c aarch64/Ginit.c \
807+ aarch64/Ginit_local.c aarch64/Ginit_remote.c \
808+ aarch64/Gis_signal_frame.c aarch64/Gregs.c aarch64/Gresume.c \
809+ aarch64/Gstep.c
810+
811 # The list of files that go into libunwind and libunwind-arm:
812 noinst_HEADERS += arm/init.h arm/offsets.h arm/unwind_i.h
813 libunwind_la_SOURCES_arm_common = $(libunwind_la_SOURCES_common) \
814@@ -418,6 +440,18 @@ if OS_FREEBSD
815 libunwind_coredump_la_SOURCES += coredump/_UCD_access_reg_freebsd.c
816 endif
817
818+if ARCH_AARCH64
819+ lib_LTLIBRARIES += libunwind-aarch64.la
820+ libunwind_la_SOURCES = $(libunwind_la_SOURCES_aarch64)
821+ libunwind_aarch64_la_SOURCES = $(libunwind_aarch64_la_SOURCES_aarch64)
822+ libunwind_aarch64_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION)
823+ libunwind_aarch64_la_LIBADD = libunwind-dwarf-generic.la
824+ libunwind_aarch64_la_LIBADD += libunwind-elf64.la
825+if !REMOTE_ONLY
826+ libunwind_aarch64_la_LIBADD += libunwind.la -lc
827+endif
828+ libunwind_setjmp_la_SOURCES += aarch64/siglongjmp.S
829+else
830 if ARCH_ARM
831 lib_LTLIBRARIES += libunwind-arm.la
832 libunwind_la_SOURCES = $(libunwind_la_SOURCES_arm)
833@@ -545,6 +579,7 @@ endif # ARCH_MIPS
834 endif # ARCH_HPPA
835 endif # ARCH_IA64
836 endif # ARCH_ARM
837+endif # ARCH_AARCH64
838
839 # libunwind-setjmp depends on libunwind-$(arch). Therefore must be added
840 # at the end.
841@@ -567,7 +602,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I
842 AM_CCASFLAGS = $(AM_CPPFLAGS)
843 noinst_HEADERS += unwind/unwind-internal.h
844
845-EXTRA_DIST = $(libunwind_la_SOURCES_arm) \
846+EXTRA_DIST = $(libunwind_la_SOURCES_aarch64) \
847+ $(libunwind_la_SOURCES_arm) \
848 $(libunwind_la_SOURCES_hppa) \
849 $(libunwind_la_SOURCES_ia64) \
850 $(libunwind_la_SOURCES_mips) \
851@@ -579,6 +615,7 @@ EXTRA_DIST = $(libunwind_la_SOURCES_arm)
852 $(libunwind_la_SOURCES_common) \
853 $(libunwind_la_SOURCES_local) \
854 $(libunwind_la_SOURCES_generic) \
855+ $(libunwind_aarch64_la_SOURCES_aarch64) \
856 $(libunwind_arm_la_SOURCES_arm) \
857 $(libunwind_hppa_la_SOURCES_hppa) \
858 $(libunwind_ia64_la_SOURCES_ia64) \
859--- /dev/null
860+++ b/src/aarch64/Gcreate_addr_space.c
861@@ -0,0 +1,60 @@
862+/* libunwind - a platform-independent unwind library
863+ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
864+ Copyright (C) 2013 Linaro Limited
865+
866+This file is part of libunwind.
867+
868+Permission is hereby granted, free of charge, to any person obtaining
869+a copy of this software and associated documentation files (the
870+"Software"), to deal in the Software without restriction, including
871+without limitation the rights to use, copy, modify, merge, publish,
872+distribute, sublicense, and/or sell copies of the Software, and to
873+permit persons to whom the Software is furnished to do so, subject to
874+the following conditions:
875+
876+The above copyright notice and this permission notice shall be
877+included in all copies or substantial portions of the Software.
878+
879+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
880+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
881+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
882+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
883+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
884+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
885+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
886+
887+#include <string.h>
888+#include <stdlib.h>
889+
890+#include "unwind_i.h"
891+
892+PROTECTED unw_addr_space_t
893+unw_create_addr_space (unw_accessors_t *a, int byte_order)
894+{
895+#ifdef UNW_LOCAL_ONLY
896+ return NULL;
897+#else
898+ unw_addr_space_t as;
899+
900+ /* AArch64 supports little-endian and big-endian. */
901+ if (byte_order != 0 && byte_order != __LITTLE_ENDIAN
902+ && byte_order != __BIG_ENDIAN)
903+ return NULL;
904+
905+ as = malloc (sizeof (*as));
906+ if (!as)
907+ return NULL;
908+
909+ memset (as, 0, sizeof (*as));
910+
911+ as->acc = *a;
912+
913+ /* Default to little-endian for AArch64. */
914+ if (byte_order == 0 || byte_order == __LITTLE_ENDIAN)
915+ as->big_endian = 0;
916+ else
917+ as->big_endian = 1;
918+
919+ return as;
920+#endif
921+}
922--- /dev/null
923+++ b/src/aarch64/Gget_proc_info.c
924@@ -0,0 +1,39 @@
925+/* libunwind - a platform-independent unwind library
926+ Copyright (C) 2008 CodeSourcery
927+
928+This file is part of libunwind.
929+
930+Permission is hereby granted, free of charge, to any person obtaining
931+a copy of this software and associated documentation files (the
932+"Software"), to deal in the Software without restriction, including
933+without limitation the rights to use, copy, modify, merge, publish,
934+distribute, sublicense, and/or sell copies of the Software, and to
935+permit persons to whom the Software is furnished to do so, subject to
936+the following conditions:
937+
938+The above copyright notice and this permission notice shall be
939+included in all copies or substantial portions of the Software.
940+
941+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
942+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
943+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
944+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
945+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
946+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
947+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
948+
949+#include "unwind_i.h"
950+
951+PROTECTED int
952+unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi)
953+{
954+ struct cursor *c = (struct cursor *) cursor;
955+ int ret;
956+
957+ ret = dwarf_make_proc_info (&c->dwarf);
958+ if (ret < 0)
959+ return ret;
960+
961+ *pi = c->dwarf.pi;
962+ return 0;
963+}
964--- /dev/null
965+++ b/src/aarch64/Gget_save_loc.c
966@@ -0,0 +1,100 @@
967+/* libunwind - a platform-independent unwind library
968+ Copyright (C) 2008 CodeSourcery
969+ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
970+ Copyright (C) 2013 Linaro Limited
971+
972+This file is part of libunwind.
973+
974+Permission is hereby granted, free of charge, to any person obtaining
975+a copy of this software and associated documentation files (the
976+"Software"), to deal in the Software without restriction, including
977+without limitation the rights to use, copy, modify, merge, publish,
978+distribute, sublicense, and/or sell copies of the Software, and to
979+permit persons to whom the Software is furnished to do so, subject to
980+the following conditions:
981+
982+The above copyright notice and this permission notice shall be
983+included in all copies or substantial portions of the Software.
984+
985+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
986+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
987+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
988+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
989+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
990+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
991+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
992+
993+#include "unwind_i.h"
994+
995+PROTECTED int
996+unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc)
997+{
998+ struct cursor *c = (struct cursor *) cursor;
999+ dwarf_loc_t loc;
1000+
1001+ switch (reg)
1002+ {
1003+ case UNW_AARCH64_X0:
1004+ case UNW_AARCH64_X1:
1005+ case UNW_AARCH64_X2:
1006+ case UNW_AARCH64_X3:
1007+ case UNW_AARCH64_X4:
1008+ case UNW_AARCH64_X5:
1009+ case UNW_AARCH64_X6:
1010+ case UNW_AARCH64_X7:
1011+ case UNW_AARCH64_X8:
1012+ case UNW_AARCH64_X9:
1013+ case UNW_AARCH64_X10:
1014+ case UNW_AARCH64_X11:
1015+ case UNW_AARCH64_X12:
1016+ case UNW_AARCH64_X13:
1017+ case UNW_AARCH64_X14:
1018+ case UNW_AARCH64_X15:
1019+ case UNW_AARCH64_X16:
1020+ case UNW_AARCH64_X17:
1021+ case UNW_AARCH64_X18:
1022+ case UNW_AARCH64_X19:
1023+ case UNW_AARCH64_X20:
1024+ case UNW_AARCH64_X21:
1025+ case UNW_AARCH64_X22:
1026+ case UNW_AARCH64_X23:
1027+ case UNW_AARCH64_X24:
1028+ case UNW_AARCH64_X25:
1029+ case UNW_AARCH64_X26:
1030+ case UNW_AARCH64_X27:
1031+ case UNW_AARCH64_X28:
1032+ case UNW_AARCH64_X29:
1033+ case UNW_AARCH64_X30:
1034+ case UNW_AARCH64_SP:
1035+ case UNW_AARCH64_PC:
1036+ case UNW_AARCH64_PSTATE:
1037+ loc = c->dwarf.loc[reg];
1038+ break;
1039+
1040+ default:
1041+ loc = DWARF_NULL_LOC; /* default to "not saved" */
1042+ break;
1043+ }
1044+
1045+ memset (sloc, 0, sizeof (*sloc));
1046+
1047+ if (DWARF_IS_NULL_LOC (loc))
1048+ {
1049+ sloc->type = UNW_SLT_NONE;
1050+ return 0;
1051+ }
1052+
1053+#if !defined(UNW_LOCAL_ONLY)
1054+ if (DWARF_IS_REG_LOC (loc))
1055+ {
1056+ sloc->type = UNW_SLT_REG;
1057+ sloc->u.regnum = DWARF_GET_LOC (loc);
1058+ }
1059+ else
1060+#endif
1061+ {
1062+ sloc->type = UNW_SLT_MEMORY;
1063+ sloc->u.addr = DWARF_GET_LOC (loc);
1064+ }
1065+ return 0;
1066+}
1067--- /dev/null
1068+++ b/src/aarch64/Gglobal.c
1069@@ -0,0 +1,57 @@
1070+/* libunwind - a platform-independent unwind library
1071+ Copyright (C) 2008 CodeSourcery
1072+ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1073+ Copyright (C) 2013 Linaro Limited
1074+
1075+This file is part of libunwind.
1076+
1077+Permission is hereby granted, free of charge, to any person obtaining
1078+a copy of this software and associated documentation files (the
1079+"Software"), to deal in the Software without restriction, including
1080+without limitation the rights to use, copy, modify, merge, publish,
1081+distribute, sublicense, and/or sell copies of the Software, and to
1082+permit persons to whom the Software is furnished to do so, subject to
1083+the following conditions:
1084+
1085+The above copyright notice and this permission notice shall be
1086+included in all copies or substantial portions of the Software.
1087+
1088+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1089+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1090+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1091+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1092+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1093+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1094+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1095+
1096+#include "unwind_i.h"
1097+#include "dwarf_i.h"
1098+
1099+HIDDEN define_lock (aarch64_lock);
1100+HIDDEN int tdep_init_done;
1101+
1102+HIDDEN void
1103+tdep_init (void)
1104+{
1105+ intrmask_t saved_mask;
1106+
1107+ sigfillset (&unwi_full_mask);
1108+
1109+ lock_acquire (&aarch64_lock, saved_mask);
1110+ {
1111+ if (tdep_init_done)
1112+ /* another thread else beat us to it... */
1113+ goto out;
1114+
1115+ mi_init ();
1116+
1117+ dwarf_init ();
1118+
1119+#ifndef UNW_REMOTE_ONLY
1120+ aarch64_local_addr_space_init ();
1121+#endif
1122+ tdep_init_done = 1; /* signal that we're initialized... */
1123+ }
1124+ out:
1125+ lock_release (&aarch64_lock, saved_mask);
1126+}
1127--- /dev/null
1128+++ b/src/aarch64/Ginit.c
1129@@ -0,0 +1,187 @@
1130+/* libunwind - a platform-independent unwind library
1131+ Copyright (C) 2008 CodeSourcery
1132+ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1133+ Copyright (C) 2013 Linaro Limited
1134+
1135+This file is part of libunwind.
1136+
1137+Permission is hereby granted, free of charge, to any person obtaining
1138+a copy of this software and associated documentation files (the
1139+"Software"), to deal in the Software without restriction, including
1140+without limitation the rights to use, copy, modify, merge, publish,
1141+distribute, sublicense, and/or sell copies of the Software, and to
1142+permit persons to whom the Software is furnished to do so, subject to
1143+the following conditions:
1144+
1145+The above copyright notice and this permission notice shall be
1146+included in all copies or substantial portions of the Software.
1147+
1148+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1149+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1150+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1151+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1152+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1153+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1154+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1155+
1156+#include <stdlib.h>
1157+#include <string.h>
1158+
1159+#include "unwind_i.h"
1160+
1161+#ifdef UNW_REMOTE_ONLY
1162+
1163+/* unw_local_addr_space is a NULL pointer in this case. */
1164+PROTECTED unw_addr_space_t unw_local_addr_space;
1165+
1166+#else /* !UNW_REMOTE_ONLY */
1167+
1168+static struct unw_addr_space local_addr_space;
1169+
1170+PROTECTED unw_addr_space_t unw_local_addr_space = &local_addr_space;
1171+
1172+static inline void *
1173+uc_addr (ucontext_t *uc, int reg)
1174+{
1175+ if (reg >= UNW_AARCH64_X0 && reg <= UNW_AARCH64_V31)
1176+ return &uc->uc_mcontext.regs[reg];
1177+ else
1178+ return NULL;
1179+}
1180+
1181+# ifdef UNW_LOCAL_ONLY
1182+
1183+HIDDEN void *
1184+tdep_uc_addr (ucontext_t *uc, int reg)
1185+{
1186+ return uc_addr (uc, reg);
1187+}
1188+
1189+# endif /* UNW_LOCAL_ONLY */
1190+
1191+HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
1192+
1193+/* XXX fix me: there is currently no way to locate the dyn-info list
1194+ by a remote unwinder. On ia64, this is done via a special
1195+ unwind-table entry. Perhaps something similar can be done with
1196+ DWARF2 unwind info. */
1197+
1198+static void
1199+put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
1200+{
1201+ /* it's a no-op */
1202+}
1203+
1204+static int
1205+get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
1206+ void *arg)
1207+{
1208+ *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
1209+ return 0;
1210+}
1211+
1212+static int
1213+access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write,
1214+ void *arg)
1215+{
1216+ if (write)
1217+ {
1218+ Debug (16, "mem[%lx] <- %lx\n", addr, *val);
1219+ *(unw_word_t *) addr = *val;
1220+ }
1221+ else
1222+ {
1223+ *val = *(unw_word_t *) addr;
1224+ Debug (16, "mem[%lx] -> %lx\n", addr, *val);
1225+ }
1226+ return 0;
1227+}
1228+
1229+static int
1230+access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write,
1231+ void *arg)
1232+{
1233+ unw_word_t *addr;
1234+ ucontext_t *uc = arg;
1235+
1236+ if (unw_is_fpreg (reg))
1237+ goto badreg;
1238+
1239+ if (!(addr = uc_addr (uc, reg)))
1240+ goto badreg;
1241+
1242+ if (write)
1243+ {
1244+ *(unw_word_t *) addr = *val;
1245+ Debug (12, "%s <- %lx\n", unw_regname (reg), *val);
1246+ }
1247+ else
1248+ {
1249+ *val = *(unw_word_t *) addr;
1250+ Debug (12, "%s -> %lx\n", unw_regname (reg), *val);
1251+ }
1252+ return 0;
1253+
1254+ badreg:
1255+ Debug (1, "bad register number %u\n", reg);
1256+ return -UNW_EBADREG;
1257+}
1258+
1259+static int
1260+access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val,
1261+ int write, void *arg)
1262+{
1263+ ucontext_t *uc = arg;
1264+ unw_fpreg_t *addr;
1265+
1266+ if (!unw_is_fpreg (reg))
1267+ goto badreg;
1268+
1269+ if (!(addr = uc_addr (uc, reg)))
1270+ goto badreg;
1271+
1272+ if (write)
1273+ {
1274+ Debug (12, "%s <- %08lx.%08lx.%08lx\n", unw_regname (reg),
1275+ ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]);
1276+ *(unw_fpreg_t *) addr = *val;
1277+ }
1278+ else
1279+ {
1280+ *val = *(unw_fpreg_t *) addr;
1281+ Debug (12, "%s -> %08lx.%08lx.%08lx\n", unw_regname (reg),
1282+ ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]);
1283+ }
1284+ return 0;
1285+
1286+ badreg:
1287+ Debug (1, "bad register number %u\n", reg);
1288+ /* attempt to access a non-preserved register */
1289+ return -UNW_EBADREG;
1290+}
1291+
1292+static int
1293+get_static_proc_name (unw_addr_space_t as, unw_word_t ip,
1294+ char *buf, size_t buf_len, unw_word_t *offp,
1295+ void *arg)
1296+{
1297+ return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp);
1298+}
1299+
1300+HIDDEN void
1301+aarch64_local_addr_space_init (void)
1302+{
1303+ memset (&local_addr_space, 0, sizeof (local_addr_space));
1304+ local_addr_space.caching_policy = UNW_CACHE_GLOBAL;
1305+ local_addr_space.acc.find_proc_info = dwarf_find_proc_info;
1306+ local_addr_space.acc.put_unwind_info = put_unwind_info;
1307+ local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr;
1308+ local_addr_space.acc.access_mem = access_mem;
1309+ local_addr_space.acc.access_reg = access_reg;
1310+ local_addr_space.acc.access_fpreg = access_fpreg;
1311+ local_addr_space.acc.resume = aarch64_local_resume;
1312+ local_addr_space.acc.get_proc_name = get_static_proc_name;
1313+ unw_flush_cache (&local_addr_space, 0, 0);
1314+}
1315+
1316+#endif /* !UNW_REMOTE_ONLY */
1317--- /dev/null
1318+++ b/src/aarch64/Ginit_local.c
1319@@ -0,0 +1,55 @@
1320+/* libunwind - a platform-independent unwind library
1321+ Copyright (C) 2008 CodeSourcery
1322+ Copyright (C) 2011-2013 Linaro Limited
1323+
1324+This file is part of libunwind.
1325+
1326+Permission is hereby granted, free of charge, to any person obtaining
1327+a copy of this software and associated documentation files (the
1328+"Software"), to deal in the Software without restriction, including
1329+without limitation the rights to use, copy, modify, merge, publish,
1330+distribute, sublicense, and/or sell copies of the Software, and to
1331+permit persons to whom the Software is furnished to do so, subject to
1332+the following conditions:
1333+
1334+The above copyright notice and this permission notice shall be
1335+included in all copies or substantial portions of the Software.
1336+
1337+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1338+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1339+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1340+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1341+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1342+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1343+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1344+
1345+#include "unwind_i.h"
1346+#include "init.h"
1347+
1348+#ifdef UNW_REMOTE_ONLY
1349+
1350+PROTECTED int
1351+unw_init_local (unw_cursor_t *cursor, unw_context_t *uc)
1352+{
1353+ return -UNW_EINVAL;
1354+}
1355+
1356+#else /* !UNW_REMOTE_ONLY */
1357+
1358+PROTECTED int
1359+unw_init_local (unw_cursor_t *cursor, unw_context_t *uc)
1360+{
1361+ struct cursor *c = (struct cursor *) cursor;
1362+
1363+ if (!tdep_init_done)
1364+ tdep_init ();
1365+
1366+ Debug (1, "(cursor=%p)\n", c);
1367+
1368+ c->dwarf.as = unw_local_addr_space;
1369+ c->dwarf.as_arg = uc;
1370+
1371+ return common_init (c, 1);
1372+}
1373+
1374+#endif /* !UNW_REMOTE_ONLY */
1375--- /dev/null
1376+++ b/src/aarch64/Ginit_remote.c
1377@@ -0,0 +1,45 @@
1378+/* libunwind - a platform-independent unwind library
1379+ Copyright (C) 2008 CodeSourcery
1380+
1381+This file is part of libunwind.
1382+
1383+Permission is hereby granted, free of charge, to any person obtaining
1384+a copy of this software and associated documentation files (the
1385+"Software"), to deal in the Software without restriction, including
1386+without limitation the rights to use, copy, modify, merge, publish,
1387+distribute, sublicense, and/or sell copies of the Software, and to
1388+permit persons to whom the Software is furnished to do so, subject to
1389+the following conditions:
1390+
1391+The above copyright notice and this permission notice shall be
1392+included in all copies or substantial portions of the Software.
1393+
1394+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1395+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1396+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1397+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1398+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1399+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1400+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1401+
1402+#include "init.h"
1403+#include "unwind_i.h"
1404+
1405+PROTECTED int
1406+unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg)
1407+{
1408+#ifdef UNW_LOCAL_ONLY
1409+ return -UNW_EINVAL;
1410+#else /* !UNW_LOCAL_ONLY */
1411+ struct cursor *c = (struct cursor *) cursor;
1412+
1413+ if (!tdep_init_done)
1414+ tdep_init ();
1415+
1416+ Debug (1, "(cursor=%p)\n", c);
1417+
1418+ c->dwarf.as = as;
1419+ c->dwarf.as_arg = as_arg;
1420+ return common_init (c, 0);
1421+#endif /* !UNW_LOCAL_ONLY */
1422+}
1423--- /dev/null
1424+++ b/src/aarch64/Gis_signal_frame.c
1425@@ -0,0 +1,64 @@
1426+/* libunwind - a platform-independent unwind library
1427+ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1428+ Copyright (C) 2013 Linaro Limited
1429+
1430+This file is part of libunwind.
1431+
1432+Permission is hereby granted, free of charge, to any person obtaining
1433+a copy of this software and associated documentation files (the
1434+"Software"), to deal in the Software without restriction, including
1435+without limitation the rights to use, copy, modify, merge, publish,
1436+distribute, sublicense, and/or sell copies of the Software, and to
1437+permit persons to whom the Software is furnished to do so, subject to
1438+the following conditions:
1439+
1440+The above copyright notice and this permission notice shall be
1441+included in all copies or substantial portions of the Software.
1442+
1443+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1444+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1445+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1446+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1447+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1448+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1449+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1450+
1451+#include "unwind_i.h"
1452+
1453+/* The restorer stub will always have the form:
1454+
1455+ d2801168 movz x8, #0x8b
1456+ d4000001 svc #0x0
1457+*/
1458+
1459+PROTECTED int
1460+unw_is_signal_frame (unw_cursor_t *cursor)
1461+{
1462+#ifdef __linux__
1463+ struct cursor *c = (struct cursor *) cursor;
1464+ unw_word_t w0, ip;
1465+ unw_addr_space_t as;
1466+ unw_accessors_t *a;
1467+ void *arg;
1468+ int ret;
1469+
1470+ as = c->dwarf.as;
1471+ a = unw_get_accessors (as);
1472+ arg = c->dwarf.as_arg;
1473+
1474+ ip = c->dwarf.ip;
1475+
1476+ ret = (*a->access_mem) (as, ip, &w0, 0, arg);
1477+ if (ret < 0)
1478+ return ret;
1479+
1480+ /* FIXME: distinguish 32bit insn vs 64bit registers. */
1481+ if (w0 != 0xd4000001d2801168)
1482+ return 0;
1483+
1484+ return 1;
1485+
1486+#else
1487+ return -UNW_ENOINFO;
1488+#endif
1489+}
1490--- /dev/null
1491+++ b/src/aarch64/Gregs.c
1492@@ -0,0 +1,113 @@
1493+/* libunwind - a platform-independent unwind library
1494+ Copyright (C) 2008 CodeSourcery
1495+ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1496+ Copyright (C) 2013 Linaro Limited
1497+
1498+This file is part of libunwind.
1499+
1500+Permission is hereby granted, free of charge, to any person obtaining
1501+a copy of this software and associated documentation files (the
1502+"Software"), to deal in the Software without restriction, including
1503+without limitation the rights to use, copy, modify, merge, publish,
1504+distribute, sublicense, and/or sell copies of the Software, and to
1505+permit persons to whom the Software is furnished to do so, subject to
1506+the following conditions:
1507+
1508+The above copyright notice and this permission notice shall be
1509+included in all copies or substantial portions of the Software.
1510+
1511+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1512+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1513+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1514+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1515+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1516+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1517+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1518+
1519+#include "unwind_i.h"
1520+
1521+HIDDEN int
1522+tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp,
1523+ int write)
1524+{
1525+ dwarf_loc_t loc = DWARF_NULL_LOC;
1526+ unsigned int mask;
1527+
1528+ switch (reg)
1529+ {
1530+ case UNW_AARCH64_X0:
1531+ case UNW_AARCH64_X1:
1532+ case UNW_AARCH64_X2:
1533+ case UNW_AARCH64_X3:
1534+ mask = 1 << reg;
1535+ if (write)
1536+ {
1537+ c->dwarf.eh_args[reg] = *valp;
1538+ c->dwarf.eh_valid_mask |= mask;
1539+ return 0;
1540+ }
1541+ else if ((c->dwarf.eh_valid_mask & mask) != 0)
1542+ {
1543+ *valp = c->dwarf.eh_args[reg];
1544+ return 0;
1545+ }
1546+ else
1547+ loc = c->dwarf.loc[reg];
1548+ break;
1549+
1550+ case UNW_AARCH64_X4:
1551+ case UNW_AARCH64_X5:
1552+ case UNW_AARCH64_X6:
1553+ case UNW_AARCH64_X7:
1554+ case UNW_AARCH64_X8:
1555+ case UNW_AARCH64_X9:
1556+ case UNW_AARCH64_X10:
1557+ case UNW_AARCH64_X11:
1558+ case UNW_AARCH64_X12:
1559+ case UNW_AARCH64_X13:
1560+ case UNW_AARCH64_X14:
1561+ case UNW_AARCH64_X15:
1562+ case UNW_AARCH64_X16:
1563+ case UNW_AARCH64_X17:
1564+ case UNW_AARCH64_X18:
1565+ case UNW_AARCH64_X19:
1566+ case UNW_AARCH64_X20:
1567+ case UNW_AARCH64_X21:
1568+ case UNW_AARCH64_X22:
1569+ case UNW_AARCH64_X23:
1570+ case UNW_AARCH64_X24:
1571+ case UNW_AARCH64_X25:
1572+ case UNW_AARCH64_X26:
1573+ case UNW_AARCH64_X27:
1574+ case UNW_AARCH64_X28:
1575+ case UNW_AARCH64_X29:
1576+ case UNW_AARCH64_X30:
1577+ case UNW_AARCH64_PC:
1578+ case UNW_AARCH64_PSTATE:
1579+ loc = c->dwarf.loc[reg];
1580+ break;
1581+
1582+ case UNW_AARCH64_SP:
1583+ if (write)
1584+ return -UNW_EREADONLYREG;
1585+ *valp = c->dwarf.cfa;
1586+ return 0;
1587+
1588+ default:
1589+ Debug (1, "bad register number %u\n", reg);
1590+ return -UNW_EBADREG;
1591+ }
1592+
1593+ if (write)
1594+ return dwarf_put (&c->dwarf, loc, *valp);
1595+ else
1596+ return dwarf_get (&c->dwarf, loc, valp);
1597+}
1598+
1599+HIDDEN int
1600+tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp,
1601+ int write)
1602+{
1603+ Debug (1, "bad register number %u\n", reg);
1604+ return -UNW_EBADREG;
1605+}
1606--- /dev/null
1607+++ b/src/aarch64/Gresume.c
1608@@ -0,0 +1,177 @@
1609+/* libunwind - a platform-independent unwind library
1610+ Copyright (C) 2008 CodeSourcery
1611+ Copyright (C) 2011-2013 Linaro Limited
1612+ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1613+
1614+This file is part of libunwind.
1615+
1616+Permission is hereby granted, free of charge, to any person obtaining
1617+a copy of this software and associated documentation files (the
1618+"Software"), to deal in the Software without restriction, including
1619+without limitation the rights to use, copy, modify, merge, publish,
1620+distribute, sublicense, and/or sell copies of the Software, and to
1621+permit persons to whom the Software is furnished to do so, subject to
1622+the following conditions:
1623+
1624+The above copyright notice and this permission notice shall be
1625+included in all copies or substantial portions of the Software.
1626+
1627+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1628+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1629+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1630+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1631+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1632+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1633+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1634+
1635+#include "unwind_i.h"
1636+#include "offsets.h"
1637+
1638+#ifndef UNW_REMOTE_ONLY
1639+
1640+HIDDEN inline int
1641+aarch64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
1642+{
1643+#ifdef __linux__
1644+ struct cursor *c = (struct cursor *) cursor;
1645+ unw_tdep_context_t *uc = c->dwarf.as_arg;
1646+
1647+ if (c->sigcontext_format == AARCH64_SCF_NONE)
1648+ {
1649+ /* Since there are no signals involved here we restore the non scratch
1650+ registers only. */
1651+ unsigned long regs[11];
1652+ regs[0] = uc->uc_mcontext.regs[19];
1653+ regs[1] = uc->uc_mcontext.regs[20];
1654+ regs[2] = uc->uc_mcontext.regs[21];
1655+ regs[3] = uc->uc_mcontext.regs[22];
1656+ regs[4] = uc->uc_mcontext.regs[23];
1657+ regs[5] = uc->uc_mcontext.regs[24];
1658+ regs[6] = uc->uc_mcontext.regs[25];
1659+ regs[7] = uc->uc_mcontext.regs[26];
1660+ regs[8] = uc->uc_mcontext.regs[27];
1661+ regs[9] = uc->uc_mcontext.regs[28];
1662+ regs[10] = uc->uc_mcontext.regs[30]; /* LR */
1663+ unsigned long sp = uc->uc_mcontext.sp;
1664+
1665+ struct regs_overlay {
1666+ char x[sizeof(regs)];
1667+ };
1668+
1669+ asm volatile (
1670+ "ldp x19, x20, [%0]\n"
1671+ "ldp x21, x22, [%0,16]\n"
1672+ "ldp x23, x24, [%0,32]\n"
1673+ "ldp x25, x26, [%0,48]\n"
1674+ "ldp x27, x28, [%0,64]\n"
1675+ "ldr x30, [%0,80]\n"
1676+ "mov sp, %1\n"
1677+ "ret \n"
1678+ :
1679+ : "r" (regs),
1680+ "r" (sp),
1681+ "m" (*(struct regs_overlay *)regs)
1682+ );
1683+ }
1684+ else
1685+ {
1686+ struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr;
1687+
1688+ if (c->dwarf.eh_valid_mask & 0x1) sc->regs[0] = c->dwarf.eh_args[0];
1689+ if (c->dwarf.eh_valid_mask & 0x2) sc->regs[1] = c->dwarf.eh_args[1];
1690+ if (c->dwarf.eh_valid_mask & 0x4) sc->regs[2] = c->dwarf.eh_args[2];
1691+ if (c->dwarf.eh_valid_mask & 0x8) sc->regs[3] = c->dwarf.eh_args[3];
1692+
1693+ sc->regs[4] = uc->uc_mcontext.regs[4];
1694+ sc->regs[5] = uc->uc_mcontext.regs[5];
1695+ sc->regs[6] = uc->uc_mcontext.regs[6];
1696+ sc->regs[7] = uc->uc_mcontext.regs[7];
1697+ sc->regs[8] = uc->uc_mcontext.regs[8];
1698+ sc->regs[9] = uc->uc_mcontext.regs[9];
1699+ sc->regs[10] = uc->uc_mcontext.regs[10];
1700+ sc->regs[11] = uc->uc_mcontext.regs[11];
1701+ sc->regs[12] = uc->uc_mcontext.regs[12];
1702+ sc->regs[13] = uc->uc_mcontext.regs[13];
1703+ sc->regs[14] = uc->uc_mcontext.regs[14];
1704+ sc->regs[15] = uc->uc_mcontext.regs[15];
1705+ sc->regs[16] = uc->uc_mcontext.regs[16];
1706+ sc->regs[17] = uc->uc_mcontext.regs[17];
1707+ sc->regs[18] = uc->uc_mcontext.regs[18];
1708+ sc->regs[19] = uc->uc_mcontext.regs[19];
1709+ sc->regs[20] = uc->uc_mcontext.regs[20];
1710+ sc->regs[21] = uc->uc_mcontext.regs[21];
1711+ sc->regs[22] = uc->uc_mcontext.regs[22];
1712+ sc->regs[23] = uc->uc_mcontext.regs[23];
1713+ sc->regs[24] = uc->uc_mcontext.regs[24];
1714+ sc->regs[25] = uc->uc_mcontext.regs[25];
1715+ sc->regs[26] = uc->uc_mcontext.regs[26];
1716+ sc->regs[27] = uc->uc_mcontext.regs[27];
1717+ sc->regs[28] = uc->uc_mcontext.regs[28];
1718+ sc->regs[29] = uc->uc_mcontext.regs[29];
1719+ sc->regs[30] = uc->uc_mcontext.regs[30];
1720+ sc->sp = uc->uc_mcontext.sp;
1721+ sc->pc = uc->uc_mcontext.pc;
1722+ sc->pstate = uc->uc_mcontext.pstate;
1723+
1724+ asm volatile (
1725+ "mov sp, %0\n"
1726+ "ret %1\n"
1727+ : : "r" (c->sigcontext_sp), "r" (c->sigcontext_pc)
1728+ );
1729+ }
1730+ unreachable();
1731+#else
1732+ printf ("%s: implement me\n", __FUNCTION__);
1733+#endif
1734+ return -UNW_EINVAL;
1735+}
1736+
1737+#endif /* !UNW_REMOTE_ONLY */
1738+
1739+static inline void
1740+establish_machine_state (struct cursor *c)
1741+{
1742+ unw_addr_space_t as = c->dwarf.as;
1743+ void *arg = c->dwarf.as_arg;
1744+ unw_fpreg_t fpval;
1745+ unw_word_t val;
1746+ int reg;
1747+
1748+ Debug (8, "copying out cursor state\n");
1749+
1750+ for (reg = 0; reg <= UNW_AARCH64_PSTATE; ++reg)
1751+ {
1752+ Debug (16, "copying %s %d\n", unw_regname (reg), reg);
1753+ if (unw_is_fpreg (reg))
1754+ {
1755+ if (tdep_access_fpreg (c, reg, &fpval, 0) >= 0)
1756+ as->acc.access_fpreg (as, reg, &fpval, 1, arg);
1757+ }
1758+ else
1759+ {
1760+ if (tdep_access_reg (c, reg, &val, 0) >= 0)
1761+ as->acc.access_reg (as, reg, &val, 1, arg);
1762+ }
1763+ }
1764+}
1765+
1766+PROTECTED int
1767+unw_resume (unw_cursor_t *cursor)
1768+{
1769+ struct cursor *c = (struct cursor *) cursor;
1770+
1771+ Debug (1, "(cursor=%p)\n", c);
1772+
1773+ if (!c->dwarf.ip)
1774+ {
1775+ /* This can happen easily when the frame-chain gets truncated
1776+ due to bad or missing unwind-info. */
1777+ Debug (1, "refusing to resume execution at address 0\n");
1778+ return -UNW_EINVAL;
1779+ }
1780+
1781+ establish_machine_state (c);
1782+
1783+ return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c,
1784+ c->dwarf.as_arg);
1785+}
1786--- /dev/null
1787+++ b/src/aarch64/Gstep.c
1788@@ -0,0 +1,129 @@
1789+/* libunwind - a platform-independent unwind library
1790+ Copyright (C) 2008 CodeSourcery
1791+ Copyright (C) 2011-2013 Linaro Limited
1792+ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1793+
1794+This file is part of libunwind.
1795+
1796+Permission is hereby granted, free of charge, to any person obtaining
1797+a copy of this software and associated documentation files (the
1798+"Software"), to deal in the Software without restriction, including
1799+without limitation the rights to use, copy, modify, merge, publish,
1800+distribute, sublicense, and/or sell copies of the Software, and to
1801+permit persons to whom the Software is furnished to do so, subject to
1802+the following conditions:
1803+
1804+The above copyright notice and this permission notice shall be
1805+included in all copies or substantial portions of the Software.
1806+
1807+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1808+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1809+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1810+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1811+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1812+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1813+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1814+
1815+#include "unwind_i.h"
1816+#include "offsets.h"
1817+
1818+PROTECTED int
1819+unw_handle_signal_frame (unw_cursor_t *cursor)
1820+{
1821+ struct cursor *c = (struct cursor *) cursor;
1822+ int ret;
1823+ unw_word_t sc_addr, sp, sp_addr = c->dwarf.cfa;
1824+ struct dwarf_loc sp_loc = DWARF_LOC (sp_addr, 0);
1825+
1826+ if ((ret = dwarf_get (&c->dwarf, sp_loc, &sp)) < 0)
1827+ return -UNW_EUNSPEC;
1828+
1829+ ret = unw_is_signal_frame (cursor);
1830+ Debug(1, "unw_is_signal_frame()=%d\n", ret);
1831+
1832+ /* Save the SP and PC to be able to return execution at this point
1833+ later in time (unw_resume). */
1834+ c->sigcontext_sp = c->dwarf.cfa;
1835+ c->sigcontext_pc = c->dwarf.ip;
1836+
1837+ if (ret)
1838+ {
1839+ c->sigcontext_format = AARCH64_SCF_LINUX_RT_SIGFRAME;
1840+ sc_addr = sp_addr + sizeof (siginfo_t) + LINUX_UC_MCONTEXT_OFF;
1841+ }
1842+ else
1843+ return -UNW_EUNSPEC;
1844+
1845+ c->sigcontext_addr = sc_addr;
1846+
1847+ /* Update the dwarf cursor.
1848+ Set the location of the registers to the corresponding addresses of the
1849+ uc_mcontext / sigcontext structure contents. */
1850+ c->dwarf.loc[UNW_AARCH64_X0] = DWARF_LOC (sc_addr + LINUX_SC_X0_OFF, 0);
1851+ c->dwarf.loc[UNW_AARCH64_X1] = DWARF_LOC (sc_addr + LINUX_SC_X1_OFF, 0);
1852+ c->dwarf.loc[UNW_AARCH64_X2] = DWARF_LOC (sc_addr + LINUX_SC_X2_OFF, 0);
1853+ c->dwarf.loc[UNW_AARCH64_X3] = DWARF_LOC (sc_addr + LINUX_SC_X3_OFF, 0);
1854+ c->dwarf.loc[UNW_AARCH64_X4] = DWARF_LOC (sc_addr + LINUX_SC_X4_OFF, 0);
1855+ c->dwarf.loc[UNW_AARCH64_X5] = DWARF_LOC (sc_addr + LINUX_SC_X5_OFF, 0);
1856+ c->dwarf.loc[UNW_AARCH64_X6] = DWARF_LOC (sc_addr + LINUX_SC_X6_OFF, 0);
1857+ c->dwarf.loc[UNW_AARCH64_X7] = DWARF_LOC (sc_addr + LINUX_SC_X7_OFF, 0);
1858+ c->dwarf.loc[UNW_AARCH64_X8] = DWARF_LOC (sc_addr + LINUX_SC_X8_OFF, 0);
1859+ c->dwarf.loc[UNW_AARCH64_X9] = DWARF_LOC (sc_addr + LINUX_SC_X9_OFF, 0);
1860+ c->dwarf.loc[UNW_AARCH64_X10] = DWARF_LOC (sc_addr + LINUX_SC_X10_OFF, 0);
1861+ c->dwarf.loc[UNW_AARCH64_X11] = DWARF_LOC (sc_addr + LINUX_SC_X11_OFF, 0);
1862+ c->dwarf.loc[UNW_AARCH64_X12] = DWARF_LOC (sc_addr + LINUX_SC_X12_OFF, 0);
1863+ c->dwarf.loc[UNW_AARCH64_X13] = DWARF_LOC (sc_addr + LINUX_SC_X13_OFF, 0);
1864+ c->dwarf.loc[UNW_AARCH64_X14] = DWARF_LOC (sc_addr + LINUX_SC_X14_OFF, 0);
1865+ c->dwarf.loc[UNW_AARCH64_X15] = DWARF_LOC (sc_addr + LINUX_SC_X15_OFF, 0);
1866+ c->dwarf.loc[UNW_AARCH64_X16] = DWARF_LOC (sc_addr + LINUX_SC_X16_OFF, 0);
1867+ c->dwarf.loc[UNW_AARCH64_X17] = DWARF_LOC (sc_addr + LINUX_SC_X17_OFF, 0);
1868+ c->dwarf.loc[UNW_AARCH64_X18] = DWARF_LOC (sc_addr + LINUX_SC_X18_OFF, 0);
1869+ c->dwarf.loc[UNW_AARCH64_X19] = DWARF_LOC (sc_addr + LINUX_SC_X19_OFF, 0);
1870+ c->dwarf.loc[UNW_AARCH64_X20] = DWARF_LOC (sc_addr + LINUX_SC_X20_OFF, 0);
1871+ c->dwarf.loc[UNW_AARCH64_X21] = DWARF_LOC (sc_addr + LINUX_SC_X21_OFF, 0);
1872+ c->dwarf.loc[UNW_AARCH64_X22] = DWARF_LOC (sc_addr + LINUX_SC_X22_OFF, 0);
1873+ c->dwarf.loc[UNW_AARCH64_X23] = DWARF_LOC (sc_addr + LINUX_SC_X23_OFF, 0);
1874+ c->dwarf.loc[UNW_AARCH64_X24] = DWARF_LOC (sc_addr + LINUX_SC_X24_OFF, 0);
1875+ c->dwarf.loc[UNW_AARCH64_X25] = DWARF_LOC (sc_addr + LINUX_SC_X25_OFF, 0);
1876+ c->dwarf.loc[UNW_AARCH64_X26] = DWARF_LOC (sc_addr + LINUX_SC_X26_OFF, 0);
1877+ c->dwarf.loc[UNW_AARCH64_X27] = DWARF_LOC (sc_addr + LINUX_SC_X27_OFF, 0);
1878+ c->dwarf.loc[UNW_AARCH64_X28] = DWARF_LOC (sc_addr + LINUX_SC_X28_OFF, 0);
1879+ c->dwarf.loc[UNW_AARCH64_X29] = DWARF_LOC (sc_addr + LINUX_SC_X29_OFF, 0);
1880+ c->dwarf.loc[UNW_AARCH64_X30] = DWARF_LOC (sc_addr + LINUX_SC_X30_OFF, 0);
1881+ c->dwarf.loc[UNW_AARCH64_SP] = DWARF_LOC (sc_addr + LINUX_SC_SP_OFF, 0);
1882+ c->dwarf.loc[UNW_AARCH64_PC] = DWARF_LOC (sc_addr + LINUX_SC_PC_OFF, 0);
1883+ c->dwarf.loc[UNW_AARCH64_PSTATE] = DWARF_LOC (sc_addr + LINUX_SC_PSTATE_OFF, 0);
1884+
1885+ /* Set SP/CFA and PC/IP. */
1886+ dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_SP], &c->dwarf.cfa);
1887+ dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_PC], &c->dwarf.ip);
1888+
1889+ c->dwarf.pi_valid = 0;
1890+
1891+ return 1;
1892+}
1893+
1894+PROTECTED int
1895+unw_step (unw_cursor_t *cursor)
1896+{
1897+ struct cursor *c = (struct cursor *) cursor;
1898+ int ret;
1899+
1900+ Debug (1, "(cursor=%p, ip=0x%016lx, cfa=0x%016lx))\n",
1901+ c, c->dwarf.ip, c->dwarf.cfa);
1902+
1903+ /* Check if this is a signal frame. */
1904+ if (unw_is_signal_frame (cursor))
1905+ return unw_handle_signal_frame (cursor);
1906+
1907+ ret = dwarf_step (&c->dwarf);
1908+ Debug(1, "dwarf_step()=%d\n", ret);
1909+
1910+ if (unlikely (ret == -UNW_ESTOPUNWIND))
1911+ return ret;
1912+
1913+ if (unlikely (ret < 0))
1914+ return 0;
1915+
1916+ return (c->dwarf.ip == 0) ? 0 : 1;
1917+}
1918--- /dev/null
1919+++ b/src/aarch64/Lcreate_addr_space.c
1920@@ -0,0 +1,5 @@
1921+#define UNW_LOCAL_ONLY
1922+#include <libunwind.h>
1923+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1924+#include "Gcreate_addr_space.c"
1925+#endif
1926--- /dev/null
1927+++ b/src/aarch64/Lget_proc_info.c
1928@@ -0,0 +1,5 @@
1929+#define UNW_LOCAL_ONLY
1930+#include <libunwind.h>
1931+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1932+#include "Gget_proc_info.c"
1933+#endif
1934--- /dev/null
1935+++ b/src/aarch64/Lget_save_loc.c
1936@@ -0,0 +1,5 @@
1937+#define UNW_LOCAL_ONLY
1938+#include <libunwind.h>
1939+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1940+#include "Gget_save_loc.c"
1941+#endif
1942--- /dev/null
1943+++ b/src/aarch64/Lglobal.c
1944@@ -0,0 +1,5 @@
1945+#define UNW_LOCAL_ONLY
1946+#include <libunwind.h>
1947+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1948+#include "Gglobal.c"
1949+#endif
1950--- /dev/null
1951+++ b/src/aarch64/Linit.c
1952@@ -0,0 +1,5 @@
1953+#define UNW_LOCAL_ONLY
1954+#include <libunwind.h>
1955+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1956+#include "Ginit.c"
1957+#endif
1958--- /dev/null
1959+++ b/src/aarch64/Linit_local.c
1960@@ -0,0 +1,5 @@
1961+#define UNW_LOCAL_ONLY
1962+#include <libunwind.h>
1963+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1964+#include "Ginit_local.c"
1965+#endif
1966--- /dev/null
1967+++ b/src/aarch64/Linit_remote.c
1968@@ -0,0 +1,5 @@
1969+#define UNW_LOCAL_ONLY
1970+#include <libunwind.h>
1971+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1972+#include "Ginit_remote.c"
1973+#endif
1974--- /dev/null
1975+++ b/src/aarch64/Lis_signal_frame.c
1976@@ -0,0 +1,5 @@
1977+#define UNW_LOCAL_ONLY
1978+#include <libunwind.h>
1979+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1980+#include "Gis_signal_frame.c"
1981+#endif
1982--- /dev/null
1983+++ b/src/aarch64/Lregs.c
1984@@ -0,0 +1,5 @@
1985+#define UNW_LOCAL_ONLY
1986+#include <libunwind.h>
1987+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1988+#include "Gregs.c"
1989+#endif
1990--- /dev/null
1991+++ b/src/aarch64/Lresume.c
1992@@ -0,0 +1,5 @@
1993+#define UNW_LOCAL_ONLY
1994+#include <libunwind.h>
1995+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1996+#include "Gresume.c"
1997+#endif
1998--- /dev/null
1999+++ b/src/aarch64/Lstep.c
2000@@ -0,0 +1,5 @@
2001+#define UNW_LOCAL_ONLY
2002+#include <libunwind.h>
2003+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
2004+#include "Gstep.c"
2005+#endif
2006--- /dev/null
2007+++ b/src/aarch64/gen-offsets.c
2008@@ -0,0 +1,68 @@
2009+#include <stdio.h>
2010+#include <stddef.h>
2011+#include <ucontext.h>
2012+#include <asm/sigcontext.h>
2013+
2014+#define UC(N,X) \
2015+ printf ("#define LINUX_UC_" N "_OFF\t0x%X\n", offsetof (ucontext_t, X))
2016+
2017+#define SC(N,X) \
2018+ printf ("#define LINUX_SC_" N "_OFF\t0x%X\n", offsetof (struct sigcontext, X))
2019+
2020+int
2021+main (void)
2022+{
2023+ printf (
2024+"/* Linux-specific definitions: */\n\n"
2025+
2026+"/* Define various structure offsets to simplify cross-compilation. */\n\n"
2027+
2028+"/* Offsets for AArch64 Linux \"ucontext_t\": */\n\n");
2029+
2030+ UC ("FLAGS", uc_flags);
2031+ UC ("LINK", uc_link);
2032+ UC ("STACK", uc_stack);
2033+ UC ("MCONTEXT", uc_mcontext);
2034+ UC ("SIGMASK", uc_sigmask);
2035+
2036+ printf ("\n/* Offsets for AArch64 Linux \"struct sigcontext\": */\n\n");
2037+
2038+ SC ("R0", regs[0]);
2039+ SC ("R1", regs[1]);
2040+ SC ("R2", regs[2]);
2041+ SC ("R3", regs[3]);
2042+ SC ("R4", regs[4]);
2043+ SC ("R5", regs[5]);
2044+ SC ("R6", regs[6]);
2045+ SC ("R7", regs[7]);
2046+ SC ("R8", regs[8]);
2047+ SC ("R9", regs[9]);
2048+ SC ("R10", regs[10]);
2049+ SC ("R11", regs[11]);
2050+ SC ("R12", regs[12]);
2051+ SC ("R13", regs[13]);
2052+ SC ("R14", regs[14]);
2053+ SC ("R15", regs[15]);
2054+ SC ("R16", regs[16]);
2055+ SC ("R17", regs[17]);
2056+ SC ("R18", regs[18]);
2057+ SC ("R19", regs[19]);
2058+ SC ("R20", regs[20]);
2059+ SC ("R21", regs[21]);
2060+ SC ("R22", regs[22]);
2061+ SC ("R23", regs[23]);
2062+ SC ("R24", regs[24]);
2063+ SC ("R25", regs[25]);
2064+ SC ("R26", regs[26]);
2065+ SC ("R27", regs[27]);
2066+ SC ("R28", regs[28]);
2067+ SC ("R29", regs[29]);
2068+ SC ("R30", regs[30]);
2069+ SC ("R31", regs[31]);
2070+
2071+ SC ("PC", pc);
2072+ SC ("SP", sp);
2073+ SC ("Fault", fault_address);
2074+ SC ("state", pstate);
2075+ return 0;
2076+}
2077--- /dev/null
2078+++ b/src/aarch64/init.h
2079@@ -0,0 +1,127 @@
2080+/* libunwind - a platform-independent unwind library
2081+ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
2082+ Copyright (C) 2013 Linaro Limited
2083+
2084+This file is part of libunwind.
2085+
2086+Permission is hereby granted, free of charge, to any person obtaining
2087+a copy of this software and associated documentation files (the
2088+"Software"), to deal in the Software without restriction, including
2089+without limitation the rights to use, copy, modify, merge, publish,
2090+distribute, sublicense, and/or sell copies of the Software, and to
2091+permit persons to whom the Software is furnished to do so, subject to
2092+the following conditions:
2093+
2094+The above copyright notice and this permission notice shall be
2095+included in all copies or substantial portions of the Software.
2096+
2097+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2098+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2099+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2100+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2101+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2102+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2103+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2104+
2105+#include "unwind_i.h"
2106+
2107+static inline int
2108+common_init (struct cursor *c, unsigned use_prev_instr)
2109+{
2110+ int ret, i;
2111+
2112+ c->dwarf.loc[UNW_AARCH64_X0] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X0);
2113+ c->dwarf.loc[UNW_AARCH64_X1] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X1);
2114+ c->dwarf.loc[UNW_AARCH64_X2] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X2);
2115+ c->dwarf.loc[UNW_AARCH64_X3] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X3);
2116+ c->dwarf.loc[UNW_AARCH64_X4] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X4);
2117+ c->dwarf.loc[UNW_AARCH64_X5] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X5);
2118+ c->dwarf.loc[UNW_AARCH64_X6] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X6);
2119+ c->dwarf.loc[UNW_AARCH64_X7] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X7);
2120+ c->dwarf.loc[UNW_AARCH64_X8] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X8);
2121+ c->dwarf.loc[UNW_AARCH64_X9] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X9);
2122+ c->dwarf.loc[UNW_AARCH64_X10] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X10);
2123+ c->dwarf.loc[UNW_AARCH64_X11] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X11);
2124+ c->dwarf.loc[UNW_AARCH64_X12] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X12);
2125+ c->dwarf.loc[UNW_AARCH64_X13] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X13);
2126+ c->dwarf.loc[UNW_AARCH64_X14] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X14);
2127+ c->dwarf.loc[UNW_AARCH64_X15] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X15);
2128+ c->dwarf.loc[UNW_AARCH64_X16] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X16);
2129+ c->dwarf.loc[UNW_AARCH64_X17] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X17);
2130+ c->dwarf.loc[UNW_AARCH64_X18] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X18);
2131+ c->dwarf.loc[UNW_AARCH64_X19] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X19);
2132+ c->dwarf.loc[UNW_AARCH64_X20] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X20);
2133+ c->dwarf.loc[UNW_AARCH64_X21] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X21);
2134+ c->dwarf.loc[UNW_AARCH64_X22] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X22);
2135+ c->dwarf.loc[UNW_AARCH64_X23] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X23);
2136+ c->dwarf.loc[UNW_AARCH64_X24] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X24);
2137+ c->dwarf.loc[UNW_AARCH64_X25] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X25);
2138+ c->dwarf.loc[UNW_AARCH64_X26] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X26);
2139+ c->dwarf.loc[UNW_AARCH64_X27] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X27);
2140+ c->dwarf.loc[UNW_AARCH64_X28] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X28);
2141+ c->dwarf.loc[UNW_AARCH64_X29] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X29);
2142+ c->dwarf.loc[UNW_AARCH64_X30] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X30);
2143+ c->dwarf.loc[UNW_AARCH64_SP] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_SP);
2144+ c->dwarf.loc[UNW_AARCH64_PC] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_PC);
2145+ c->dwarf.loc[UNW_AARCH64_PSTATE] = DWARF_REG_LOC (&c->dwarf,
2146+ UNW_AARCH64_PSTATE);
2147+ c->dwarf.loc[UNW_AARCH64_V0] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V0);
2148+ c->dwarf.loc[UNW_AARCH64_V1] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V1);
2149+ c->dwarf.loc[UNW_AARCH64_V2] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V2);
2150+ c->dwarf.loc[UNW_AARCH64_V3] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V3);
2151+ c->dwarf.loc[UNW_AARCH64_V4] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V4);
2152+ c->dwarf.loc[UNW_AARCH64_V5] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V5);
2153+ c->dwarf.loc[UNW_AARCH64_V6] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V6);
2154+ c->dwarf.loc[UNW_AARCH64_V7] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V7);
2155+ c->dwarf.loc[UNW_AARCH64_V8] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V8);
2156+ c->dwarf.loc[UNW_AARCH64_V9] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V9);
2157+ c->dwarf.loc[UNW_AARCH64_V10] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V10);
2158+ c->dwarf.loc[UNW_AARCH64_V11] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V11);
2159+ c->dwarf.loc[UNW_AARCH64_V12] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V12);
2160+ c->dwarf.loc[UNW_AARCH64_V13] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V13);
2161+ c->dwarf.loc[UNW_AARCH64_V14] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V14);
2162+ c->dwarf.loc[UNW_AARCH64_V15] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V15);
2163+ c->dwarf.loc[UNW_AARCH64_V16] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V16);
2164+ c->dwarf.loc[UNW_AARCH64_V17] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V17);
2165+ c->dwarf.loc[UNW_AARCH64_V18] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V18);
2166+ c->dwarf.loc[UNW_AARCH64_V19] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V19);
2167+ c->dwarf.loc[UNW_AARCH64_V20] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V20);
2168+ c->dwarf.loc[UNW_AARCH64_V21] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V21);
2169+ c->dwarf.loc[UNW_AARCH64_V22] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V22);
2170+ c->dwarf.loc[UNW_AARCH64_V23] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V23);
2171+ c->dwarf.loc[UNW_AARCH64_V24] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V24);
2172+ c->dwarf.loc[UNW_AARCH64_V25] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V25);
2173+ c->dwarf.loc[UNW_AARCH64_V26] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V26);
2174+ c->dwarf.loc[UNW_AARCH64_V27] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V27);
2175+ c->dwarf.loc[UNW_AARCH64_V28] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V28);
2176+ c->dwarf.loc[UNW_AARCH64_V29] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V29);
2177+ c->dwarf.loc[UNW_AARCH64_V30] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V30);
2178+ c->dwarf.loc[UNW_AARCH64_V31] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V31);
2179+
2180+ for (i = UNW_AARCH64_PSTATE + 1; i < UNW_AARCH64_V0; ++i)
2181+ c->dwarf.loc[i] = DWARF_NULL_LOC;
2182+
2183+ ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_PC], &c->dwarf.ip);
2184+ if (ret < 0)
2185+ return ret;
2186+
2187+ ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_SP], &c->dwarf.cfa);
2188+ if (ret < 0)
2189+ return ret;
2190+
2191+ c->sigcontext_format = AARCH64_SCF_NONE;
2192+ c->sigcontext_addr = 0;
2193+ c->sigcontext_sp = 0;
2194+ c->sigcontext_pc = 0;
2195+
2196+ c->dwarf.args_size = 0;
2197+ c->dwarf.ret_addr_column = 0;
2198+ c->dwarf.stash_frames = 0;
2199+ c->dwarf.use_prev_instr = use_prev_instr;
2200+ c->dwarf.pi_valid = 0;
2201+ c->dwarf.pi_is_dynamic = 0;
2202+ c->dwarf.hint = 0;
2203+ c->dwarf.prev_rs = 0;
2204+
2205+ return 0;
2206+}
2207--- /dev/null
2208+++ b/src/aarch64/is_fpreg.c
2209@@ -0,0 +1,32 @@
2210+/* libunwind - a platform-independent unwind library
2211+ Copyright (C) 2008 CodeSourcery
2212+ Copyright (C) 2013 Linaro Limited
2213+
2214+This file is part of libunwind.
2215+
2216+Permission is hereby granted, free of charge, to any person obtaining
2217+a copy of this software and associated documentation files (the
2218+"Software"), to deal in the Software without restriction, including
2219+without limitation the rights to use, copy, modify, merge, publish,
2220+distribute, sublicense, and/or sell copies of the Software, and to
2221+permit persons to whom the Software is furnished to do so, subject to
2222+the following conditions:
2223+
2224+The above copyright notice and this permission notice shall be
2225+included in all copies or substantial portions of the Software.
2226+
2227+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2228+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2229+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2230+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2231+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2232+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2233+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2234+
2235+#include "libunwind_i.h"
2236+
2237+PROTECTED int
2238+unw_is_fpreg (int regnum)
2239+{
2240+ return (regnum >= UNW_AARCH64_V0 && regnum <= UNW_AARCH64_V31);
2241+}
2242--- /dev/null
2243+++ b/src/aarch64/offsets.h
2244@@ -0,0 +1,49 @@
2245+/* Linux-specific definitions: */
2246+
2247+/* Define various structure offsets to simplify cross-compilation. */
2248+
2249+/* Offsets for AArch64 Linux "ucontext_t": */
2250+
2251+#define LINUX_UC_FLAGS_OFF 0x0
2252+#define LINUX_UC_LINK_OFF 0x8
2253+#define LINUX_UC_STACK_OFF 0x10
2254+#define LINUX_UC_SIGMASK_OFF 0x28
2255+#define LINUX_UC_MCONTEXT_OFF 0xb0
2256+
2257+/* Offsets for AArch64 Linux "struct sigcontext": */
2258+
2259+#define LINUX_SC_FAULTADDRESS_OFF 0x00
2260+#define LINUX_SC_X0_OFF 0x008
2261+#define LINUX_SC_X1_OFF 0x010
2262+#define LINUX_SC_X2_OFF 0x018
2263+#define LINUX_SC_X3_OFF 0x020
2264+#define LINUX_SC_X4_OFF 0x028
2265+#define LINUX_SC_X5_OFF 0x030
2266+#define LINUX_SC_X6_OFF 0x038
2267+#define LINUX_SC_X7_OFF 0x040
2268+#define LINUX_SC_X8_OFF 0x048
2269+#define LINUX_SC_X9_OFF 0x050
2270+#define LINUX_SC_X10_OFF 0x058
2271+#define LINUX_SC_X11_OFF 0x060
2272+#define LINUX_SC_X12_OFF 0x068
2273+#define LINUX_SC_X13_OFF 0x070
2274+#define LINUX_SC_X14_OFF 0x078
2275+#define LINUX_SC_X15_OFF 0x080
2276+#define LINUX_SC_X16_OFF 0x088
2277+#define LINUX_SC_X17_OFF 0x090
2278+#define LINUX_SC_X18_OFF 0x098
2279+#define LINUX_SC_X19_OFF 0x0a0
2280+#define LINUX_SC_X20_OFF 0x0a8
2281+#define LINUX_SC_X21_OFF 0x0b0
2282+#define LINUX_SC_X22_OFF 0x0b8
2283+#define LINUX_SC_X23_OFF 0x0c0
2284+#define LINUX_SC_X24_OFF 0x0c8
2285+#define LINUX_SC_X25_OFF 0x0d0
2286+#define LINUX_SC_X26_OFF 0x0d8
2287+#define LINUX_SC_X27_OFF 0x0e0
2288+#define LINUX_SC_X28_OFF 0x0e8
2289+#define LINUX_SC_X29_OFF 0x0f0
2290+#define LINUX_SC_X30_OFF 0x0f8
2291+#define LINUX_SC_SP_OFF 0x100
2292+#define LINUX_SC_PC_OFF 0x108
2293+#define LINUX_SC_PSTATE_OFF 0x110
2294--- /dev/null
2295+++ b/src/aarch64/regname.c
2296@@ -0,0 +1,106 @@
2297+/* libunwind - a platform-independent unwind library
2298+ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
2299+ Copyright (C) 2013 Linaro Limited
2300+
2301+This file is part of libunwind.
2302+
2303+Permission is hereby granted, free of charge, to any person obtaining
2304+a copy of this software and associated documentation files (the
2305+"Software"), to deal in the Software without restriction, including
2306+without limitation the rights to use, copy, modify, merge, publish,
2307+distribute, sublicense, and/or sell copies of the Software, and to
2308+permit persons to whom the Software is furnished to do so, subject to
2309+the following conditions:
2310+
2311+The above copyright notice and this permission notice shall be
2312+included in all copies or substantial portions of the Software.
2313+
2314+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2315+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2316+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2317+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2318+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2319+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2320+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2321+
2322+#include "unwind_i.h"
2323+
2324+static const char *const regname[] =
2325+ {
2326+ [UNW_AARCH64_X0] = "x0",
2327+ [UNW_AARCH64_X1] = "x1",
2328+ [UNW_AARCH64_X2] = "x2",
2329+ [UNW_AARCH64_X3] = "x3",
2330+ [UNW_AARCH64_X4] = "x4",
2331+ [UNW_AARCH64_X5] = "x5",
2332+ [UNW_AARCH64_X6] = "x6",
2333+ [UNW_AARCH64_X7] = "x7",
2334+ [UNW_AARCH64_X8] = "x8",
2335+ [UNW_AARCH64_X9] = "x9",
2336+ [UNW_AARCH64_X10] = "x10",
2337+ [UNW_AARCH64_X11] = "x11",
2338+ [UNW_AARCH64_X12] = "x12",
2339+ [UNW_AARCH64_X13] = "x13",
2340+ [UNW_AARCH64_X14] = "x14",
2341+ [UNW_AARCH64_X15] = "x15",
2342+ [UNW_AARCH64_X16] = "ip0",
2343+ [UNW_AARCH64_X17] = "ip1",
2344+ [UNW_AARCH64_X18] = "x18",
2345+ [UNW_AARCH64_X19] = "x19",
2346+ [UNW_AARCH64_X20] = "x20",
2347+ [UNW_AARCH64_X21] = "x21",
2348+ [UNW_AARCH64_X22] = "x22",
2349+ [UNW_AARCH64_X23] = "x23",
2350+ [UNW_AARCH64_X24] = "x24",
2351+ [UNW_AARCH64_X25] = "x25",
2352+ [UNW_AARCH64_X26] = "x26",
2353+ [UNW_AARCH64_X27] = "x27",
2354+ [UNW_AARCH64_X28] = "x28",
2355+ [UNW_AARCH64_X29] = "fp",
2356+ [UNW_AARCH64_X30] = "lr",
2357+ [UNW_AARCH64_SP] = "sp",
2358+ [UNW_AARCH64_PC] = "pc",
2359+ [UNW_AARCH64_V0] = "v0",
2360+ [UNW_AARCH64_V1] = "v1",
2361+ [UNW_AARCH64_V2] = "v2",
2362+ [UNW_AARCH64_V3] = "v3",
2363+ [UNW_AARCH64_V4] = "v4",
2364+ [UNW_AARCH64_V5] = "v5",
2365+ [UNW_AARCH64_V6] = "v6",
2366+ [UNW_AARCH64_V7] = "v7",
2367+ [UNW_AARCH64_V8] = "v8",
2368+ [UNW_AARCH64_V9] = "v9",
2369+ [UNW_AARCH64_V10] = "v10",
2370+ [UNW_AARCH64_V11] = "v11",
2371+ [UNW_AARCH64_V12] = "v12",
2372+ [UNW_AARCH64_V13] = "v13",
2373+ [UNW_AARCH64_V14] = "v14",
2374+ [UNW_AARCH64_V15] = "v15",
2375+ [UNW_AARCH64_V16] = "v16",
2376+ [UNW_AARCH64_V17] = "v17",
2377+ [UNW_AARCH64_V18] = "v18",
2378+ [UNW_AARCH64_V19] = "v19",
2379+ [UNW_AARCH64_V20] = "v20",
2380+ [UNW_AARCH64_V21] = "v21",
2381+ [UNW_AARCH64_V22] = "v22",
2382+ [UNW_AARCH64_V23] = "v23",
2383+ [UNW_AARCH64_V24] = "v24",
2384+ [UNW_AARCH64_V25] = "v25",
2385+ [UNW_AARCH64_V26] = "v26",
2386+ [UNW_AARCH64_V27] = "v27",
2387+ [UNW_AARCH64_V28] = "v28",
2388+ [UNW_AARCH64_V29] = "v29",
2389+ [UNW_AARCH64_V30] = "v30",
2390+ [UNW_AARCH64_V31] = "v31",
2391+ [UNW_AARCH64_FPSR] = "fpsr",
2392+ [UNW_AARCH64_FPCR] = "fpcr",
2393+ };
2394+
2395+PROTECTED const char *
2396+unw_regname (unw_regnum_t reg)
2397+{
2398+ if (reg < (unw_regnum_t) ARRAY_SIZE (regname) && regname[reg] != NULL)
2399+ return regname[reg];
2400+ else
2401+ return "???";
2402+}
2403--- /dev/null
2404+++ b/src/aarch64/siglongjmp.S
2405@@ -0,0 +1,12 @@
2406+ /* Dummy implementation for now. */
2407+
2408+ .global _UI_siglongjmp_cont
2409+ .global _UI_longjmp_cont
2410+
2411+_UI_siglongjmp_cont:
2412+_UI_longjmp_cont:
2413+ ret
2414+#ifdef __linux__
2415+ /* We do not need executable stack. */
2416+ .section .note.GNU-stack,"",%progbits
2417+#endif
2418--- /dev/null
2419+++ b/src/aarch64/unwind_i.h
2420@@ -0,0 +1,43 @@
2421+/* libunwind - a platform-independent unwind library
2422+ Copyright (C) 2008 CodeSourcery
2423+ Copyright (C) 2013 Linaro Limited
2424+
2425+This file is part of libunwind.
2426+
2427+Permission is hereby granted, free of charge, to any person obtaining
2428+a copy of this software and associated documentation files (the
2429+"Software"), to deal in the Software without restriction, including
2430+without limitation the rights to use, copy, modify, merge, publish,
2431+distribute, sublicense, and/or sell copies of the Software, and to
2432+permit persons to whom the Software is furnished to do so, subject to
2433+the following conditions:
2434+
2435+The above copyright notice and this permission notice shall be
2436+included in all copies or substantial portions of the Software.
2437+
2438+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2439+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2440+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2441+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2442+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2443+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2444+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2445+
2446+#ifndef unwind_i_h
2447+#define unwind_i_h
2448+
2449+#include <stdint.h>
2450+
2451+#include <libunwind-aarch64.h>
2452+
2453+#include "libunwind_i.h"
2454+
2455+#define aarch64_lock UNW_OBJ(lock)
2456+#define aarch64_local_resume UNW_OBJ(local_resume)
2457+#define aarch64_local_addr_space_init UNW_OBJ(local_addr_space_init)
2458+
2459+extern void aarch64_local_addr_space_init (void);
2460+extern int aarch64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor,
2461+ void *arg);
2462+
2463+#endif /* unwind_i_h */
2464--- a/src/coredump/_UCD_access_reg_linux.c
2465+++ b/src/coredump/_UCD_access_reg_linux.c
2466@@ -39,7 +39,10 @@ _UCD_access_reg (unw_addr_space_t as,
2467 return -UNW_EINVAL;
2468 }
2469
2470-#if defined(UNW_TARGET_ARM)
2471+#if defined(UNW_TARGET_AARCH64)
2472+ if (regnum < 0 || regnum >= UNW_AARCH64_FPCR)
2473+ goto badreg;
2474+#elif defined(UNW_TARGET_ARM)
2475 if (regnum < 0 || regnum >= 16)
2476 goto badreg;
2477 #elif defined(UNW_TARGET_SH)
2478--- a/src/ptrace/_UPT_reg_offset.c
2479+++ b/src/ptrace/_UPT_reg_offset.c
2480@@ -1,6 +1,7 @@
2481 /* libunwind - a platform-independent unwind library
2482 Copyright (C) 2003-2004 Hewlett-Packard Co
2483 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
2484+ Copyright (C) 2013 Linaro Limited
2485
2486 This file is part of libunwind.
2487
2488@@ -501,6 +502,41 @@ const int _UPT_reg_offset[UNW_REG_LAST +
2489 [UNW_ARM_R15] = 0x3c,
2490 #elif defined(UNW_TARGET_MIPS)
2491 #elif defined(UNW_TARGET_SH)
2492+#elif defined(UNW_TARGET_AARCH64)
2493+ [UNW_AARCH64_X0] = 0x00,
2494+ [UNW_AARCH64_X1] = 0x08,
2495+ [UNW_AARCH64_X2] = 0x10,
2496+ [UNW_AARCH64_X3] = 0x18,
2497+ [UNW_AARCH64_X4] = 0x20,
2498+ [UNW_AARCH64_X5] = 0x28,
2499+ [UNW_AARCH64_X6] = 0x30,
2500+ [UNW_AARCH64_X7] = 0x38,
2501+ [UNW_AARCH64_X8] = 0x40,
2502+ [UNW_AARCH64_X9] = 0x48,
2503+ [UNW_AARCH64_X10] = 0x50,
2504+ [UNW_AARCH64_X11] = 0x58,
2505+ [UNW_AARCH64_X12] = 0x60,
2506+ [UNW_AARCH64_X13] = 0x68,
2507+ [UNW_AARCH64_X14] = 0x70,
2508+ [UNW_AARCH64_X15] = 0x78,
2509+ [UNW_AARCH64_X16] = 0x80,
2510+ [UNW_AARCH64_X17] = 0x88,
2511+ [UNW_AARCH64_X18] = 0x90,
2512+ [UNW_AARCH64_X19] = 0x98,
2513+ [UNW_AARCH64_X20] = 0xa0,
2514+ [UNW_AARCH64_X21] = 0xa8,
2515+ [UNW_AARCH64_X22] = 0xb0,
2516+ [UNW_AARCH64_X23] = 0xb8,
2517+ [UNW_AARCH64_X24] = 0xc0,
2518+ [UNW_AARCH64_X25] = 0xc8,
2519+ [UNW_AARCH64_X26] = 0xd0,
2520+ [UNW_AARCH64_X27] = 0xd8,
2521+ [UNW_AARCH64_X28] = 0xe0,
2522+ [UNW_AARCH64_X29] = 0xe8,
2523+ [UNW_AARCH64_X30] = 0xf0,
2524+ [UNW_AARCH64_SP] = 0xf8,
2525+ [UNW_AARCH64_PC] = 0x100,
2526+ [UNW_AARCH64_PSTATE] = 0x108
2527 #else
2528 # error Fix me.
2529 #endif
diff --git a/meta/recipes-support/libunwind/libunwind-1.1/Support-building-with-older-compilers.patch b/meta/recipes-support/libunwind/libunwind-1.1/Support-building-with-older-compilers.patch
new file mode 100644
index 0000000000..268b702dcb
--- /dev/null
+++ b/meta/recipes-support/libunwind/libunwind-1.1/Support-building-with-older-compilers.patch
@@ -0,0 +1,72 @@
1From 10b064ffe902d5af31bb49bd8e4f03c545f8d462 Mon Sep 17 00:00:00 2001
2From: Ladislav Michl <ladis@linux-mips.org>
3Date: Tue, 13 Nov 2012 11:19:47 +0100
4Subject: [PATCH] Support building with older compilers.
5
6Add a check for __builtin_unreachable.
7
8Upstream-Status: Pending
9---
10 configure.ac | 11 +++++++++++
11 include/libunwind_i.h | 6 ++++++
12 src/arm/Gresume.c | 2 +-
13 src/sh/Gresume.c | 2 +-
14 4 files changed, 19 insertions(+), 2 deletions(-)
15
16--- a/configure.ac
17+++ b/configure.ac
18@@ -285,6 +285,17 @@ if test x$have__builtin___clear_cache =
19 fi
20 AC_MSG_RESULT([$have__builtin___clear_cache])
21
22+AC_MSG_CHECKING([for __builtin_unreachable])
23+AC_LINK_IFELSE(
24+ [AC_LANG_PROGRAM([[]], [[__builtin_unreachable()]])],
25+ [have__builtin_unreachable=yes],
26+ [have__builtin_unreachable=no])
27+if test x$have__builtin_unreachable = xyes; then
28+ AC_DEFINE([HAVE__BUILTIN_UNREACHABLE], [1],
29+ [Defined if __builtin_unreachable() is available])
30+fi
31+AC_MSG_RESULT([$have__builtin_unreachable])
32+
33 AC_MSG_CHECKING([for __sync atomics])
34 AC_LINK_IFELSE(
35 [AC_LANG_PROGRAM([[]], [[
36--- a/include/libunwind_i.h
37+++ b/include/libunwind_i.h
38@@ -72,6 +72,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE
39 # endif
40 #endif
41
42+#if defined(HAVE__BUILTIN_UNREACHABLE)
43+# define unreachable() __builtin_unreachable()
44+#else
45+# define unreachable() do { } while (1)
46+#endif
47+
48 #ifdef DEBUG
49 # define UNW_DEBUG 1
50 #else
51--- a/src/arm/Gresume.c
52+++ b/src/arm/Gresume.c
53@@ -96,7 +96,7 @@ arm_local_resume (unw_addr_space_t as, u
54 : : "r" (c->sigcontext_sp), "r" (c->sigcontext_pc)
55 );
56 }
57- __builtin_unreachable();
58+ unreachable();
59 #else
60 printf ("%s: implement me\n", __FUNCTION__);
61 #endif
62--- a/src/sh/Gresume.c
63+++ b/src/sh/Gresume.c
64@@ -109,7 +109,7 @@ sh_local_resume (unw_addr_space_t as, un
65 "r" (c->sigcontext_pc)
66 );
67 }
68- __builtin_unreachable();
69+ unreachable();
70 #endif
71 return -UNW_EINVAL;
72 }