1 diff --git a/Makefile.am b/Makefile.am
2 index d7278df..e24fe1e 100644
5 @@ -2,6 +2,9 @@ include_HEADERS = include/libunwind-dynamic.h \
6 include/libunwind-ptrace.h \
7 include/libunwind-coredump.h
10 +include_HEADERS += include/libunwind-aarch64.h
13 include_HEADERS += include/libunwind-arm.h
15 @@ -41,6 +44,9 @@ SUBDIRS = src tests doc
16 noinst_HEADERS = include/dwarf.h include/dwarf_i.h include/dwarf-eh.h \
17 include/compiler.h include/libunwind_i.h include/mempool.h \
19 + include/tdep-aarch64/dwarf-config.h \
20 + include/tdep-aarch64/jmpbuf.h \
21 + include/tdep-aarch64/libunwind_i.h \
22 include/tdep-arm/dwarf-config.h include/tdep-arm/ex_tables.h \
23 include/tdep-arm/jmpbuf.h include/tdep-arm/libunwind_i.h \
24 include/tdep-ia64/jmpbuf.h include/tdep-ia64/rse.h \
25 diff --git a/README b/README
26 index 71a631f..511fb0c 100644
29 @@ -9,6 +9,7 @@ several architecture/operating-system combinations:
30 Linux/IA-64: Fully tested and supported.
31 Linux/PARISC: Works well, but C library missing unwind-info.
32 HP-UX/IA-64: Mostly works but known to have some serious limitations.
33 + Linux/AArch64: Newly added.
34 Linux/PPC64: Newly added.
35 Linux/SuperH: Newly added.
36 FreeBSD/i386: Newly added.
37 diff --git a/configure.ac b/configure.ac
38 index cffe19b..096ca7b 100644
41 @@ -104,7 +104,7 @@ SET_ARCH([$target_cpu],[target_arch])
43 AC_ARG_ENABLE(coredump,
44 AS_HELP_STRING([--enable-coredump],[building libunwind-coredump library]),,
45 - [AS_CASE([$host_arch], [arm*|mips*|sh*|x86*], [enable_coredump=yes], [enable_coredump=no])]
46 + [AS_CASE([$host_arch], [aarch64*|arm*|mips*|sh*|x86*], [enable_coredump=yes], [enable_coredump=no])]
49 AC_MSG_CHECKING([if we should build libunwind-coredump])
50 @@ -121,6 +121,7 @@ AC_MSG_RESULT([$target_os])
52 AM_CONDITIONAL(BUILD_COREDUMP, test x$enable_coredump = xyes)
53 AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch)
54 +AM_CONDITIONAL(ARCH_AARCH64, test x$target_arch = xaarch64)
55 AM_CONDITIONAL(ARCH_ARM, test x$target_arch = xarm)
56 AM_CONDITIONAL(ARCH_IA64, test x$target_arch = xia64)
57 AM_CONDITIONAL(ARCH_HPPA, test x$target_arch = xhppa)
58 @@ -137,7 +138,7 @@ AM_CONDITIONAL(OS_FREEBSD, expr x$target_os : xfreebsd >/dev/null)
59 AC_MSG_CHECKING([for ELF helper width])
60 case "${target_arch}" in
61 (arm|hppa|ppc32|x86|sh) use_elf32=yes; AC_MSG_RESULT([32]);;
62 -(ia64|ppc64|x86_64) use_elf64=yes; AC_MSG_RESULT([64]);;
63 +(aarch64|ia64|ppc64|x86_64) use_elf64=yes; AC_MSG_RESULT([64]);;
64 (mips) use_elfxx=yes; AC_MSG_RESULT([xx]);;
65 *) AC_MSG_ERROR([Unknown ELF target: ${target_arch}])
67 @@ -186,6 +187,7 @@ AS_HELP_STRING([--enable-cxx-exceptions],[use libunwind to handle C++ exceptions
68 # C++ exception handling doesn't work too well on x86
70 x86*) enable_cxx_exceptions=no;;
71 + aarch64*) enable_cxx_exceptions=no;;
72 arm*) enable_cxx_exceptions=no;;
73 mips*) enable_cxx_exceptions=no;;
74 *) enable_cxx_exceptions=yes;;
75 diff --git a/include/libunwind-aarch64.h b/include/libunwind-aarch64.h
77 index 0000000..d50da8f
79 +++ b/include/libunwind-aarch64.h
81 +/* libunwind - a platform-independent unwind library
82 + Copyright (C) 2001-2004 Hewlett-Packard Co
83 + Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
84 + Copyright (C) 2013 Linaro Limited
86 +This file is part of libunwind.
88 +Permission is hereby granted, free of charge, to any person obtaining
89 +a copy of this software and associated documentation files (the
90 +"Software"), to deal in the Software without restriction, including
91 +without limitation the rights to use, copy, modify, merge, publish,
92 +distribute, sublicense, and/or sell copies of the Software, and to
93 +permit persons to whom the Software is furnished to do so, subject to
94 +the following conditions:
96 +The above copyright notice and this permission notice shall be
97 +included in all copies or substantial portions of the Software.
99 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
100 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
101 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
102 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
103 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
104 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
105 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
110 +#if defined(__cplusplus) || defined(c_plusplus)
114 +#include <inttypes.h>
116 +#include <ucontext.h>
118 +#define UNW_TARGET aarch64
119 +#define UNW_TARGET_AARCH64 1
121 +#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
123 +/* This needs to be big enough to accommodate "struct cursor", while
124 + leaving some slack for future expansion. Changing this value will
125 + require recompiling all users of this library. Stack allocation is
126 + relatively cheap and unwind-state copying is relatively rare, so we
127 + want to err on making it rather too big than too small. */
129 +#define UNW_TDEP_CURSOR_LEN 4096
131 +typedef uint64_t unw_word_t;
132 +typedef int64_t unw_sword_t;
134 +typedef long double unw_tdep_fpreg_t;
138 + /* no aarch64-specific auxiliary proc-info */
140 +unw_tdep_proc_info_t;
144 + /* 64-bit general registers. */
155 + /* Temporary registers. */
164 + /* Intra-procedure-call temporary registers. */
168 + /* Callee-saved registers. */
181 + /* 64-bit frame pointer. */
184 + /* 64-bit link register. */
187 + /* 64-bit stack pointer. */
188 + UNW_AARCH64_SP = 31,
190 + UNW_AARCH64_PSTATE,
192 + /* 128-bit FP/Advanced SIMD registers. */
193 + UNW_AARCH64_V0 = 64,
229 + /* For AArch64, the CFA is the value of SP (x31) at the call site of the
231 + UNW_AARCH64_CFA = UNW_AARCH64_SP,
233 + UNW_TDEP_LAST_REG = UNW_AARCH64_FPCR,
235 + UNW_TDEP_IP = UNW_AARCH64_X30,
236 + UNW_TDEP_SP = UNW_AARCH64_SP,
237 + UNW_TDEP_EH = UNW_AARCH64_X0,
242 +/* Use R0 through R3 to pass exception handling information. */
243 +#define UNW_TDEP_NUM_EH_REGS 4
245 +typedef struct unw_tdep_save_loc
247 + /* Additional target-dependent info on a save location. */
249 +unw_tdep_save_loc_t;
252 +/* On AArch64, we can directly use ucontext_t as the unwind context. */
253 +typedef ucontext_t unw_tdep_context_t;
255 +#include "libunwind-common.h"
256 +#include "libunwind-dynamic.h"
258 +#define unw_tdep_getcontext(uc) (getcontext (uc), 0)
259 +#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
261 +extern int unw_tdep_is_fpreg (int);
263 +#if defined(__cplusplus) || defined(c_plusplus)
267 +#endif /* LIBUNWIND_H */
268 diff --git a/include/libunwind.h.in b/include/libunwind.h.in
269 index 25c4e3b..64b1457 100644
270 --- a/include/libunwind.h.in
271 +++ b/include/libunwind.h.in
274 #ifndef UNW_REMOTE_ONLY
277 +#if defined __aarch64__
278 +#include "libunwind-aarch64.h"
279 +#elif defined __arm__
280 # include "libunwind-arm.h"
281 #elif defined __hppa__
282 # include "libunwind-hppa.h"
283 diff --git a/include/tdep-aarch64/dwarf-config.h b/include/tdep-aarch64/dwarf-config.h
285 index 0000000..c3bbed5
287 +++ b/include/tdep-aarch64/dwarf-config.h
289 +/* libunwind - a platform-independent unwind library
290 + Copyright (C) 2008 CodeSourcery
291 + Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
292 + Copyright (C) 2013 Linaro Limited
294 +This file is part of libunwind.
296 +Permission is hereby granted, free of charge, to any person obtaining
297 +a copy of this software and associated documentation files (the
298 +"Software"), to deal in the Software without restriction, including
299 +without limitation the rights to use, copy, modify, merge, publish,
300 +distribute, sublicense, and/or sell copies of the Software, and to
301 +permit persons to whom the Software is furnished to do so, subject to
302 +the following conditions:
304 +The above copyright notice and this permission notice shall be
305 +included in all copies or substantial portions of the Software.
307 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
308 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
309 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
310 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
311 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
312 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
313 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
315 +#ifndef dwarf_config_h
316 +#define dwarf_config_h
318 +/* This matches the value udes by GCC (see
319 + gcc/config/aarch64/aarch64.h:DWARF_FRAME_REGISTERS. */
320 +#define DWARF_NUM_PRESERVED_REGS 97
322 +/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */
323 +#define dwarf_is_big_endian(addr_space) 0
325 +#define dwarf_to_unw_regnum(reg) (((reg) <= UNW_AARCH64_V31) ? (reg) : 0)
327 +/* Convert a pointer to a dwarf_cursor structure to a pointer to
329 +#define dwarf_to_cursor(c) ((unw_cursor_t *) (c))
331 +typedef struct dwarf_loc
334 +#ifndef UNW_LOCAL_ONLY
335 + unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */
340 +#endif /* dwarf_config_h */
341 diff --git a/include/tdep-aarch64/jmpbuf.h b/include/tdep-aarch64/jmpbuf.h
343 index 0000000..2eb53a7
345 +++ b/include/tdep-aarch64/jmpbuf.h
347 +/* libunwind - a platform-independent unwind library
348 + Copyright (C) 2008 CodeSourcery
349 + Copyright (C) 2013 Linaro Limited
351 +This file is part of libunwind.
353 +Permission is hereby granted, free of charge, to any person obtaining
354 +a copy of this software and associated documentation files (the
355 +"Software"), to deal in the Software without restriction, including
356 +without limitation the rights to use, copy, modify, merge, publish,
357 +distribute, sublicense, and/or sell copies of the Software, and to
358 +permit persons to whom the Software is furnished to do so, subject to
359 +the following conditions:
361 +The above copyright notice and this permission notice shall be
362 +included in all copies or substantial portions of the Software.
364 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
365 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
366 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
367 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
368 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
369 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
370 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
372 +/* Use glibc's jump-buffer indices; NPTL peeks at SP: */
374 +/* FIXME for AArch64 */
378 +#define JB_MASK_SAVED 15
380 diff --git a/include/tdep-aarch64/libunwind_i.h b/include/tdep-aarch64/libunwind_i.h
382 index 0000000..28943db
384 +++ b/include/tdep-aarch64/libunwind_i.h
386 +/* libunwind - a platform-independent unwind library
387 + Copyright (C) 2001-2005 Hewlett-Packard Co
388 + Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
389 + Copyright (C) 2013 Linaro Limited
391 +This file is part of libunwind.
393 +Permission is hereby granted, free of charge, to any person obtaining
394 +a copy of this software and associated documentation files (the
395 +"Software"), to deal in the Software without restriction, including
396 +without limitation the rights to use, copy, modify, merge, publish,
397 +distribute, sublicense, and/or sell copies of the Software, and to
398 +permit persons to whom the Software is furnished to do so, subject to
399 +the following conditions:
401 +The above copyright notice and this permission notice shall be
402 +included in all copies or substantial portions of the Software.
404 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
405 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
406 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
407 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
408 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
409 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
410 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
412 +#ifndef AARCH64_LIBUNWIND_I_H
413 +#define AARCH64_LIBUNWIND_I_H
415 +/* Target-dependent definitions that are internal to libunwind but need
416 + to be shared with target-independent code. */
419 +#include <libunwind.h>
422 +#include "mempool.h"
427 + /* no aarch64-specific fast trace */
431 +#ifdef UNW_LOCAL_ONLY
433 +typedef unw_word_t aarch64_loc_t;
435 +#else /* !UNW_LOCAL_ONLY */
437 +typedef struct aarch64_loc
443 +#endif /* !UNW_LOCAL_ONLY */
445 +struct unw_addr_space
447 + struct unw_accessors acc;
449 + unw_caching_policy_t caching_policy;
450 +#ifdef HAVE_ATOMIC_OPS_H
451 + AO_t cache_generation;
453 + uint32_t cache_generation;
455 + unw_word_t dyn_generation; /* see dyn-common.h */
456 + unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */
457 + struct dwarf_rs_cache global_cache;
458 + struct unw_debug_frame_list *debug_frames;
463 + struct dwarf_cursor dwarf; /* must be first */
467 + AARCH64_SCF_LINUX_RT_SIGFRAME,
470 + unw_word_t sigcontext_addr;
471 + unw_word_t sigcontext_sp;
472 + unw_word_t sigcontext_pc;
475 +#define DWARF_GET_LOC(l) ((l).val)
477 +#ifdef UNW_LOCAL_ONLY
478 +# define DWARF_NULL_LOC DWARF_LOC (0, 0)
479 +# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0)
480 +# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) })
481 +# define DWARF_IS_REG_LOC(l) 0
482 +# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \
483 + tdep_uc_addr((c)->as_arg, (r)), 0))
484 +# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0)
485 +# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \
486 + tdep_uc_addr((c)->as_arg, (r)), 0))
489 +dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val)
491 + if (!DWARF_GET_LOC (loc))
493 + *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc);
498 +dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val)
500 + if (!DWARF_GET_LOC (loc))
502 + *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val;
507 +dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val)
509 + if (!DWARF_GET_LOC (loc))
511 + *val = *(unw_word_t *) DWARF_GET_LOC (loc);
516 +dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val)
518 + if (!DWARF_GET_LOC (loc))
520 + *(unw_word_t *) DWARF_GET_LOC (loc) = val;
524 +#else /* !UNW_LOCAL_ONLY */
525 +# define DWARF_LOC_TYPE_FP (1 << 0)
526 +# define DWARF_LOC_TYPE_REG (1 << 1)
527 +# define DWARF_NULL_LOC DWARF_LOC (0, 0)
528 +# define DWARF_IS_NULL_LOC(l) \
529 + ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; })
530 +# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) })
531 +# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0)
532 +# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0)
533 +# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG)
534 +# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0)
535 +# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \
536 + | DWARF_LOC_TYPE_FP))
539 +dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val)
541 + char *valp = (char *) &val;
545 + if (DWARF_IS_NULL_LOC (loc))
546 + return -UNW_EBADREG;
548 + if (DWARF_IS_REG_LOC (loc))
549 + return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc),
550 + val, 0, c->as_arg);
552 + addr = DWARF_GET_LOC (loc);
553 + if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp,
554 + 0, c->as_arg)) < 0)
557 + return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0,
562 +dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val)
564 + char *valp = (char *) &val;
568 + if (DWARF_IS_NULL_LOC (loc))
569 + return -UNW_EBADREG;
571 + if (DWARF_IS_REG_LOC (loc))
572 + return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc),
573 + &val, 1, c->as_arg);
575 + addr = DWARF_GET_LOC (loc);
576 + if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp,
577 + 1, c->as_arg)) < 0)
580 + return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1,
585 +dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val)
587 + if (DWARF_IS_NULL_LOC (loc))
588 + return -UNW_EBADREG;
590 + /* If a code-generator were to save a value of type unw_word_t in a
591 + floating-point register, we would have to support this case. I
592 + suppose it could happen with MMX registers, but does it really
594 + assert (!DWARF_IS_FP_LOC (loc));
596 + if (DWARF_IS_REG_LOC (loc))
597 + return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val,
600 + return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val,
605 +dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val)
607 + if (DWARF_IS_NULL_LOC (loc))
608 + return -UNW_EBADREG;
610 + /* If a code-generator were to save a value of type unw_word_t in a
611 + floating-point register, we would have to support this case. I
612 + suppose it could happen with MMX registers, but does it really
614 + assert (!DWARF_IS_FP_LOC (loc));
616 + if (DWARF_IS_REG_LOC (loc))
617 + return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val,
620 + return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val,
624 +#endif /* !UNW_LOCAL_ONLY */
628 +#define tdep_getcontext_trace unw_getcontext
629 +#define tdep_init_done UNW_OBJ(init_done)
630 +#define tdep_init UNW_OBJ(init)
631 +/* Platforms that support UNW_INFO_FORMAT_TABLE need to define
632 + tdep_search_unwind_table. */
633 +#define tdep_search_unwind_table dwarf_search_unwind_table
634 +#define tdep_find_unwind_table dwarf_find_unwind_table
635 +#define tdep_uc_addr UNW_OBJ(uc_addr)
636 +#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image)
637 +#define tdep_access_reg UNW_OBJ(access_reg)
638 +#define tdep_access_fpreg UNW_OBJ(access_fpreg)
639 +#define tdep_fetch_frame(c,ip,n) do {} while(0)
640 +#define tdep_cache_frame(c,rs) do {} while(0)
641 +#define tdep_reuse_frame(c,rs) do {} while(0)
642 +#define tdep_stash_frame(c,rs) do {} while(0)
643 +#define tdep_trace(cur,addr,n) (-UNW_ENOINFO)
645 +#ifdef UNW_LOCAL_ONLY
646 +# define tdep_find_proc_info(c,ip,n) \
647 + dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \
649 +# define tdep_put_unwind_info(as,pi,arg) \
650 + dwarf_put_unwind_info((as), (pi), (arg))
652 +# define tdep_find_proc_info(c,ip,n) \
653 + (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \
655 +# define tdep_put_unwind_info(as,pi,arg) \
656 + (*(as)->acc.put_unwind_info)((as), (pi), (arg))
659 +#define tdep_get_as(c) ((c)->dwarf.as)
660 +#define tdep_get_as_arg(c) ((c)->dwarf.as_arg)
661 +#define tdep_get_ip(c) ((c)->dwarf.ip)
662 +#define tdep_big_endian(as) ((as)->big_endian)
664 +extern int tdep_init_done;
666 +extern void tdep_init (void);
667 +extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
668 + unw_dyn_info_t *di, unw_proc_info_t *pi,
669 + int need_unwind_info, void *arg);
670 +extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg);
671 +extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
672 + unsigned long *segbase, unsigned long *mapoff,
673 + char *path, size_t pathlen);
674 +extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
675 + unw_word_t *valp, int write);
676 +extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
677 + unw_fpreg_t *valp, int write);
679 +#endif /* AARCH64_LIBUNWIND_I_H */
680 diff --git a/include/tdep/dwarf-config.h b/include/tdep/dwarf-config.h
681 index 1da268b..5b09fc1 100644
682 --- a/include/tdep/dwarf-config.h
683 +++ b/include/tdep/dwarf-config.h
685 /* Provide a real file - not a symlink - as it would cause multiarch conflicts
686 when multiple different arch releases are installed simultaneously. */
689 +#if defined __aarch64__
690 +# include "tdep-aarch64/dwarf-config.h"
691 +#elif defined __arm__
692 # include "tdep-arm/dwarf-config.h"
693 #elif defined __hppa__
694 # include "tdep-hppa/dwarf-config.h"
695 diff --git a/include/tdep/jmpbuf.h b/include/tdep/jmpbuf.h
696 index 7d04a42..684d0d9 100644
697 --- a/include/tdep/jmpbuf.h
698 +++ b/include/tdep/jmpbuf.h
701 #ifndef UNW_REMOTE_ONLY
703 +#if defined __aarch64__
704 +# include "tdep-aarch64/jmpbuf.h"
706 # include "tdep-arm/jmpbuf.h"
707 #elif defined __hppa__
708 diff --git a/include/tdep/libunwind_i.h.in b/include/tdep/libunwind_i.h.in
709 index 2ad6269..475f828 100644
710 --- a/include/tdep/libunwind_i.h.in
711 +++ b/include/tdep/libunwind_i.h.in
714 #ifndef UNW_REMOTE_ONLY
717 +#if defined __aarch64__
718 +# include "tdep-aarch64/libunwind_i.h"
719 +#elif defined __arm__
720 # include "tdep-arm/libunwind_i.h"
721 #elif defined __hppa__
722 # include "tdep-hppa/libunwind_i.h"
723 diff --git a/src/Makefile.am b/src/Makefile.am
724 index 08d2870..f104214 100644
725 --- a/src/Makefile.am
726 +++ b/src/Makefile.am
727 @@ -170,6 +170,28 @@ libunwind_elfxx_la_SOURCES = elfxx.c
728 noinst_LTLIBRARIES += $(LIBUNWIND_ELF)
729 libunwind_la_LIBADD += $(LIBUNWIND_ELF)
731 +# The list of files that go into libunwind and libunwind-aarch64:
732 +noinst_HEADERS += aarch64/init.h aarch64/offsets.h aarch64/unwind_i.h
733 +libunwind_la_SOURCES_aarch64_common = $(libunwind_la_SOURCES_common) \
734 + aarch64/is_fpreg.c aarch64/regname.c
736 +# The list of files that go into libunwind:
737 +libunwind_la_SOURCES_aarch64 = $(libunwind_la_SOURCES_aarch64_common) \
738 + $(libunwind_la_SOURCES_local) \
739 + aarch64/Lcreate_addr_space.c aarch64/Lget_proc_info.c \
740 + aarch64/Lget_save_loc.c aarch64/Lglobal.c aarch64/Linit.c \
741 + aarch64/Linit_local.c aarch64/Linit_remote.c \
742 + aarch64/Lis_signal_frame.c aarch64/Lregs.c aarch64/Lresume.c \
745 +libunwind_aarch64_la_SOURCES_aarch64 = $(libunwind_la_SOURCES_aarch64_common) \
746 + $(libunwind_la_SOURCES_generic) \
747 + aarch64/Gcreate_addr_space.c aarch64/Gget_proc_info.c \
748 + aarch64/Gget_save_loc.c aarch64/Gglobal.c aarch64/Ginit.c \
749 + aarch64/Ginit_local.c aarch64/Ginit_remote.c \
750 + aarch64/Gis_signal_frame.c aarch64/Gregs.c aarch64/Gresume.c \
753 # The list of files that go into libunwind and libunwind-arm:
754 noinst_HEADERS += arm/init.h arm/offsets.h arm/unwind_i.h
755 libunwind_la_SOURCES_arm_common = $(libunwind_la_SOURCES_common) \
756 @@ -418,6 +440,18 @@ if OS_FREEBSD
757 libunwind_coredump_la_SOURCES += coredump/_UCD_access_reg_freebsd.c
761 + lib_LTLIBRARIES += libunwind-aarch64.la
762 + libunwind_la_SOURCES = $(libunwind_la_SOURCES_aarch64)
763 + libunwind_aarch64_la_SOURCES = $(libunwind_aarch64_la_SOURCES_aarch64)
764 + libunwind_aarch64_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION)
765 + libunwind_aarch64_la_LIBADD = libunwind-dwarf-generic.la
766 + libunwind_aarch64_la_LIBADD += libunwind-elf64.la
768 + libunwind_aarch64_la_LIBADD += libunwind.la -lc
770 +# libunwind_setjmp_la_SOURCES += aarch64/siglongjmp.S
773 lib_LTLIBRARIES += libunwind-arm.la
774 libunwind_la_SOURCES = $(libunwind_la_SOURCES_arm)
775 @@ -545,6 +579,7 @@ endif # ARCH_MIPS
779 +endif # ARCH_AARCH64
781 # libunwind-setjmp depends on libunwind-$(arch). Therefore must be added
783 @@ -567,7 +602,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/tdep-$(arch) -I.
784 AM_CCASFLAGS = $(AM_CPPFLAGS)
785 noinst_HEADERS += unwind/unwind-internal.h
787 -EXTRA_DIST = $(libunwind_la_SOURCES_arm) \
788 +EXTRA_DIST = $(libunwind_la_SOURCES_aarch64) \
789 + $(libunwind_la_SOURCES_arm) \
790 $(libunwind_la_SOURCES_hppa) \
791 $(libunwind_la_SOURCES_ia64) \
792 $(libunwind_la_SOURCES_mips) \
793 @@ -579,6 +615,7 @@ EXTRA_DIST = $(libunwind_la_SOURCES_arm) \
794 $(libunwind_la_SOURCES_common) \
795 $(libunwind_la_SOURCES_local) \
796 $(libunwind_la_SOURCES_generic) \
797 + $(libunwind_aarch64_la_SOURCES_aarch64) \
798 $(libunwind_arm_la_SOURCES_arm) \
799 $(libunwind_hppa_la_SOURCES_hppa) \
800 $(libunwind_ia64_la_SOURCES_ia64) \
801 diff --git a/src/aarch64/Gcreate_addr_space.c b/src/aarch64/Gcreate_addr_space.c
803 index 0000000..b0f2b04
805 +++ b/src/aarch64/Gcreate_addr_space.c
807 +/* libunwind - a platform-independent unwind library
808 + Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
809 + Copyright (C) 2013 Linaro Limited
811 +This file is part of libunwind.
813 +Permission is hereby granted, free of charge, to any person obtaining
814 +a copy of this software and associated documentation files (the
815 +"Software"), to deal in the Software without restriction, including
816 +without limitation the rights to use, copy, modify, merge, publish,
817 +distribute, sublicense, and/or sell copies of the Software, and to
818 +permit persons to whom the Software is furnished to do so, subject to
819 +the following conditions:
821 +The above copyright notice and this permission notice shall be
822 +included in all copies or substantial portions of the Software.
824 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
825 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
826 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
827 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
828 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
829 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
830 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
835 +#include "unwind_i.h"
837 +PROTECTED unw_addr_space_t
838 +unw_create_addr_space (unw_accessors_t *a, int byte_order)
840 +#ifdef UNW_LOCAL_ONLY
843 + unw_addr_space_t as;
845 + /* AArch64 supports little-endian and big-endian. */
846 + if (byte_order != 0 && byte_order != __LITTLE_ENDIAN
847 + && byte_order != __BIG_ENDIAN)
850 + as = malloc (sizeof (*as));
854 + memset (as, 0, sizeof (*as));
858 + /* Default to little-endian for AArch64. */
859 + if (byte_order == 0 || byte_order == __LITTLE_ENDIAN)
860 + as->big_endian = 0;
862 + as->big_endian = 1;
867 diff --git a/src/aarch64/Gget_proc_info.c b/src/aarch64/Gget_proc_info.c
869 index 0000000..de9199f
871 +++ b/src/aarch64/Gget_proc_info.c
873 +/* libunwind - a platform-independent unwind library
874 + Copyright (C) 2008 CodeSourcery
876 +This file is part of libunwind.
878 +Permission is hereby granted, free of charge, to any person obtaining
879 +a copy of this software and associated documentation files (the
880 +"Software"), to deal in the Software without restriction, including
881 +without limitation the rights to use, copy, modify, merge, publish,
882 +distribute, sublicense, and/or sell copies of the Software, and to
883 +permit persons to whom the Software is furnished to do so, subject to
884 +the following conditions:
886 +The above copyright notice and this permission notice shall be
887 +included in all copies or substantial portions of the Software.
889 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
890 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
891 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
892 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
893 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
894 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
895 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
897 +#include "unwind_i.h"
900 +unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi)
902 + struct cursor *c = (struct cursor *) cursor;
905 + ret = dwarf_make_proc_info (&c->dwarf);
912 diff --git a/src/aarch64/Gget_save_loc.c b/src/aarch64/Gget_save_loc.c
914 index 0000000..c76eb9c
916 +++ b/src/aarch64/Gget_save_loc.c
918 +/* libunwind - a platform-independent unwind library
919 + Copyright (C) 2008 CodeSourcery
920 + Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
921 + Copyright (C) 2013 Linaro Limited
923 +This file is part of libunwind.
925 +Permission is hereby granted, free of charge, to any person obtaining
926 +a copy of this software and associated documentation files (the
927 +"Software"), to deal in the Software without restriction, including
928 +without limitation the rights to use, copy, modify, merge, publish,
929 +distribute, sublicense, and/or sell copies of the Software, and to
930 +permit persons to whom the Software is furnished to do so, subject to
931 +the following conditions:
933 +The above copyright notice and this permission notice shall be
934 +included in all copies or substantial portions of the Software.
936 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
937 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
938 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
939 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
940 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
941 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
942 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
944 +#include "unwind_i.h"
947 +unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc)
949 + struct cursor *c = (struct cursor *) cursor;
954 + case UNW_AARCH64_X0:
955 + case UNW_AARCH64_X1:
956 + case UNW_AARCH64_X2:
957 + case UNW_AARCH64_X3:
958 + case UNW_AARCH64_X4:
959 + case UNW_AARCH64_X5:
960 + case UNW_AARCH64_X6:
961 + case UNW_AARCH64_X7:
962 + case UNW_AARCH64_X8:
963 + case UNW_AARCH64_X9:
964 + case UNW_AARCH64_X10:
965 + case UNW_AARCH64_X11:
966 + case UNW_AARCH64_X12:
967 + case UNW_AARCH64_X13:
968 + case UNW_AARCH64_X14:
969 + case UNW_AARCH64_X15:
970 + case UNW_AARCH64_X16:
971 + case UNW_AARCH64_X17:
972 + case UNW_AARCH64_X18:
973 + case UNW_AARCH64_X19:
974 + case UNW_AARCH64_X20:
975 + case UNW_AARCH64_X21:
976 + case UNW_AARCH64_X22:
977 + case UNW_AARCH64_X23:
978 + case UNW_AARCH64_X24:
979 + case UNW_AARCH64_X25:
980 + case UNW_AARCH64_X26:
981 + case UNW_AARCH64_X27:
982 + case UNW_AARCH64_X28:
983 + case UNW_AARCH64_X29:
984 + case UNW_AARCH64_X30:
985 + case UNW_AARCH64_SP:
986 + case UNW_AARCH64_PC:
987 + case UNW_AARCH64_PSTATE:
988 + loc = c->dwarf.loc[reg];
992 + loc = DWARF_NULL_LOC; /* default to "not saved" */
996 + memset (sloc, 0, sizeof (*sloc));
998 + if (DWARF_IS_NULL_LOC (loc))
1000 + sloc->type = UNW_SLT_NONE;
1004 +#if !defined(UNW_LOCAL_ONLY)
1005 + if (DWARF_IS_REG_LOC (loc))
1007 + sloc->type = UNW_SLT_REG;
1008 + sloc->u.regnum = DWARF_GET_LOC (loc);
1013 + sloc->type = UNW_SLT_MEMORY;
1014 + sloc->u.addr = DWARF_GET_LOC (loc);
1018 diff --git a/src/aarch64/Gglobal.c b/src/aarch64/Gglobal.c
1019 new file mode 100644
1020 index 0000000..b0a7e26
1022 +++ b/src/aarch64/Gglobal.c
1024 +/* libunwind - a platform-independent unwind library
1025 + Copyright (C) 2008 CodeSourcery
1026 + Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1027 + Copyright (C) 2013 Linaro Limited
1029 +This file is part of libunwind.
1031 +Permission is hereby granted, free of charge, to any person obtaining
1032 +a copy of this software and associated documentation files (the
1033 +"Software"), to deal in the Software without restriction, including
1034 +without limitation the rights to use, copy, modify, merge, publish,
1035 +distribute, sublicense, and/or sell copies of the Software, and to
1036 +permit persons to whom the Software is furnished to do so, subject to
1037 +the following conditions:
1039 +The above copyright notice and this permission notice shall be
1040 +included in all copies or substantial portions of the Software.
1042 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1043 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1044 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1045 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1046 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1047 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1048 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1050 +#include "unwind_i.h"
1051 +#include "dwarf_i.h"
1053 +HIDDEN define_lock (aarch64_lock);
1054 +HIDDEN int tdep_init_done;
1059 + intrmask_t saved_mask;
1061 + sigfillset (&unwi_full_mask);
1063 + lock_acquire (&aarch64_lock, saved_mask);
1065 + if (tdep_init_done)
1066 + /* another thread else beat us to it... */
1073 +#ifndef UNW_REMOTE_ONLY
1074 + aarch64_local_addr_space_init ();
1076 + tdep_init_done = 1; /* signal that we're initialized... */
1079 + lock_release (&aarch64_lock, saved_mask);
1081 diff --git a/src/aarch64/Ginit.c b/src/aarch64/Ginit.c
1082 new file mode 100644
1083 index 0000000..449b417
1085 +++ b/src/aarch64/Ginit.c
1087 +/* libunwind - a platform-independent unwind library
1088 + Copyright (C) 2008 CodeSourcery
1089 + Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1090 + Copyright (C) 2013 Linaro Limited
1092 +This file is part of libunwind.
1094 +Permission is hereby granted, free of charge, to any person obtaining
1095 +a copy of this software and associated documentation files (the
1096 +"Software"), to deal in the Software without restriction, including
1097 +without limitation the rights to use, copy, modify, merge, publish,
1098 +distribute, sublicense, and/or sell copies of the Software, and to
1099 +permit persons to whom the Software is furnished to do so, subject to
1100 +the following conditions:
1102 +The above copyright notice and this permission notice shall be
1103 +included in all copies or substantial portions of the Software.
1105 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1106 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1107 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1108 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1109 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1110 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1111 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1113 +#include <stdlib.h>
1114 +#include <string.h>
1116 +#include "unwind_i.h"
1118 +#ifdef UNW_REMOTE_ONLY
1120 +/* unw_local_addr_space is a NULL pointer in this case. */
1121 +PROTECTED unw_addr_space_t unw_local_addr_space;
1123 +#else /* !UNW_REMOTE_ONLY */
1125 +static struct unw_addr_space local_addr_space;
1127 +PROTECTED unw_addr_space_t unw_local_addr_space = &local_addr_space;
1129 +static inline void *
1130 +uc_addr (ucontext_t *uc, int reg)
1132 + if (reg >= UNW_AARCH64_X0 && reg <= UNW_AARCH64_V31)
1133 + return &uc->uc_mcontext.regs[reg];
1138 +# ifdef UNW_LOCAL_ONLY
1141 +tdep_uc_addr (ucontext_t *uc, int reg)
1143 + return uc_addr (uc, reg);
1146 +# endif /* UNW_LOCAL_ONLY */
1148 +HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
1150 +/* XXX fix me: there is currently no way to locate the dyn-info list
1151 + by a remote unwinder. On ia64, this is done via a special
1152 + unwind-table entry. Perhaps something similar can be done with
1153 + DWARF2 unwind info. */
1156 +put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
1158 + /* it's a no-op */
1162 +get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
1165 + *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
1170 +access_mem (unw_addr_space_t as, unw_word_t addr, unw_word_t *val, int write,
1175 + Debug (16, "mem[%x] <- %x\n", addr, *val);
1176 + *(unw_word_t *) addr = *val;
1180 + *val = *(unw_word_t *) addr;
1181 + Debug (16, "mem[%x] -> %x\n", addr, *val);
1187 +access_reg (unw_addr_space_t as, unw_regnum_t reg, unw_word_t *val, int write,
1191 + ucontext_t *uc = arg;
1193 + if (unw_is_fpreg (reg))
1196 + if (!(addr = uc_addr (uc, reg)))
1201 + *(unw_word_t *) addr = *val;
1202 + Debug (12, "%s <- %x\n", unw_regname (reg), *val);
1206 + *val = *(unw_word_t *) addr;
1207 + Debug (12, "%s -> %x\n", unw_regname (reg), *val);
1212 + Debug (1, "bad register number %u\n", reg);
1213 + return -UNW_EBADREG;
1217 +access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val,
1218 + int write, void *arg)
1220 + ucontext_t *uc = arg;
1221 + unw_fpreg_t *addr;
1223 + if (!unw_is_fpreg (reg))
1226 + if (!(addr = uc_addr (uc, reg)))
1231 + Debug (12, "%s <- %08lx.%08lx.%08lx\n", unw_regname (reg),
1232 + ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]);
1233 + *(unw_fpreg_t *) addr = *val;
1237 + *val = *(unw_fpreg_t *) addr;
1238 + Debug (12, "%s -> %08lx.%08lx.%08lx\n", unw_regname (reg),
1239 + ((long *)val)[0], ((long *)val)[1], ((long *)val)[2]);
1244 + Debug (1, "bad register number %u\n", reg);
1245 + /* attempt to access a non-preserved register */
1246 + return -UNW_EBADREG;
1250 +get_static_proc_name (unw_addr_space_t as, unw_word_t ip,
1251 + char *buf, size_t buf_len, unw_word_t *offp,
1254 + return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp);
1258 +aarch64_local_addr_space_init (void)
1260 + memset (&local_addr_space, 0, sizeof (local_addr_space));
1261 + local_addr_space.caching_policy = UNW_CACHE_GLOBAL;
1262 + local_addr_space.acc.find_proc_info = dwarf_find_proc_info;
1263 + local_addr_space.acc.put_unwind_info = put_unwind_info;
1264 + local_addr_space.acc.get_dyn_info_list_addr = get_dyn_info_list_addr;
1265 + local_addr_space.acc.access_mem = access_mem;
1266 + local_addr_space.acc.access_reg = access_reg;
1267 + local_addr_space.acc.access_fpreg = access_fpreg;
1268 + local_addr_space.acc.resume = aarch64_local_resume;
1269 + local_addr_space.acc.get_proc_name = get_static_proc_name;
1270 + unw_flush_cache (&local_addr_space, 0, 0);
1273 +#endif /* !UNW_REMOTE_ONLY */
1274 diff --git a/src/aarch64/Ginit_local.c b/src/aarch64/Ginit_local.c
1275 new file mode 100644
1276 index 0000000..dee6fd3
1278 +++ b/src/aarch64/Ginit_local.c
1280 +/* libunwind - a platform-independent unwind library
1281 + Copyright (C) 2008 CodeSourcery
1282 + Copyright (C) 2011-2013 Linaro Limited
1284 +This file is part of libunwind.
1286 +Permission is hereby granted, free of charge, to any person obtaining
1287 +a copy of this software and associated documentation files (the
1288 +"Software"), to deal in the Software without restriction, including
1289 +without limitation the rights to use, copy, modify, merge, publish,
1290 +distribute, sublicense, and/or sell copies of the Software, and to
1291 +permit persons to whom the Software is furnished to do so, subject to
1292 +the following conditions:
1294 +The above copyright notice and this permission notice shall be
1295 +included in all copies or substantial portions of the Software.
1297 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1298 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1299 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1300 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1301 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1302 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1303 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1305 +#include "unwind_i.h"
1308 +#ifdef UNW_REMOTE_ONLY
1311 +unw_init_local (unw_cursor_t *cursor, unw_context_t *uc)
1313 + return -UNW_EINVAL;
1316 +#else /* !UNW_REMOTE_ONLY */
1319 +unw_init_local (unw_cursor_t *cursor, unw_context_t *uc)
1321 + struct cursor *c = (struct cursor *) cursor;
1323 + if (!tdep_init_done)
1326 + Debug (1, "(cursor=%p)\n", c);
1328 + c->dwarf.as = unw_local_addr_space;
1329 + c->dwarf.as_arg = uc;
1331 + return common_init (c, 1);
1334 +#endif /* !UNW_REMOTE_ONLY */
1335 diff --git a/src/aarch64/Ginit_remote.c b/src/aarch64/Ginit_remote.c
1336 new file mode 100644
1337 index 0000000..f284e99
1339 +++ b/src/aarch64/Ginit_remote.c
1341 +/* libunwind - a platform-independent unwind library
1342 + Copyright (C) 2008 CodeSourcery
1344 +This file is part of libunwind.
1346 +Permission is hereby granted, free of charge, to any person obtaining
1347 +a copy of this software and associated documentation files (the
1348 +"Software"), to deal in the Software without restriction, including
1349 +without limitation the rights to use, copy, modify, merge, publish,
1350 +distribute, sublicense, and/or sell copies of the Software, and to
1351 +permit persons to whom the Software is furnished to do so, subject to
1352 +the following conditions:
1354 +The above copyright notice and this permission notice shall be
1355 +included in all copies or substantial portions of the Software.
1357 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1358 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1359 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1360 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1361 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1362 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1363 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1366 +#include "unwind_i.h"
1369 +unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg)
1371 +#ifdef UNW_LOCAL_ONLY
1372 + return -UNW_EINVAL;
1373 +#else /* !UNW_LOCAL_ONLY */
1374 + struct cursor *c = (struct cursor *) cursor;
1376 + if (!tdep_init_done)
1379 + Debug (1, "(cursor=%p)\n", c);
1382 + c->dwarf.as_arg = as_arg;
1383 + return common_init (c, 0);
1384 +#endif /* !UNW_LOCAL_ONLY */
1386 diff --git a/src/aarch64/Gis_signal_frame.c b/src/aarch64/Gis_signal_frame.c
1387 new file mode 100644
1388 index 0000000..53e32de
1390 +++ b/src/aarch64/Gis_signal_frame.c
1392 +/* libunwind - a platform-independent unwind library
1393 + Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1394 + Copyright (C) 2013 Linaro Limited
1396 +This file is part of libunwind.
1398 +Permission is hereby granted, free of charge, to any person obtaining
1399 +a copy of this software and associated documentation files (the
1400 +"Software"), to deal in the Software without restriction, including
1401 +without limitation the rights to use, copy, modify, merge, publish,
1402 +distribute, sublicense, and/or sell copies of the Software, and to
1403 +permit persons to whom the Software is furnished to do so, subject to
1404 +the following conditions:
1406 +The above copyright notice and this permission notice shall be
1407 +included in all copies or substantial portions of the Software.
1409 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1410 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1411 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1412 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1413 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1414 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1415 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1417 +#include "unwind_i.h"
1419 +/* The restorer stub will always have the form:
1421 + d2801168 movz x8, #0x8b
1426 +unw_is_signal_frame (unw_cursor_t *cursor)
1429 + struct cursor *c = (struct cursor *) cursor;
1430 + unw_word_t w0, ip;
1431 + unw_addr_space_t as;
1432 + unw_accessors_t *a;
1437 + a = unw_get_accessors (as);
1438 + arg = c->dwarf.as_arg;
1442 + ret = (*a->access_mem) (as, ip, &w0, 0, arg);
1446 + /* FIXME: distinguish 32bit insn vs 64bit registers. */
1447 + if (w0 != 0xd4000001d2801168)
1453 + return -UNW_ENOINFO;
1456 diff --git a/src/aarch64/Gregs.c b/src/aarch64/Gregs.c
1457 new file mode 100644
1458 index 0000000..0f6b9c6
1460 +++ b/src/aarch64/Gregs.c
1462 +/* libunwind - a platform-independent unwind library
1463 + Copyright (C) 2008 CodeSourcery
1464 + Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1465 + Copyright (C) 2013 Linaro Limited
1467 +This file is part of libunwind.
1469 +Permission is hereby granted, free of charge, to any person obtaining
1470 +a copy of this software and associated documentation files (the
1471 +"Software"), to deal in the Software without restriction, including
1472 +without limitation the rights to use, copy, modify, merge, publish,
1473 +distribute, sublicense, and/or sell copies of the Software, and to
1474 +permit persons to whom the Software is furnished to do so, subject to
1475 +the following conditions:
1477 +The above copyright notice and this permission notice shall be
1478 +included in all copies or substantial portions of the Software.
1480 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1481 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1482 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1483 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1484 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1485 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1486 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1488 +#include "unwind_i.h"
1491 +tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp,
1494 + dwarf_loc_t loc = DWARF_NULL_LOC;
1495 + unsigned int mask;
1499 + case UNW_AARCH64_X0:
1500 + case UNW_AARCH64_X1:
1501 + case UNW_AARCH64_X2:
1502 + case UNW_AARCH64_X3:
1506 + c->dwarf.eh_args[reg] = *valp;
1507 + c->dwarf.eh_valid_mask |= mask;
1510 + else if ((c->dwarf.eh_valid_mask & mask) != 0)
1512 + *valp = c->dwarf.eh_args[reg];
1516 + loc = c->dwarf.loc[reg];
1519 + case UNW_AARCH64_X4:
1520 + case UNW_AARCH64_X5:
1521 + case UNW_AARCH64_X6:
1522 + case UNW_AARCH64_X7:
1523 + case UNW_AARCH64_X8:
1524 + case UNW_AARCH64_X9:
1525 + case UNW_AARCH64_X10:
1526 + case UNW_AARCH64_X11:
1527 + case UNW_AARCH64_X12:
1528 + case UNW_AARCH64_X13:
1529 + case UNW_AARCH64_X14:
1530 + case UNW_AARCH64_X15:
1531 + case UNW_AARCH64_X16:
1532 + case UNW_AARCH64_X17:
1533 + case UNW_AARCH64_X18:
1534 + case UNW_AARCH64_X19:
1535 + case UNW_AARCH64_X20:
1536 + case UNW_AARCH64_X21:
1537 + case UNW_AARCH64_X22:
1538 + case UNW_AARCH64_X23:
1539 + case UNW_AARCH64_X24:
1540 + case UNW_AARCH64_X25:
1541 + case UNW_AARCH64_X26:
1542 + case UNW_AARCH64_X27:
1543 + case UNW_AARCH64_X28:
1544 + case UNW_AARCH64_X29:
1545 + case UNW_AARCH64_X30:
1546 + case UNW_AARCH64_PC:
1547 + case UNW_AARCH64_PSTATE:
1548 + loc = c->dwarf.loc[reg];
1551 + case UNW_AARCH64_SP:
1553 + return -UNW_EREADONLYREG;
1554 + *valp = c->dwarf.cfa;
1558 + Debug (1, "bad register number %u\n", reg);
1559 + return -UNW_EBADREG;
1563 + return dwarf_put (&c->dwarf, loc, *valp);
1565 + return dwarf_get (&c->dwarf, loc, valp);
1569 +tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp,
1572 + Debug (1, "bad register number %u\n", reg);
1573 + return -UNW_EBADREG;
1575 diff --git a/src/aarch64/Gresume.c b/src/aarch64/Gresume.c
1576 new file mode 100644
1577 index 0000000..908646b
1579 +++ b/src/aarch64/Gresume.c
1581 +/* libunwind - a platform-independent unwind library
1582 + Copyright (C) 2008 CodeSourcery
1583 + Copyright (C) 2011-2013 Linaro Limited
1584 + Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1586 +This file is part of libunwind.
1588 +Permission is hereby granted, free of charge, to any person obtaining
1589 +a copy of this software and associated documentation files (the
1590 +"Software"), to deal in the Software without restriction, including
1591 +without limitation the rights to use, copy, modify, merge, publish,
1592 +distribute, sublicense, and/or sell copies of the Software, and to
1593 +permit persons to whom the Software is furnished to do so, subject to
1594 +the following conditions:
1596 +The above copyright notice and this permission notice shall be
1597 +included in all copies or substantial portions of the Software.
1599 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1600 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1601 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1602 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1603 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1604 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1605 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1607 +#include "unwind_i.h"
1608 +#include "offsets.h"
1610 +#ifndef UNW_REMOTE_ONLY
1613 +aarch64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor, void *arg)
1616 + struct cursor *c = (struct cursor *) cursor;
1617 + unw_tdep_context_t *uc = c->dwarf.as_arg;
1619 + if (c->sigcontext_format == AARCH64_SCF_NONE)
1621 + /* Since there are no signals involved here we restore the non scratch
1622 + registers only. */
1623 + unsigned long regs[11];
1624 + regs[0] = uc->uc_mcontext.regs[19];
1625 + regs[1] = uc->uc_mcontext.regs[20];
1626 + regs[2] = uc->uc_mcontext.regs[21];
1627 + regs[3] = uc->uc_mcontext.regs[22];
1628 + regs[4] = uc->uc_mcontext.regs[23];
1629 + regs[5] = uc->uc_mcontext.regs[24];
1630 + regs[6] = uc->uc_mcontext.regs[25];
1631 + regs[7] = uc->uc_mcontext.regs[26];
1632 + regs[8] = uc->uc_mcontext.regs[27];
1633 + regs[9] = uc->uc_mcontext.regs[28];
1634 + regs[10] = uc->uc_mcontext.regs[30]; /* LR */
1635 + unsigned long sp = uc->uc_mcontext.sp;
1637 + struct regs_overlay {
1638 + char x[sizeof(regs)];
1642 + "ldp x19, x20, [%0]\n"
1643 + "ldp x21, x22, [%0,16]\n"
1644 + "ldp x23, x24, [%0,32]\n"
1645 + "ldp x25, x26, [%0,48]\n"
1646 + "ldp x27, x28, [%0,64]\n"
1647 + "ldr x30, [%0,80]\n"
1653 + "m" (*(struct regs_overlay *)regs)
1658 + struct sigcontext *sc = (struct sigcontext *) c->sigcontext_addr;
1660 + if (c->dwarf.eh_valid_mask & 0x1) sc->regs[0] = c->dwarf.eh_args[0];
1661 + if (c->dwarf.eh_valid_mask & 0x2) sc->regs[1] = c->dwarf.eh_args[1];
1662 + if (c->dwarf.eh_valid_mask & 0x4) sc->regs[2] = c->dwarf.eh_args[2];
1663 + if (c->dwarf.eh_valid_mask & 0x8) sc->regs[3] = c->dwarf.eh_args[3];
1665 + sc->regs[4] = uc->uc_mcontext.regs[4];
1666 + sc->regs[5] = uc->uc_mcontext.regs[5];
1667 + sc->regs[6] = uc->uc_mcontext.regs[6];
1668 + sc->regs[7] = uc->uc_mcontext.regs[7];
1669 + sc->regs[8] = uc->uc_mcontext.regs[8];
1670 + sc->regs[9] = uc->uc_mcontext.regs[9];
1671 + sc->regs[10] = uc->uc_mcontext.regs[10];
1672 + sc->regs[11] = uc->uc_mcontext.regs[11];
1673 + sc->regs[12] = uc->uc_mcontext.regs[12];
1674 + sc->regs[13] = uc->uc_mcontext.regs[13];
1675 + sc->regs[14] = uc->uc_mcontext.regs[14];
1676 + sc->regs[15] = uc->uc_mcontext.regs[15];
1677 + sc->regs[16] = uc->uc_mcontext.regs[16];
1678 + sc->regs[17] = uc->uc_mcontext.regs[17];
1679 + sc->regs[18] = uc->uc_mcontext.regs[18];
1680 + sc->regs[19] = uc->uc_mcontext.regs[19];
1681 + sc->regs[20] = uc->uc_mcontext.regs[20];
1682 + sc->regs[21] = uc->uc_mcontext.regs[21];
1683 + sc->regs[22] = uc->uc_mcontext.regs[22];
1684 + sc->regs[23] = uc->uc_mcontext.regs[23];
1685 + sc->regs[24] = uc->uc_mcontext.regs[24];
1686 + sc->regs[25] = uc->uc_mcontext.regs[25];
1687 + sc->regs[26] = uc->uc_mcontext.regs[26];
1688 + sc->regs[27] = uc->uc_mcontext.regs[27];
1689 + sc->regs[28] = uc->uc_mcontext.regs[28];
1690 + sc->regs[29] = uc->uc_mcontext.regs[29];
1691 + sc->regs[30] = uc->uc_mcontext.regs[30];
1692 + sc->sp = uc->uc_mcontext.sp;
1693 + sc->pc = uc->uc_mcontext.pc;
1694 + sc->pstate = uc->uc_mcontext.pstate;
1699 + : : "r" (c->sigcontext_sp), "r" (c->sigcontext_pc)
1702 + __builtin_unreachable();
1704 + printf ("%s: implement me\n", __FUNCTION__);
1706 + return -UNW_EINVAL;
1709 +#endif /* !UNW_REMOTE_ONLY */
1712 +establish_machine_state (struct cursor *c)
1714 + unw_addr_space_t as = c->dwarf.as;
1715 + void *arg = c->dwarf.as_arg;
1716 + unw_fpreg_t fpval;
1720 + Debug (8, "copying out cursor state\n");
1722 + for (reg = 0; reg <= UNW_AARCH64_PSTATE; ++reg)
1724 + Debug (16, "copying %s %d\n", unw_regname (reg), reg);
1725 + if (unw_is_fpreg (reg))
1727 + if (tdep_access_fpreg (c, reg, &fpval, 0) >= 0)
1728 + as->acc.access_fpreg (as, reg, &fpval, 1, arg);
1732 + if (tdep_access_reg (c, reg, &val, 0) >= 0)
1733 + as->acc.access_reg (as, reg, &val, 1, arg);
1739 +unw_resume (unw_cursor_t *cursor)
1741 + struct cursor *c = (struct cursor *) cursor;
1743 + Debug (1, "(cursor=%p)\n", c);
1747 + /* This can happen easily when the frame-chain gets truncated
1748 + due to bad or missing unwind-info. */
1749 + Debug (1, "refusing to resume execution at address 0\n");
1750 + return -UNW_EINVAL;
1753 + establish_machine_state (c);
1755 + return (*c->dwarf.as->acc.resume) (c->dwarf.as, (unw_cursor_t *) c,
1758 diff --git a/src/aarch64/Gstep.c b/src/aarch64/Gstep.c
1759 new file mode 100644
1760 index 0000000..4aa15d1
1762 +++ b/src/aarch64/Gstep.c
1764 +/* libunwind - a platform-independent unwind library
1765 + Copyright (C) 2008 CodeSourcery
1766 + Copyright (C) 2011-2013 Linaro Limited
1767 + Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
1769 +This file is part of libunwind.
1771 +Permission is hereby granted, free of charge, to any person obtaining
1772 +a copy of this software and associated documentation files (the
1773 +"Software"), to deal in the Software without restriction, including
1774 +without limitation the rights to use, copy, modify, merge, publish,
1775 +distribute, sublicense, and/or sell copies of the Software, and to
1776 +permit persons to whom the Software is furnished to do so, subject to
1777 +the following conditions:
1779 +The above copyright notice and this permission notice shall be
1780 +included in all copies or substantial portions of the Software.
1782 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1783 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1784 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1785 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1786 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1787 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1788 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1790 +#include "unwind_i.h"
1791 +#include "offsets.h"
1794 +unw_handle_signal_frame (unw_cursor_t *cursor)
1796 + struct cursor *c = (struct cursor *) cursor;
1798 + unw_word_t sc_addr, sp, sp_addr = c->dwarf.cfa;
1799 + struct dwarf_loc sp_loc = DWARF_LOC (sp_addr, 0);
1801 + if ((ret = dwarf_get (&c->dwarf, sp_loc, &sp)) < 0)
1802 + return -UNW_EUNSPEC;
1804 + ret = unw_is_signal_frame (cursor);
1805 + Debug(1, "unw_is_signal_frame()=%d\n", ret);
1807 + /* Save the SP and PC to be able to return execution at this point
1808 + later in time (unw_resume). */
1809 + c->sigcontext_sp = c->dwarf.cfa;
1810 + c->sigcontext_pc = c->dwarf.ip;
1814 + c->sigcontext_format = AARCH64_SCF_LINUX_RT_SIGFRAME;
1815 + sc_addr = sp_addr + sizeof (siginfo_t) + LINUX_UC_MCONTEXT_OFF;
1818 + return -UNW_EUNSPEC;
1820 + c->sigcontext_addr = sc_addr;
1822 + /* Update the dwarf cursor.
1823 + Set the location of the registers to the corresponding addresses of the
1824 + uc_mcontext / sigcontext structure contents. */
1825 + c->dwarf.loc[UNW_AARCH64_X0] = DWARF_LOC (sc_addr + LINUX_SC_X0_OFF, 0);
1826 + c->dwarf.loc[UNW_AARCH64_X1] = DWARF_LOC (sc_addr + LINUX_SC_X1_OFF, 0);
1827 + c->dwarf.loc[UNW_AARCH64_X2] = DWARF_LOC (sc_addr + LINUX_SC_X2_OFF, 0);
1828 + c->dwarf.loc[UNW_AARCH64_X3] = DWARF_LOC (sc_addr + LINUX_SC_X3_OFF, 0);
1829 + c->dwarf.loc[UNW_AARCH64_X4] = DWARF_LOC (sc_addr + LINUX_SC_X4_OFF, 0);
1830 + c->dwarf.loc[UNW_AARCH64_X5] = DWARF_LOC (sc_addr + LINUX_SC_X5_OFF, 0);
1831 + c->dwarf.loc[UNW_AARCH64_X6] = DWARF_LOC (sc_addr + LINUX_SC_X6_OFF, 0);
1832 + c->dwarf.loc[UNW_AARCH64_X7] = DWARF_LOC (sc_addr + LINUX_SC_X7_OFF, 0);
1833 + c->dwarf.loc[UNW_AARCH64_X8] = DWARF_LOC (sc_addr + LINUX_SC_X8_OFF, 0);
1834 + c->dwarf.loc[UNW_AARCH64_X9] = DWARF_LOC (sc_addr + LINUX_SC_X9_OFF, 0);
1835 + c->dwarf.loc[UNW_AARCH64_X10] = DWARF_LOC (sc_addr + LINUX_SC_X10_OFF, 0);
1836 + c->dwarf.loc[UNW_AARCH64_X11] = DWARF_LOC (sc_addr + LINUX_SC_X11_OFF, 0);
1837 + c->dwarf.loc[UNW_AARCH64_X12] = DWARF_LOC (sc_addr + LINUX_SC_X12_OFF, 0);
1838 + c->dwarf.loc[UNW_AARCH64_X13] = DWARF_LOC (sc_addr + LINUX_SC_X13_OFF, 0);
1839 + c->dwarf.loc[UNW_AARCH64_X14] = DWARF_LOC (sc_addr + LINUX_SC_X14_OFF, 0);
1840 + c->dwarf.loc[UNW_AARCH64_X15] = DWARF_LOC (sc_addr + LINUX_SC_X15_OFF, 0);
1841 + c->dwarf.loc[UNW_AARCH64_X16] = DWARF_LOC (sc_addr + LINUX_SC_X16_OFF, 0);
1842 + c->dwarf.loc[UNW_AARCH64_X17] = DWARF_LOC (sc_addr + LINUX_SC_X17_OFF, 0);
1843 + c->dwarf.loc[UNW_AARCH64_X18] = DWARF_LOC (sc_addr + LINUX_SC_X18_OFF, 0);
1844 + c->dwarf.loc[UNW_AARCH64_X19] = DWARF_LOC (sc_addr + LINUX_SC_X19_OFF, 0);
1845 + c->dwarf.loc[UNW_AARCH64_X20] = DWARF_LOC (sc_addr + LINUX_SC_X20_OFF, 0);
1846 + c->dwarf.loc[UNW_AARCH64_X21] = DWARF_LOC (sc_addr + LINUX_SC_X21_OFF, 0);
1847 + c->dwarf.loc[UNW_AARCH64_X22] = DWARF_LOC (sc_addr + LINUX_SC_X22_OFF, 0);
1848 + c->dwarf.loc[UNW_AARCH64_X23] = DWARF_LOC (sc_addr + LINUX_SC_X23_OFF, 0);
1849 + c->dwarf.loc[UNW_AARCH64_X24] = DWARF_LOC (sc_addr + LINUX_SC_X24_OFF, 0);
1850 + c->dwarf.loc[UNW_AARCH64_X25] = DWARF_LOC (sc_addr + LINUX_SC_X25_OFF, 0);
1851 + c->dwarf.loc[UNW_AARCH64_X26] = DWARF_LOC (sc_addr + LINUX_SC_X26_OFF, 0);
1852 + c->dwarf.loc[UNW_AARCH64_X27] = DWARF_LOC (sc_addr + LINUX_SC_X27_OFF, 0);
1853 + c->dwarf.loc[UNW_AARCH64_X28] = DWARF_LOC (sc_addr + LINUX_SC_X28_OFF, 0);
1854 + c->dwarf.loc[UNW_AARCH64_X29] = DWARF_LOC (sc_addr + LINUX_SC_X29_OFF, 0);
1855 + c->dwarf.loc[UNW_AARCH64_X30] = DWARF_LOC (sc_addr + LINUX_SC_X30_OFF, 0);
1856 + c->dwarf.loc[UNW_AARCH64_SP] = DWARF_LOC (sc_addr + LINUX_SC_SP_OFF, 0);
1857 + c->dwarf.loc[UNW_AARCH64_PC] = DWARF_LOC (sc_addr + LINUX_SC_PC_OFF, 0);
1858 + c->dwarf.loc[UNW_AARCH64_PSTATE] = DWARF_LOC (sc_addr + LINUX_SC_PSTATE_OFF, 0);
1860 + /* Set SP/CFA and PC/IP. */
1861 + dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_SP], &c->dwarf.cfa);
1862 + dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_PC], &c->dwarf.ip);
1864 + c->dwarf.pi_valid = 0;
1870 +unw_step (unw_cursor_t *cursor)
1872 + struct cursor *c = (struct cursor *) cursor;
1875 + Debug (1, "(cursor=%p, ip=0x%016lx, cfa=0x%016lx))\n",
1876 + c, c->dwarf.ip, c->dwarf.cfa);
1878 + /* Check if this is a signal frame. */
1879 + if (unw_is_signal_frame (cursor))
1880 + return unw_handle_signal_frame (cursor);
1882 + ret = dwarf_step (&c->dwarf);
1883 + Debug(1, "dwarf_step()=%d\n", ret);
1885 + if (unlikely (ret == -UNW_ESTOPUNWIND))
1888 + if (unlikely (ret < 0))
1891 + return (c->dwarf.ip == 0) ? 0 : 1;
1893 diff --git a/src/aarch64/Lcreate_addr_space.c b/src/aarch64/Lcreate_addr_space.c
1894 new file mode 100644
1895 index 0000000..0f2dc6b
1897 +++ b/src/aarch64/Lcreate_addr_space.c
1899 +#define UNW_LOCAL_ONLY
1900 +#include <libunwind.h>
1901 +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1902 +#include "Gcreate_addr_space.c"
1904 diff --git a/src/aarch64/Lget_proc_info.c b/src/aarch64/Lget_proc_info.c
1905 new file mode 100644
1906 index 0000000..69028b0
1908 +++ b/src/aarch64/Lget_proc_info.c
1910 +#define UNW_LOCAL_ONLY
1911 +#include <libunwind.h>
1912 +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1913 +#include "Gget_proc_info.c"
1915 diff --git a/src/aarch64/Lget_save_loc.c b/src/aarch64/Lget_save_loc.c
1916 new file mode 100644
1917 index 0000000..9ea048a
1919 +++ b/src/aarch64/Lget_save_loc.c
1921 +#define UNW_LOCAL_ONLY
1922 +#include <libunwind.h>
1923 +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1924 +#include "Gget_save_loc.c"
1926 diff --git a/src/aarch64/Lglobal.c b/src/aarch64/Lglobal.c
1927 new file mode 100644
1928 index 0000000..6d7b489
1930 +++ b/src/aarch64/Lglobal.c
1932 +#define UNW_LOCAL_ONLY
1933 +#include <libunwind.h>
1934 +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1935 +#include "Gglobal.c"
1937 diff --git a/src/aarch64/Linit.c b/src/aarch64/Linit.c
1938 new file mode 100644
1939 index 0000000..e9abfdd
1941 +++ b/src/aarch64/Linit.c
1943 +#define UNW_LOCAL_ONLY
1944 +#include <libunwind.h>
1945 +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1948 diff --git a/src/aarch64/Linit_local.c b/src/aarch64/Linit_local.c
1949 new file mode 100644
1950 index 0000000..68a1687
1952 +++ b/src/aarch64/Linit_local.c
1954 +#define UNW_LOCAL_ONLY
1955 +#include <libunwind.h>
1956 +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1957 +#include "Ginit_local.c"
1959 diff --git a/src/aarch64/Linit_remote.c b/src/aarch64/Linit_remote.c
1960 new file mode 100644
1961 index 0000000..58cb04a
1963 +++ b/src/aarch64/Linit_remote.c
1965 +#define UNW_LOCAL_ONLY
1966 +#include <libunwind.h>
1967 +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1968 +#include "Ginit_remote.c"
1970 diff --git a/src/aarch64/Lis_signal_frame.c b/src/aarch64/Lis_signal_frame.c
1971 new file mode 100644
1972 index 0000000..b9a7c4f
1974 +++ b/src/aarch64/Lis_signal_frame.c
1976 +#define UNW_LOCAL_ONLY
1977 +#include <libunwind.h>
1978 +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1979 +#include "Gis_signal_frame.c"
1981 diff --git a/src/aarch64/Lregs.c b/src/aarch64/Lregs.c
1982 new file mode 100644
1983 index 0000000..2c9c75c
1985 +++ b/src/aarch64/Lregs.c
1987 +#define UNW_LOCAL_ONLY
1988 +#include <libunwind.h>
1989 +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
1992 diff --git a/src/aarch64/Lresume.c b/src/aarch64/Lresume.c
1993 new file mode 100644
1994 index 0000000..41a8cf0
1996 +++ b/src/aarch64/Lresume.c
1998 +#define UNW_LOCAL_ONLY
1999 +#include <libunwind.h>
2000 +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
2001 +#include "Gresume.c"
2003 diff --git a/src/aarch64/Lstep.c b/src/aarch64/Lstep.c
2004 new file mode 100644
2005 index 0000000..c1ac3c7
2007 +++ b/src/aarch64/Lstep.c
2009 +#define UNW_LOCAL_ONLY
2010 +#include <libunwind.h>
2011 +#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
2014 diff --git a/src/aarch64/gen-offsets.c b/src/aarch64/gen-offsets.c
2015 new file mode 100644
2016 index 0000000..eadc237
2018 +++ b/src/aarch64/gen-offsets.c
2021 +#include <stddef.h>
2022 +#include <ucontext.h>
2023 +#include <asm/sigcontext.h>
2026 + printf ("#define LINUX_UC_" N "_OFF\t0x%X\n", offsetof (ucontext_t, X))
2029 + printf ("#define LINUX_SC_" N "_OFF\t0x%X\n", offsetof (struct sigcontext, X))
2035 +"/* Linux-specific definitions: */\n\n"
2037 +"/* Define various structure offsets to simplify cross-compilation. */\n\n"
2039 +"/* Offsets for AArch64 Linux \"ucontext_t\": */\n\n");
2041 + UC ("FLAGS", uc_flags);
2042 + UC ("LINK", uc_link);
2043 + UC ("STACK", uc_stack);
2044 + UC ("MCONTEXT", uc_mcontext);
2045 + UC ("SIGMASK", uc_sigmask);
2047 + printf ("\n/* Offsets for AArch64 Linux \"struct sigcontext\": */\n\n");
2049 + SC ("R0", regs[0]);
2050 + SC ("R1", regs[1]);
2051 + SC ("R2", regs[2]);
2052 + SC ("R3", regs[3]);
2053 + SC ("R4", regs[4]);
2054 + SC ("R5", regs[5]);
2055 + SC ("R6", regs[6]);
2056 + SC ("R7", regs[7]);
2057 + SC ("R8", regs[8]);
2058 + SC ("R9", regs[9]);
2059 + SC ("R10", regs[10]);
2060 + SC ("R11", regs[11]);
2061 + SC ("R12", regs[12]);
2062 + SC ("R13", regs[13]);
2063 + SC ("R14", regs[14]);
2064 + SC ("R15", regs[15]);
2065 + SC ("R16", regs[16]);
2066 + SC ("R17", regs[17]);
2067 + SC ("R18", regs[18]);
2068 + SC ("R19", regs[19]);
2069 + SC ("R20", regs[20]);
2070 + SC ("R21", regs[21]);
2071 + SC ("R22", regs[22]);
2072 + SC ("R23", regs[23]);
2073 + SC ("R24", regs[24]);
2074 + SC ("R25", regs[25]);
2075 + SC ("R26", regs[26]);
2076 + SC ("R27", regs[27]);
2077 + SC ("R28", regs[28]);
2078 + SC ("R29", regs[29]);
2079 + SC ("R30", regs[30]);
2080 + SC ("R31", regs[31]);
2084 + SC ("Fault", fault_address);
2085 + SC ("state", pstate);
2088 diff --git a/src/aarch64/init.h b/src/aarch64/init.h
2089 new file mode 100644
2090 index 0000000..0cedc1a
2092 +++ b/src/aarch64/init.h
2094 +/* libunwind - a platform-independent unwind library
2095 + Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
2096 + Copyright (C) 2013 Linaro Limited
2098 +This file is part of libunwind.
2100 +Permission is hereby granted, free of charge, to any person obtaining
2101 +a copy of this software and associated documentation files (the
2102 +"Software"), to deal in the Software without restriction, including
2103 +without limitation the rights to use, copy, modify, merge, publish,
2104 +distribute, sublicense, and/or sell copies of the Software, and to
2105 +permit persons to whom the Software is furnished to do so, subject to
2106 +the following conditions:
2108 +The above copyright notice and this permission notice shall be
2109 +included in all copies or substantial portions of the Software.
2111 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2112 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2113 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2114 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2115 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2116 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2117 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2119 +#include "unwind_i.h"
2122 +common_init (struct cursor *c, unsigned use_prev_instr)
2126 + c->dwarf.loc[UNW_AARCH64_X0] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X0);
2127 + c->dwarf.loc[UNW_AARCH64_X1] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X1);
2128 + c->dwarf.loc[UNW_AARCH64_X2] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X2);
2129 + c->dwarf.loc[UNW_AARCH64_X3] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X3);
2130 + c->dwarf.loc[UNW_AARCH64_X4] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X4);
2131 + c->dwarf.loc[UNW_AARCH64_X5] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X5);
2132 + c->dwarf.loc[UNW_AARCH64_X6] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X6);
2133 + c->dwarf.loc[UNW_AARCH64_X7] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X7);
2134 + c->dwarf.loc[UNW_AARCH64_X8] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X8);
2135 + c->dwarf.loc[UNW_AARCH64_X9] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X9);
2136 + c->dwarf.loc[UNW_AARCH64_X10] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X10);
2137 + c->dwarf.loc[UNW_AARCH64_X11] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X11);
2138 + c->dwarf.loc[UNW_AARCH64_X12] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X12);
2139 + c->dwarf.loc[UNW_AARCH64_X13] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X13);
2140 + c->dwarf.loc[UNW_AARCH64_X14] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X14);
2141 + c->dwarf.loc[UNW_AARCH64_X15] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X15);
2142 + c->dwarf.loc[UNW_AARCH64_X16] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X16);
2143 + c->dwarf.loc[UNW_AARCH64_X17] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X17);
2144 + c->dwarf.loc[UNW_AARCH64_X18] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X18);
2145 + c->dwarf.loc[UNW_AARCH64_X19] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X19);
2146 + c->dwarf.loc[UNW_AARCH64_X20] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X20);
2147 + c->dwarf.loc[UNW_AARCH64_X21] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X21);
2148 + c->dwarf.loc[UNW_AARCH64_X22] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X22);
2149 + c->dwarf.loc[UNW_AARCH64_X23] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X23);
2150 + c->dwarf.loc[UNW_AARCH64_X24] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X24);
2151 + c->dwarf.loc[UNW_AARCH64_X25] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X25);
2152 + c->dwarf.loc[UNW_AARCH64_X26] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X26);
2153 + c->dwarf.loc[UNW_AARCH64_X27] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X27);
2154 + c->dwarf.loc[UNW_AARCH64_X28] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X28);
2155 + c->dwarf.loc[UNW_AARCH64_X29] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X29);
2156 + c->dwarf.loc[UNW_AARCH64_X30] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_X30);
2157 + c->dwarf.loc[UNW_AARCH64_SP] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_SP);
2158 + c->dwarf.loc[UNW_AARCH64_PC] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_PC);
2159 + c->dwarf.loc[UNW_AARCH64_PSTATE] = DWARF_REG_LOC (&c->dwarf,
2160 + UNW_AARCH64_PSTATE);
2161 + c->dwarf.loc[UNW_AARCH64_V0] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V0);
2162 + c->dwarf.loc[UNW_AARCH64_V1] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V1);
2163 + c->dwarf.loc[UNW_AARCH64_V2] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V2);
2164 + c->dwarf.loc[UNW_AARCH64_V3] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V3);
2165 + c->dwarf.loc[UNW_AARCH64_V4] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V4);
2166 + c->dwarf.loc[UNW_AARCH64_V5] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V5);
2167 + c->dwarf.loc[UNW_AARCH64_V6] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V6);
2168 + c->dwarf.loc[UNW_AARCH64_V7] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V7);
2169 + c->dwarf.loc[UNW_AARCH64_V8] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V8);
2170 + c->dwarf.loc[UNW_AARCH64_V9] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V9);
2171 + c->dwarf.loc[UNW_AARCH64_V10] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V10);
2172 + c->dwarf.loc[UNW_AARCH64_V11] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V11);
2173 + c->dwarf.loc[UNW_AARCH64_V12] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V12);
2174 + c->dwarf.loc[UNW_AARCH64_V13] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V13);
2175 + c->dwarf.loc[UNW_AARCH64_V14] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V14);
2176 + c->dwarf.loc[UNW_AARCH64_V15] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V15);
2177 + c->dwarf.loc[UNW_AARCH64_V16] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V16);
2178 + c->dwarf.loc[UNW_AARCH64_V17] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V17);
2179 + c->dwarf.loc[UNW_AARCH64_V18] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V18);
2180 + c->dwarf.loc[UNW_AARCH64_V19] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V19);
2181 + c->dwarf.loc[UNW_AARCH64_V20] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V20);
2182 + c->dwarf.loc[UNW_AARCH64_V21] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V21);
2183 + c->dwarf.loc[UNW_AARCH64_V22] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V22);
2184 + c->dwarf.loc[UNW_AARCH64_V23] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V23);
2185 + c->dwarf.loc[UNW_AARCH64_V24] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V24);
2186 + c->dwarf.loc[UNW_AARCH64_V25] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V25);
2187 + c->dwarf.loc[UNW_AARCH64_V26] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V26);
2188 + c->dwarf.loc[UNW_AARCH64_V27] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V27);
2189 + c->dwarf.loc[UNW_AARCH64_V28] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V28);
2190 + c->dwarf.loc[UNW_AARCH64_V29] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V29);
2191 + c->dwarf.loc[UNW_AARCH64_V30] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V30);
2192 + c->dwarf.loc[UNW_AARCH64_V31] = DWARF_REG_LOC (&c->dwarf, UNW_AARCH64_V31);
2194 + for (i = UNW_AARCH64_PSTATE + 1; i < UNW_AARCH64_V0; ++i)
2195 + c->dwarf.loc[i] = DWARF_NULL_LOC;
2197 + ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_PC], &c->dwarf.ip);
2201 + ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_AARCH64_SP], &c->dwarf.cfa);
2205 + c->sigcontext_format = AARCH64_SCF_NONE;
2206 + c->sigcontext_addr = 0;
2207 + c->sigcontext_sp = 0;
2208 + c->sigcontext_pc = 0;
2210 + c->dwarf.args_size = 0;
2211 + c->dwarf.ret_addr_column = 0;
2212 + c->dwarf.stash_frames = 0;
2213 + c->dwarf.use_prev_instr = use_prev_instr;
2214 + c->dwarf.pi_valid = 0;
2215 + c->dwarf.pi_is_dynamic = 0;
2216 + c->dwarf.hint = 0;
2217 + c->dwarf.prev_rs = 0;
2221 diff --git a/src/aarch64/is_fpreg.c b/src/aarch64/is_fpreg.c
2222 new file mode 100644
2223 index 0000000..7c32693
2225 +++ b/src/aarch64/is_fpreg.c
2227 +/* libunwind - a platform-independent unwind library
2228 + Copyright (C) 2008 CodeSourcery
2229 + Copyright (C) 2013 Linaro Limited
2231 +This file is part of libunwind.
2233 +Permission is hereby granted, free of charge, to any person obtaining
2234 +a copy of this software and associated documentation files (the
2235 +"Software"), to deal in the Software without restriction, including
2236 +without limitation the rights to use, copy, modify, merge, publish,
2237 +distribute, sublicense, and/or sell copies of the Software, and to
2238 +permit persons to whom the Software is furnished to do so, subject to
2239 +the following conditions:
2241 +The above copyright notice and this permission notice shall be
2242 +included in all copies or substantial portions of the Software.
2244 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2245 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2246 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2247 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2248 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2249 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2250 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2252 +#include "libunwind_i.h"
2255 +unw_is_fpreg (int regnum)
2257 + return (regnum >= UNW_AARCH64_V0 && regnum <= UNW_AARCH64_V31);
2259 diff --git a/src/aarch64/offsets.h b/src/aarch64/offsets.h
2260 new file mode 100644
2261 index 0000000..81aa74f
2263 +++ b/src/aarch64/offsets.h
2265 +/* Linux-specific definitions: */
2267 +/* Define various structure offsets to simplify cross-compilation. */
2269 +/* Offsets for AArch64 Linux "ucontext_t": */
2271 +#define LINUX_UC_FLAGS_OFF 0x0
2272 +#define LINUX_UC_LINK_OFF 0x8
2273 +#define LINUX_UC_STACK_OFF 0x10
2274 +#define LINUX_UC_SIGMASK_OFF 0x28
2275 +#define LINUX_UC_MCONTEXT_OFF 0xb0
2277 +/* Offsets for AArch64 Linux "struct sigcontext": */
2279 +#define LINUX_SC_FAULTADDRESS_OFF 0x00
2280 +#define LINUX_SC_X0_OFF 0x008
2281 +#define LINUX_SC_X1_OFF 0x010
2282 +#define LINUX_SC_X2_OFF 0x018
2283 +#define LINUX_SC_X3_OFF 0x020
2284 +#define LINUX_SC_X4_OFF 0x028
2285 +#define LINUX_SC_X5_OFF 0x030
2286 +#define LINUX_SC_X6_OFF 0x038
2287 +#define LINUX_SC_X7_OFF 0x040
2288 +#define LINUX_SC_X8_OFF 0x048
2289 +#define LINUX_SC_X9_OFF 0x050
2290 +#define LINUX_SC_X10_OFF 0x058
2291 +#define LINUX_SC_X11_OFF 0x060
2292 +#define LINUX_SC_X12_OFF 0x068
2293 +#define LINUX_SC_X13_OFF 0x070
2294 +#define LINUX_SC_X14_OFF 0x078
2295 +#define LINUX_SC_X15_OFF 0x080
2296 +#define LINUX_SC_X16_OFF 0x088
2297 +#define LINUX_SC_X17_OFF 0x090
2298 +#define LINUX_SC_X18_OFF 0x098
2299 +#define LINUX_SC_X19_OFF 0x0a0
2300 +#define LINUX_SC_X20_OFF 0x0a8
2301 +#define LINUX_SC_X21_OFF 0x0b0
2302 +#define LINUX_SC_X22_OFF 0x0b8
2303 +#define LINUX_SC_X23_OFF 0x0c0
2304 +#define LINUX_SC_X24_OFF 0x0c8
2305 +#define LINUX_SC_X25_OFF 0x0d0
2306 +#define LINUX_SC_X26_OFF 0x0d8
2307 +#define LINUX_SC_X27_OFF 0x0e0
2308 +#define LINUX_SC_X28_OFF 0x0e8
2309 +#define LINUX_SC_X29_OFF 0x0f0
2310 +#define LINUX_SC_X30_OFF 0x0f8
2311 +#define LINUX_SC_SP_OFF 0x100
2312 +#define LINUX_SC_PC_OFF 0x108
2313 +#define LINUX_SC_PSTATE_OFF 0x110
2314 diff --git a/src/aarch64/regname.c b/src/aarch64/regname.c
2315 new file mode 100644
2316 index 0000000..8c97342
2318 +++ b/src/aarch64/regname.c
2320 +/* libunwind - a platform-independent unwind library
2321 + Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com>
2322 + Copyright (C) 2013 Linaro Limited
2324 +This file is part of libunwind.
2326 +Permission is hereby granted, free of charge, to any person obtaining
2327 +a copy of this software and associated documentation files (the
2328 +"Software"), to deal in the Software without restriction, including
2329 +without limitation the rights to use, copy, modify, merge, publish,
2330 +distribute, sublicense, and/or sell copies of the Software, and to
2331 +permit persons to whom the Software is furnished to do so, subject to
2332 +the following conditions:
2334 +The above copyright notice and this permission notice shall be
2335 +included in all copies or substantial portions of the Software.
2337 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2338 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2339 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2340 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2341 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2342 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2343 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2345 +#include "unwind_i.h"
2347 +static const char *const regname[] =
2349 + [UNW_AARCH64_X0] = "x0",
2350 + [UNW_AARCH64_X1] = "x1",
2351 + [UNW_AARCH64_X2] = "x2",
2352 + [UNW_AARCH64_X3] = "x3",
2353 + [UNW_AARCH64_X4] = "x4",
2354 + [UNW_AARCH64_X5] = "x5",
2355 + [UNW_AARCH64_X6] = "x6",
2356 + [UNW_AARCH64_X7] = "x7",
2357 + [UNW_AARCH64_X8] = "x8",
2358 + [UNW_AARCH64_X9] = "x9",
2359 + [UNW_AARCH64_X10] = "x10",
2360 + [UNW_AARCH64_X11] = "x11",
2361 + [UNW_AARCH64_X12] = "x12",
2362 + [UNW_AARCH64_X13] = "x13",
2363 + [UNW_AARCH64_X14] = "x14",
2364 + [UNW_AARCH64_X15] = "x15",
2365 + [UNW_AARCH64_X16] = "ip0",
2366 + [UNW_AARCH64_X17] = "ip1",
2367 + [UNW_AARCH64_X18] = "x18",
2368 + [UNW_AARCH64_X19] = "x19",
2369 + [UNW_AARCH64_X20] = "x20",
2370 + [UNW_AARCH64_X21] = "x21",
2371 + [UNW_AARCH64_X22] = "x22",
2372 + [UNW_AARCH64_X23] = "x23",
2373 + [UNW_AARCH64_X24] = "x24",
2374 + [UNW_AARCH64_X25] = "x25",
2375 + [UNW_AARCH64_X26] = "x26",
2376 + [UNW_AARCH64_X27] = "x27",
2377 + [UNW_AARCH64_X28] = "x28",
2378 + [UNW_AARCH64_X29] = "fp",
2379 + [UNW_AARCH64_X30] = "lr",
2380 + [UNW_AARCH64_SP] = "sp",
2381 + [UNW_AARCH64_PC] = "pc",
2382 + [UNW_AARCH64_V0] = "v0",
2383 + [UNW_AARCH64_V1] = "v1",
2384 + [UNW_AARCH64_V2] = "v2",
2385 + [UNW_AARCH64_V3] = "v3",
2386 + [UNW_AARCH64_V4] = "v4",
2387 + [UNW_AARCH64_V5] = "v5",
2388 + [UNW_AARCH64_V6] = "v6",
2389 + [UNW_AARCH64_V7] = "v7",
2390 + [UNW_AARCH64_V8] = "v8",
2391 + [UNW_AARCH64_V9] = "v9",
2392 + [UNW_AARCH64_V10] = "v10",
2393 + [UNW_AARCH64_V11] = "v11",
2394 + [UNW_AARCH64_V12] = "v12",
2395 + [UNW_AARCH64_V13] = "v13",
2396 + [UNW_AARCH64_V14] = "v14",
2397 + [UNW_AARCH64_V15] = "v15",
2398 + [UNW_AARCH64_V16] = "v16",
2399 + [UNW_AARCH64_V17] = "v17",
2400 + [UNW_AARCH64_V18] = "v18",
2401 + [UNW_AARCH64_V19] = "v19",
2402 + [UNW_AARCH64_V20] = "v20",
2403 + [UNW_AARCH64_V21] = "v21",
2404 + [UNW_AARCH64_V22] = "v22",
2405 + [UNW_AARCH64_V23] = "v23",
2406 + [UNW_AARCH64_V24] = "v24",
2407 + [UNW_AARCH64_V25] = "v25",
2408 + [UNW_AARCH64_V26] = "v26",
2409 + [UNW_AARCH64_V27] = "v27",
2410 + [UNW_AARCH64_V28] = "v28",
2411 + [UNW_AARCH64_V29] = "v29",
2412 + [UNW_AARCH64_V30] = "v30",
2413 + [UNW_AARCH64_V31] = "v31",
2414 + [UNW_AARCH64_FPSR] = "fpsr",
2415 + [UNW_AARCH64_FPCR] = "fpcr",
2418 +PROTECTED const char *
2419 +unw_regname (unw_regnum_t reg)
2421 + if (reg < (unw_regnum_t) ARRAY_SIZE (regname) && regname[reg] != NULL)
2422 + return regname[reg];
2426 diff --git a/src/aarch64/siglongjmp.S b/src/aarch64/siglongjmp.S
2427 new file mode 100644
2428 index 0000000..9985c4b
2430 +++ b/src/aarch64/siglongjmp.S
2432 + /* Dummy implementation for now. */
2434 + .global _UI_siglongjmp_cont
2435 + .global _UI_longjmp_cont
2437 +_UI_siglongjmp_cont:
2441 + /* We do not need executable stack. */
2442 + .section .note.GNU-stack,"",%progbits
2444 diff --git a/src/aarch64/unwind_i.h b/src/aarch64/unwind_i.h
2445 new file mode 100644
2446 index 0000000..e4947a3
2448 +++ b/src/aarch64/unwind_i.h
2450 +/* libunwind - a platform-independent unwind library
2451 + Copyright (C) 2008 CodeSourcery
2452 + Copyright (C) 2013 Linaro Limited
2454 +This file is part of libunwind.
2456 +Permission is hereby granted, free of charge, to any person obtaining
2457 +a copy of this software and associated documentation files (the
2458 +"Software"), to deal in the Software without restriction, including
2459 +without limitation the rights to use, copy, modify, merge, publish,
2460 +distribute, sublicense, and/or sell copies of the Software, and to
2461 +permit persons to whom the Software is furnished to do so, subject to
2462 +the following conditions:
2464 +The above copyright notice and this permission notice shall be
2465 +included in all copies or substantial portions of the Software.
2467 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2468 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2469 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2470 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
2471 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2472 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2473 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
2478 +#include <stdint.h>
2480 +#include <libunwind-aarch64.h>
2482 +#include "libunwind_i.h"
2484 +#define aarch64_lock UNW_OBJ(lock)
2485 +#define aarch64_local_resume UNW_OBJ(local_resume)
2486 +#define aarch64_local_addr_space_init UNW_OBJ(local_addr_space_init)
2488 +extern void aarch64_local_addr_space_init (void);
2489 +extern int aarch64_local_resume (unw_addr_space_t as, unw_cursor_t *cursor,
2492 +#endif /* unwind_i_h */
2493 diff --git a/src/coredump/_UCD_access_reg_linux.c b/src/coredump/_UCD_access_reg_linux.c
2494 index bc360ad..9dc0904 100644
2495 --- a/src/coredump/_UCD_access_reg_linux.c
2496 +++ b/src/coredump/_UCD_access_reg_linux.c
2497 @@ -39,7 +39,10 @@ _UCD_access_reg (unw_addr_space_t as,
2501 -#if defined(UNW_TARGET_ARM)
2502 +#if defined(UNW_TARGET_AARCH64)
2503 + if (regnum < 0 || regnum >= UNW_AARCH64_FPCR)
2505 +#elif defined(UNW_TARGET_ARM)
2506 if (regnum < 0 || regnum >= 16)
2508 #elif defined(UNW_TARGET_SH)
2509 diff --git a/src/ptrace/_UPT_reg_offset.c b/src/ptrace/_UPT_reg_offset.c
2510 index 765f7d5..ced4896 100644
2511 --- a/src/ptrace/_UPT_reg_offset.c
2512 +++ b/src/ptrace/_UPT_reg_offset.c
2514 /* libunwind - a platform-independent unwind library
2515 Copyright (C) 2003-2004 Hewlett-Packard Co
2516 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
2517 + Copyright (C) 2013 Linaro Limited
2519 This file is part of libunwind.
2521 @@ -501,6 +502,41 @@ const int _UPT_reg_offset[UNW_REG_LAST + 1] =
2522 [UNW_ARM_R15] = 0x3c,
2523 #elif defined(UNW_TARGET_MIPS)
2524 #elif defined(UNW_TARGET_SH)
2525 +#elif defined(UNW_TARGET_AARCH64)
2526 + [UNW_AARCH64_X0] = 0x00,
2527 + [UNW_AARCH64_X1] = 0x08,
2528 + [UNW_AARCH64_X2] = 0x10,
2529 + [UNW_AARCH64_X3] = 0x18,
2530 + [UNW_AARCH64_X4] = 0x20,
2531 + [UNW_AARCH64_X5] = 0x28,
2532 + [UNW_AARCH64_X6] = 0x30,
2533 + [UNW_AARCH64_X7] = 0x38,
2534 + [UNW_AARCH64_X8] = 0x40,
2535 + [UNW_AARCH64_X9] = 0x48,
2536 + [UNW_AARCH64_X10] = 0x50,
2537 + [UNW_AARCH64_X11] = 0x58,
2538 + [UNW_AARCH64_X12] = 0x60,
2539 + [UNW_AARCH64_X13] = 0x68,
2540 + [UNW_AARCH64_X14] = 0x70,
2541 + [UNW_AARCH64_X15] = 0x78,
2542 + [UNW_AARCH64_X16] = 0x80,
2543 + [UNW_AARCH64_X17] = 0x88,
2544 + [UNW_AARCH64_X18] = 0x90,
2545 + [UNW_AARCH64_X19] = 0x98,
2546 + [UNW_AARCH64_X20] = 0xa0,
2547 + [UNW_AARCH64_X21] = 0xa8,
2548 + [UNW_AARCH64_X22] = 0xb0,
2549 + [UNW_AARCH64_X23] = 0xb8,
2550 + [UNW_AARCH64_X24] = 0xc0,
2551 + [UNW_AARCH64_X25] = 0xc8,
2552 + [UNW_AARCH64_X26] = 0xd0,
2553 + [UNW_AARCH64_X27] = 0xd8,
2554 + [UNW_AARCH64_X28] = 0xe0,
2555 + [UNW_AARCH64_X29] = 0xe8,
2556 + [UNW_AARCH64_X30] = 0xf0,
2557 + [UNW_AARCH64_SP] = 0xf8,
2558 + [UNW_AARCH64_PC] = 0x100,
2559 + [UNW_AARCH64_PSTATE] = 0x108