diff options
4 files changed, 2607 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 @@ +From ac6c0a6535975f1dc2da6e4e2766614baac2a14a Mon Sep 17 00:00:00 2001 +From: Yvan Roux <yvan.roux@linaro.org> +Date: Sat, 11 May 2013 09:18:23 -0600 +Subject: [PATCH] AArch64 port. + +Upstream-Status: Backport + +--- + Makefile.am | 6 + README | 1 + configure.ac | 6 + include/libunwind-aarch64.h | 187 ++++++++++++++++++++++ + include/libunwind.h.in | 4 + include/tdep-aarch64/dwarf-config.h | 52 ++++++ + include/tdep-aarch64/jmpbuf.h | 33 +++ + include/tdep-aarch64/libunwind_i.h | 294 +++++++++++++++++++++++++++++++++++ + include/tdep/dwarf-config.h | 4 + include/tdep/jmpbuf.h | 2 + include/tdep/libunwind_i.h.in | 4 + src/Makefile.am | 39 ++++ + src/aarch64/Gcreate_addr_space.c | 60 +++++++ + src/aarch64/Gget_proc_info.c | 39 ++++ + src/aarch64/Gget_save_loc.c | 100 +++++++++++ + src/aarch64/Gglobal.c | 57 ++++++ + src/aarch64/Ginit.c | 187 ++++++++++++++++++++++ + src/aarch64/Ginit_local.c | 55 ++++++ + src/aarch64/Ginit_remote.c | 45 +++++ + src/aarch64/Gis_signal_frame.c | 64 +++++++ + src/aarch64/Gregs.c | 113 +++++++++++++ + src/aarch64/Gresume.c | 177 +++++++++++++++++++++ + src/aarch64/Gstep.c | 129 +++++++++++++++ + src/aarch64/Lcreate_addr_space.c | 5 + src/aarch64/Lget_proc_info.c | 5 + src/aarch64/Lget_save_loc.c | 5 + src/aarch64/Lglobal.c | 5 + src/aarch64/Linit.c | 5 + src/aarch64/Linit_local.c | 5 + src/aarch64/Linit_remote.c | 5 + src/aarch64/Lis_signal_frame.c | 5 + src/aarch64/Lregs.c | 5 + src/aarch64/Lresume.c | 5 + src/aarch64/Lstep.c | 5 + src/aarch64/gen-offsets.c | 68 ++++++++ + src/aarch64/init.h | 127 +++++++++++++++ + src/aarch64/is_fpreg.c | 32 +++ + src/aarch64/offsets.h | 49 +++++ + src/aarch64/regname.c | 106 ++++++++++++ + src/aarch64/siglongjmp.S | 12 + + src/aarch64/unwind_i.h | 43 +++++ + src/coredump/_UCD_access_reg_linux.c | 5 + src/ptrace/_UPT_reg_offset.c | 36 ++++ + 43 files changed, 2184 insertions(+), 7 deletions(-) + create mode 100644 include/libunwind-aarch64.h + create mode 100644 include/tdep-aarch64/dwarf-config.h + create mode 100644 include/tdep-aarch64/jmpbuf.h + create mode 100644 include/tdep-aarch64/libunwind_i.h + create mode 100644 src/aarch64/Gcreate_addr_space.c + create mode 100644 src/aarch64/Gget_proc_info.c + create mode 100644 src/aarch64/Gget_save_loc.c + create mode 100644 src/aarch64/Gglobal.c + create mode 100644 src/aarch64/Ginit.c + create mode 100644 src/aarch64/Ginit_local.c + create mode 100644 src/aarch64/Ginit_remote.c + create mode 100644 src/aarch64/Gis_signal_frame.c + create mode 100644 src/aarch64/Gregs.c + create mode 100644 src/aarch64/Gresume.c + create mode 100644 src/aarch64/Gstep.c + create mode 100644 src/aarch64/Lcreate_addr_space.c + create mode 100644 src/aarch64/Lget_proc_info.c + create mode 100644 src/aarch64/Lget_save_loc.c + create mode 100644 src/aarch64/Lglobal.c + create mode 100644 src/aarch64/Linit.c + create mode 100644 src/aarch64/Linit_local.c + create mode 100644 src/aarch64/Linit_remote.c + create mode 100644 src/aarch64/Lis_signal_frame.c + create mode 100644 src/aarch64/Lregs.c + create mode 100644 src/aarch64/Lresume.c + create mode 100644 src/aarch64/Lstep.c + create mode 100644 src/aarch64/gen-offsets.c + create mode 100644 src/aarch64/init.h + create mode 100644 src/aarch64/is_fpreg.c + create mode 100644 src/aarch64/offsets.h + create mode 100644 src/aarch64/regname.c + create mode 100644 src/aarch64/siglongjmp.S + create mode 100644 src/aarch64/unwind_i.h + +--- a/Makefile.am ++++ b/Makefile.am +@@ -2,6 +2,9 @@ include_HEADERS = include/libunwind-dyna + include/libunwind-ptrace.h \ + include/libunwind-coredump.h + ++if ARCH_AARCH64 ++include_HEADERS += include/libunwind-aarch64.h ++endif + if ARCH_ARM + include_HEADERS += include/libunwind-arm.h + endif +@@ -41,6 +44,9 @@ SUBDIRS = src tests doc + noinst_HEADERS = include/dwarf.h include/dwarf_i.h include/dwarf-eh.h \ + include/compiler.h include/libunwind_i.h include/mempool.h \ + include/remote.h \ ++ include/tdep-aarch64/dwarf-config.h \ ++ include/tdep-aarch64/jmpbuf.h \ ++ include/tdep-aarch64/libunwind_i.h \ + include/tdep-arm/dwarf-config.h include/tdep-arm/ex_tables.h \ + include/tdep-arm/jmpbuf.h include/tdep-arm/libunwind_i.h \ + include/tdep-ia64/jmpbuf.h include/tdep-ia64/rse.h \ +--- a/README ++++ b/README +@@ -9,6 +9,7 @@ several architecture/operating-system co + Linux/IA-64: Fully tested and supported. + Linux/PARISC: Works well, but C library missing unwind-info. + HP-UX/IA-64: Mostly works but known to have some serious limitations. ++ Linux/AArch64: Newly added. + Linux/PPC64: Newly added. + Linux/SuperH: Newly added. + FreeBSD/i386: Newly added. +--- a/configure.ac ++++ b/configure.ac +@@ -104,7 +104,7 @@ SET_ARCH([$target_cpu],[target_arch]) + + AC_ARG_ENABLE(coredump, + AS_HELP_STRING([--enable-coredump],[building libunwind-coredump library]),, +- [AS_CASE([$host_arch], [arm*|mips*|sh*|x86*], [enable_coredump=yes], [enable_coredump=no])] ++ [AS_CASE([$host_arch], [aarch64*|arm*|mips*|sh*|x86*], [enable_coredump=yes], [enable_coredump=no])] + ) + + AC_MSG_CHECKING([if we should build libunwind-coredump]) +@@ -121,6 +121,7 @@ AC_MSG_RESULT([$target_os]) + + AM_CONDITIONAL(BUILD_COREDUMP, test x$enable_coredump = xyes) + AM_CONDITIONAL(REMOTE_ONLY, test x$target_arch != x$host_arch) ++AM_CONDITIONAL(ARCH_AARCH64, test x$target_arch = xaarch64) + AM_CONDITIONAL(ARCH_ARM, test x$target_arch = xarm) + AM_CONDITIONAL(ARCH_IA64, test x$target_arch = xia64) + AM_CONDITIONAL(ARCH_HPPA, test x$target_arch = xhppa) +@@ -137,7 +138,7 @@ AM_CONDITIONAL(OS_FREEBSD, expr x$target + AC_MSG_CHECKING([for ELF helper width]) + case "${target_arch}" in + (arm|hppa|ppc32|x86|sh) use_elf32=yes; AC_MSG_RESULT([32]);; +-(ia64|ppc64|x86_64) use_elf64=yes; AC_MSG_RESULT([64]);; ++(aarch64|ia64|ppc64|x86_64) use_elf64=yes; AC_MSG_RESULT([64]);; + (mips) use_elfxx=yes; AC_MSG_RESULT([xx]);; + *) AC_MSG_ERROR([Unknown ELF target: ${target_arch}]) + esac +@@ -186,6 +187,7 @@ AS_HELP_STRING([--enable-cxx-exceptions] + # C++ exception handling doesn't work too well on x86 + case $target_arch in + x86*) enable_cxx_exceptions=no;; ++ aarch64*) enable_cxx_exceptions=no;; + arm*) enable_cxx_exceptions=no;; + mips*) enable_cxx_exceptions=no;; + *) enable_cxx_exceptions=yes;; +--- /dev/null ++++ b/include/libunwind-aarch64.h +@@ -0,0 +1,187 @@ ++/* libunwind - a platform-independent unwind library ++ Copyright (C) 2001-2004 Hewlett-Packard Co ++ Contributed by David Mosberger-Tang <davidm@hpl.hp.com> ++ Copyright (C) 2013 Linaro Limited ++ ++This file is part of libunwind. ++ ++Permission is hereby granted, free of charge, to any person obtaining ++a copy of this software and associated documentation files (the ++"Software"), to deal in the Software without restriction, including ++without limitation the rights to use, copy, modify, merge, publish, ++distribute, sublicense, and/or sell copies of the Software, and to ++permit persons to whom the Software is furnished to do so, subject to ++the following conditions: ++ ++The above copyright notice and this permission notice shall be ++included in all copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ ++ ++#ifndef LIBUNWIND_H ++#define LIBUNWIND_H ++ ++#if defined(__cplusplus) || defined(c_plusplus) ++extern "C" { ++#endif ++ ++#include <inttypes.h> ++#include <stddef.h> ++#include <ucontext.h> ++ ++#define UNW_TARGET aarch64 ++#define UNW_TARGET_AARCH64 1 ++ ++#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */ ++ ++/* This needs to be big enough to accommodate "struct cursor", while ++ leaving some slack for future expansion. Changing this value will ++ require recompiling all users of this library. Stack allocation is ++ relatively cheap and unwind-state copying is relatively rare, so we ++ want to err on making it rather too big than too small. */ ++ ++#define UNW_TDEP_CURSOR_LEN 4096 ++ ++typedef uint64_t unw_word_t; ++typedef int64_t unw_sword_t; ++ ++typedef long double unw_tdep_fpreg_t; ++ ++typedef struct ++ { ++ /* no aarch64-specific auxiliary proc-info */ ++ } ++unw_tdep_proc_info_t; ++ ++typedef enum ++ { ++ /* 64-bit general registers. */ ++ UNW_AARCH64_X0, ++ UNW_AARCH64_X1, ++ UNW_AARCH64_X2, ++ UNW_AARCH64_X3, ++ UNW_AARCH64_X4, ++ UNW_AARCH64_X5, ++ UNW_AARCH64_X6, ++ UNW_AARCH64_X7, ++ UNW_AARCH64_X8, ++ ++ /* Temporary registers. */ ++ UNW_AARCH64_X9, ++ UNW_AARCH64_X10, ++ UNW_AARCH64_X11, ++ UNW_AARCH64_X12, ++ UNW_AARCH64_X13, ++ UNW_AARCH64_X14, ++ UNW_AARCH64_X15, ++ ++ /* Intra-procedure-call temporary registers. */ ++ UNW_AARCH64_X16, ++ UNW_AARCH64_X17, ++ ++ /* Callee-saved registers. */ ++ UNW_AARCH64_X18, ++ UNW_AARCH64_X19, ++ UNW_AARCH64_X20, ++ UNW_AARCH64_X21, ++ UNW_AARCH64_X22, ++ UNW_AARCH64_X23, ++ UNW_AARCH64_X24, ++ UNW_AARCH64_X25, ++ UNW_AARCH64_X26, ++ UNW_AARCH64_X27, ++ UNW_AARCH64_X28, ++ ++ /* 64-bit frame pointer. */ ++ UNW_AARCH64_X29, ++ ++ /* 64-bit link register. */ ++ UNW_AARCH64_X30, ++ ++ /* 64-bit stack pointer. */ ++ UNW_AARCH64_SP = 31, ++ UNW_AARCH64_PC, ++ UNW_AARCH64_PSTATE, ++ ++ /* 128-bit FP/Advanced SIMD registers. */ ++ UNW_AARCH64_V0 = 64, ++ UNW_AARCH64_V1, ++ UNW_AARCH64_V2, ++ UNW_AARCH64_V3, ++ UNW_AARCH64_V4, ++ UNW_AARCH64_V5, ++ UNW_AARCH64_V6, ++ UNW_AARCH64_V7, ++ UNW_AARCH64_V8, ++ UNW_AARCH64_V9, ++ UNW_AARCH64_V10, ++ UNW_AARCH64_V11, ++ UNW_AARCH64_V12, ++ UNW_AARCH64_V13, ++ UNW_AARCH64_V14, ++ UNW_AARCH64_V15, ++ UNW_AARCH64_V16, ++ UNW_AARCH64_V17, ++ UNW_AARCH64_V18, ++ UNW_AARCH64_V19, ++ UNW_AARCH64_V20, ++ UNW_AARCH64_V21, ++ UNW_AARCH64_V22, ++ UNW_AARCH64_V23, ++ UNW_AARCH64_V24, ++ UNW_AARCH64_V25, ++ UNW_AARCH64_V26, ++ UNW_AARCH64_V27, ++ UNW_AARCH64_V28, ++ UNW_AARCH64_V29, ++ UNW_AARCH64_V30, ++ UNW_AARCH64_V31, ++ ++ UNW_AARCH64_FPSR, ++ UNW_AARCH64_FPCR, ++ ++ /* For AArch64, the CFA is the value of SP (x31) at the call site of the ++ previous frame. */ ++ UNW_AARCH64_CFA = UNW_AARCH64_SP, ++ ++ UNW_TDEP_LAST_REG = UNW_AARCH64_FPCR, ++ ++ UNW_TDEP_IP = UNW_AARCH64_X30, ++ UNW_TDEP_SP = UNW_AARCH64_SP, ++ UNW_TDEP_EH = UNW_AARCH64_X0, ++ ++ } ++aarch64_regnum_t; ++ ++/* Use R0 through R3 to pass exception handling information. */ ++#define UNW_TDEP_NUM_EH_REGS 4 ++ ++typedef struct unw_tdep_save_loc ++ { ++ /* Additional target-dependent info on a save location. */ ++ } ++unw_tdep_save_loc_t; ++ ++ ++/* On AArch64, we can directly use ucontext_t as the unwind context. */ ++typedef ucontext_t unw_tdep_context_t; ++ ++#include "libunwind-common.h" ++#include "libunwind-dynamic.h" ++ ++#define unw_tdep_getcontext(uc) (getcontext (uc), 0) ++#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg) ++ ++extern int unw_tdep_is_fpreg (int); ++ ++#if defined(__cplusplus) || defined(c_plusplus) ++} ++#endif ++ ++#endif /* LIBUNWIND_H */ +--- a/include/libunwind.h.in ++++ b/include/libunwind.h.in +@@ -3,7 +3,9 @@ + + #ifndef UNW_REMOTE_ONLY + +-#if defined __arm__ ++#if defined __aarch64__ ++#include "libunwind-aarch64.h" ++#elif defined __arm__ + # include "libunwind-arm.h" + #elif defined __hppa__ + # include "libunwind-hppa.h" +--- /dev/null ++++ b/include/tdep-aarch64/dwarf-config.h +@@ -0,0 +1,52 @@ ++/* libunwind - a platform-independent unwind library ++ Copyright (C) 2008 CodeSourcery ++ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com> ++ Copyright (C) 2013 Linaro Limited ++ ++This file is part of libunwind. ++ ++Permission is hereby granted, free of charge, to any person obtaining ++a copy of this software and associated documentation files (the ++"Software"), to deal in the Software without restriction, including ++without limitation the rights to use, copy, modify, merge, publish, ++distribute, sublicense, and/or sell copies of the Software, and to ++permit persons to whom the Software is furnished to do so, subject to ++the following conditions: ++ ++The above copyright notice and this permission notice shall be ++included in all copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ ++ ++#ifndef dwarf_config_h ++#define dwarf_config_h ++ ++/* This matches the value udes by GCC (see ++ gcc/config/aarch64/aarch64.h:DWARF_FRAME_REGISTERS. */ ++#define DWARF_NUM_PRESERVED_REGS 97 ++ ++/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */ ++#define dwarf_is_big_endian(addr_space) 0 ++ ++#define dwarf_to_unw_regnum(reg) (((reg) <= UNW_AARCH64_V31) ? (reg) : 0) ++ ++/* Convert a pointer to a dwarf_cursor structure to a pointer to ++ unw_cursor_t. */ ++#define dwarf_to_cursor(c) ((unw_cursor_t *) (c)) ++ ++typedef struct dwarf_loc ++ { ++ unw_word_t val; ++#ifndef UNW_LOCAL_ONLY ++ unw_word_t type; /* see DWARF_LOC_TYPE_* macros. */ ++#endif ++ } ++dwarf_loc_t; ++ ++#endif /* dwarf_config_h */ +--- /dev/null ++++ b/include/tdep-aarch64/jmpbuf.h +@@ -0,0 +1,33 @@ ++/* libunwind - a platform-independent unwind library ++ Copyright (C) 2008 CodeSourcery ++ Copyright (C) 2013 Linaro Limited ++ ++This file is part of libunwind. ++ ++Permission is hereby granted, free of charge, to any person obtaining ++a copy of this software and associated documentation files (the ++"Software"), to deal in the Software without restriction, including ++without limitation the rights to use, copy, modify, merge, publish, ++distribute, sublicense, and/or sell copies of the Software, and to ++permit persons to whom the Software is furnished to do so, subject to ++the following conditions: ++ ++The above copyright notice and this permission notice shall be ++included in all copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ ++ ++/* Use glibc's jump-buffer indices; NPTL peeks at SP: */ ++ ++/* FIXME for AArch64 */ ++ ++#define JB_SP 13 ++#define JB_RP 14 ++#define JB_MASK_SAVED 15 ++#define JB_MASK 16 +--- /dev/null ++++ b/include/tdep-aarch64/libunwind_i.h +@@ -0,0 +1,294 @@ ++/* libunwind - a platform-independent unwind library ++ Copyright (C) 2001-2005 Hewlett-Packard Co ++ Contributed by David Mosberger-Tang <davidm@hpl.hp.com> ++ Copyright (C) 2013 Linaro Limited ++ ++This file is part of libunwind. ++ ++Permission is hereby granted, free of charge, to any person obtaining ++a copy of this software and associated documentation files (the ++"Software"), to deal in the Software without restriction, including ++without limitation the rights to use, copy, modify, merge, publish, ++distribute, sublicense, and/or sell copies of the Software, and to ++permit persons to whom the Software is furnished to do so, subject to ++the following conditions: ++ ++The above copyright notice and this permission notice shall be ++included in all copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ ++ ++#ifndef AARCH64_LIBUNWIND_I_H ++#define AARCH64_LIBUNWIND_I_H ++ ++/* Target-dependent definitions that are internal to libunwind but need ++ to be shared with target-independent code. */ ++ ++#include <stdlib.h> ++#include <libunwind.h> ++ ++#include "elf64.h" ++#include "mempool.h" ++#include "dwarf.h" ++ ++typedef struct ++ { ++ /* no aarch64-specific fast trace */ ++ } ++unw_tdep_frame_t; ++ ++#ifdef UNW_LOCAL_ONLY ++ ++typedef unw_word_t aarch64_loc_t; ++ ++#else /* !UNW_LOCAL_ONLY */ ++ ++typedef struct aarch64_loc ++ { ++ unw_word_t w0, w1; ++ } ++aarch64_loc_t; ++ ++#endif /* !UNW_LOCAL_ONLY */ ++ ++struct unw_addr_space ++ { ++ struct unw_accessors acc; ++ int big_endian; ++ unw_caching_policy_t caching_policy; ++#ifdef HAVE_ATOMIC_OPS_H ++ AO_t cache_generation; ++#else ++ uint32_t cache_generation; ++#endif ++ unw_word_t dyn_generation; /* see dyn-common.h */ ++ unw_word_t dyn_info_list_addr; /* (cached) dyn_info_list_addr */ ++ struct dwarf_rs_cache global_cache; ++ struct unw_debug_frame_list *debug_frames; ++ }; ++ ++struct cursor ++ { ++ struct dwarf_cursor dwarf; /* must be first */ ++ enum ++ { ++ AARCH64_SCF_NONE, ++ AARCH64_SCF_LINUX_RT_SIGFRAME, ++ } ++ sigcontext_format; ++ unw_word_t sigcontext_addr; ++ unw_word_t sigcontext_sp; ++ unw_word_t sigcontext_pc; ++ }; ++ ++#define DWARF_GET_LOC(l) ((l).val) ++ ++#ifdef UNW_LOCAL_ONLY ++# define DWARF_NULL_LOC DWARF_LOC (0, 0) ++# define DWARF_IS_NULL_LOC(l) (DWARF_GET_LOC (l) == 0) ++# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r) }) ++# define DWARF_IS_REG_LOC(l) 0 ++# define DWARF_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \ ++ tdep_uc_addr((c)->as_arg, (r)), 0)) ++# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) ++# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \ ++ tdep_uc_addr((c)->as_arg, (r)), 0)) ++ ++static inline int ++dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) ++{ ++ if (!DWARF_GET_LOC (loc)) ++ return -1; ++ *val = *(unw_fpreg_t *) DWARF_GET_LOC (loc); ++ return 0; ++} ++ ++static inline int ++dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) ++{ ++ if (!DWARF_GET_LOC (loc)) ++ return -1; ++ *(unw_fpreg_t *) DWARF_GET_LOC (loc) = val; ++ return 0; ++} ++ ++static inline int ++dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) ++{ ++ if (!DWARF_GET_LOC (loc)) ++ return -1; ++ *val = *(unw_word_t *) DWARF_GET_LOC (loc); ++ return 0; ++} ++ ++static inline int ++dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) ++{ ++ if (!DWARF_GET_LOC (loc)) ++ return -1; ++ *(unw_word_t *) DWARF_GET_LOC (loc) = val; ++ return 0; ++} ++ ++#else /* !UNW_LOCAL_ONLY */ ++# define DWARF_LOC_TYPE_FP (1 << 0) ++# define DWARF_LOC_TYPE_REG (1 << 1) ++# define DWARF_NULL_LOC DWARF_LOC (0, 0) ++# define DWARF_IS_NULL_LOC(l) \ ++ ({ dwarf_loc_t _l = (l); _l.val == 0 && _l.type == 0; }) ++# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) }) ++# define DWARF_IS_REG_LOC(l) (((l).type & DWARF_LOC_TYPE_REG) != 0) ++# define DWARF_IS_FP_LOC(l) (((l).type & DWARF_LOC_TYPE_FP) != 0) ++# define DWARF_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG) ++# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), 0) ++# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \ ++ | DWARF_LOC_TYPE_FP)) ++ ++static inline int ++dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val) ++{ ++ char *valp = (char *) &val; ++ unw_word_t addr; ++ int ret; ++ ++ if (DWARF_IS_NULL_LOC (loc)) ++ return -UNW_EBADREG; ++ ++ if (DWARF_IS_REG_LOC (loc)) ++ return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), ++ val, 0, c->as_arg); ++ ++ addr = DWARF_GET_LOC (loc); ++ if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, ++ 0, c->as_arg)) < 0) ++ return ret; ++ ++ return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, 0, ++ c->as_arg); ++} ++ ++static inline int ++dwarf_putfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t val) ++{ ++ char *valp = (char *) &val; ++ unw_word_t addr; ++ int ret; ++ ++ if (DWARF_IS_NULL_LOC (loc)) ++ return -UNW_EBADREG; ++ ++ if (DWARF_IS_REG_LOC (loc)) ++ return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), ++ &val, 1, c->as_arg); ++ ++ addr = DWARF_GET_LOC (loc); ++ if ((ret = (*c->as->acc.access_mem) (c->as, addr + 0, (unw_word_t *) valp, ++ 1, c->as_arg)) < 0) ++ return ret; ++ ++ return (*c->as->acc.access_mem) (c->as, addr + 4, (unw_word_t *) valp + 1, ++ 1, c->as_arg); ++} ++ ++static inline int ++dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val) ++{ ++ if (DWARF_IS_NULL_LOC (loc)) ++ return -UNW_EBADREG; ++ ++ /* If a code-generator were to save a value of type unw_word_t in a ++ floating-point register, we would have to support this case. I ++ suppose it could happen with MMX registers, but does it really ++ happen? */ ++ assert (!DWARF_IS_FP_LOC (loc)); ++ ++ if (DWARF_IS_REG_LOC (loc)) ++ return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val, ++ 0, c->as_arg); ++ else ++ return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val, ++ 0, c->as_arg); ++} ++ ++static inline int ++dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val) ++{ ++ if (DWARF_IS_NULL_LOC (loc)) ++ return -UNW_EBADREG; ++ ++ /* If a code-generator were to save a value of type unw_word_t in a ++ floating-point register, we would have to support this case. I ++ suppose it could happen with MMX registers, but does it really ++ happen? */ ++ assert (!DWARF_IS_FP_LOC (loc)); ++ ++ if (DWARF_IS_REG_LOC (loc)) ++ return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val, ++ 1, c->as_arg); ++ else ++ return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val, ++ 1, c->as_arg); ++} ++ ++#endif /* !UNW_LOCAL_ONLY */ ++ ++ ++ ++#define tdep_getcontext_trace unw_getcontext ++#define tdep_init_done UNW_OBJ(init_done) ++#define tdep_init UNW_OBJ(init) ++/* Platforms that support UNW_INFO_FORMAT_TABLE need to define ++ tdep_search_unwind_table. */ ++#define tdep_search_unwind_table dwarf_search_unwind_table ++#define tdep_find_unwind_table dwarf_find_unwind_table ++#define tdep_uc_addr UNW_OBJ(uc_addr) ++#define tdep_get_elf_image UNW_ARCH_OBJ(get_elf_image) ++#define tdep_access_reg UNW_OBJ(access_reg) ++#define tdep_access_fpreg UNW_OBJ(access_fpreg) ++#define tdep_fetch_frame(c,ip,n) do {} while(0) ++#define tdep_cache_frame(c,rs) do {} while(0) ++#define tdep_reuse_frame(c,rs) do {} while(0) ++#define tdep_stash_frame(c,rs) do {} while(0) ++#define tdep_trace(cur,addr,n) (-UNW_ENOINFO) ++ ++#ifdef UNW_LOCAL_ONLY ++# define tdep_find_proc_info(c,ip,n) \ ++ dwarf_find_proc_info((c)->as, (ip), &(c)->pi, (n), \ ++ (c)->as_arg) ++# define tdep_put_unwind_info(as,pi,arg) \ ++ dwarf_put_unwind_info((as), (pi), (arg)) ++#else ++# define tdep_find_proc_info(c,ip,n) \ ++ (*(c)->as->acc.find_proc_info)((c)->as, (ip), &(c)->pi, (n), \ ++ (c)->as_arg) ++# define tdep_put_unwind_info(as,pi,arg) \ ++ (*(as)->acc.put_unwind_info)((as), (pi), (arg)) ++#endif ++ ++#define tdep_get_as(c) ((c)->dwarf.as) ++#define tdep_get_as_arg(c) ((c)->dwarf.as_arg) ++#define tdep_get_ip(c) ((c)->dwarf.ip) ++#define tdep_big_endian(as) ((as)->big_endian) ++ ++extern int tdep_init_done; ++ ++extern void tdep_init (void); ++extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip, ++ unw_dyn_info_t *di, unw_proc_info_t *pi, ++ int need_unwind_info, void *arg); ++extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg); ++extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip, ++ unsigned long *segbase, unsigned long *mapoff, ++ char *path, size_t pathlen); ++extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg, ++ unw_word_t *valp, int write); ++extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, ++ unw_fpreg_t *valp, int write); ++ ++#endif /* AARCH64_LIBUNWIND_I_H */ +--- a/include/tdep/dwarf-config.h ++++ b/include/tdep/dwarf-config.h +@@ -1,7 +1,9 @@ + /* Provide a real file - not a symlink - as it would cause multiarch conflicts + when multiple different arch releases are installed simultaneously. */ + +-#if defined __arm__ ++#if defined __aarch64__ ++# include "tdep-aarch64/dwarf-config.h" ++#elif defined __arm__ + # include "tdep-arm/dwarf-config.h" + #elif defined __hppa__ + # include "tdep-hppa/dwarf-config.h" +--- a/include/tdep/jmpbuf.h ++++ b/include/tdep/jmpbuf.h +@@ -3,6 +3,8 @@ + + #ifndef UNW_REMOTE_ONLY + ++#if defined __aarch64__ ++# include "tdep-aarch64/jmpbuf.h" + #if defined __arm__ + # include "tdep-arm/jmpbuf.h" + #elif defined __hppa__ +--- a/include/tdep/libunwind_i.h.in ++++ b/include/tdep/libunwind_i.h.in +@@ -3,7 +3,9 @@ + + #ifndef UNW_REMOTE_ONLY + +-#if defined __arm__ ++#if defined __aarch64__ ++# include "tdep-aarch64/libunwind_i.h" ++#elif defined __arm__ + # include "tdep-arm/libunwind_i.h" + #elif defined __hppa__ + # include "tdep-hppa/libunwind_i.h" +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -170,6 +170,28 @@ libunwind_elfxx_la_SOURCES = elfxx.c + noinst_LTLIBRARIES += $(LIBUNWIND_ELF) + libunwind_la_LIBADD += $(LIBUNWIND_ELF) + ++# The list of files that go into libunwind and libunwind-aarch64: ++noinst_HEADERS += aarch64/init.h aarch64/offsets.h aarch64/unwind_i.h ++libunwind_la_SOURCES_aarch64_common = $(libunwind_la_SOURCES_common) \ ++ aarch64/is_fpreg.c aarch64/regname.c ++ ++# The list of files that go into libunwind: ++libunwind_la_SOURCES_aarch64 = $(libunwind_la_SOURCES_aarch64_common) \ ++ $(libunwind_la_SOURCES_local) \ ++ aarch64/Lcreate_addr_space.c aarch64/Lget_proc_info.c \ ++ aarch64/Lget_save_loc.c aarch64/Lglobal.c aarch64/Linit.c \ ++ aarch64/Linit_local.c aarch64/Linit_remote.c \ ++ aarch64/Lis_signal_frame.c aarch64/Lregs.c aarch64/Lresume.c \ ++ aarch64/Lstep.c ++ ++libunwind_aarch64_la_SOURCES_aarch64 = $(libunwind_la_SOURCES_aarch64_common) \ ++ $(libunwind_la_SOURCES_generic) \ ++ aarch64/Gcreate_addr_space.c aarch64/Gget_proc_info.c \ ++ aarch64/Gget_save_loc.c aarch64/Gglobal.c aarch64/Ginit.c \ ++ aarch64/Ginit_local.c aarch64/Ginit_remote.c \ ++ aarch64/Gis_signal_frame.c aarch64/Gregs.c aarch64/Gresume.c \ ++ aarch64/Gstep.c ++ + # The list of files that go into libunwind and libunwind-arm: + noinst_HEADERS += arm/init.h arm/offsets.h arm/unwind_i.h + libunwind_la_SOURCES_arm_common = $(libunwind_la_SOURCES_common) \ +@@ -418,6 +440,18 @@ if OS_FREEBSD + libunwind_coredump_la_SOURCES += coredump/_UCD_access_reg_freebsd.c + endif + ++if ARCH_AARCH64 ++ lib_LTLIBRARIES += libunwind-aarch64.la ++ libunwind_la_SOURCES = $(libunwind_la_SOURCES_aarch64) ++ libunwind_aarch64_la_SOURCES = $(libunwind_aarch64_la_SOURCES_aarch64) ++ libunwind_aarch64_la_LDFLAGS = $(COMMON_SO_LDFLAGS) -version-info $(SOVERSION) ++ libunwind_aarch64_la_LIBADD = libunwind-dwarf-generic.la ++ libunwind_aarch64_la_LIBADD += libunwind-elf64.la ++if !REMOTE_ONLY ++ libunwind_aarch64_la_LIBADD += libunwind.la -lc ++endif ++ libunwind_setjmp_la_SOURCES += aarch64/siglongjmp.S ++else + if ARCH_ARM + lib_LTLIBRARIES += libunwind-arm.la + libunwind_la_SOURCES = $(libunwind_la_SOURCES_arm) +@@ -545,6 +579,7 @@ endif # ARCH_MIPS + endif # ARCH_HPPA + endif # ARCH_IA64 + endif # ARCH_ARM ++endif # ARCH_AARCH64 + + # libunwind-setjmp depends on libunwind-$(arch). Therefore must be added + # at the end. +@@ -567,7 +602,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I + AM_CCASFLAGS = $(AM_CPPFLAGS) + noinst_HEADERS += unwind/unwind-internal.h + +-EXTRA_DIST = $(libunwind_la_SOURCES_arm) \ ++EXTRA_DIST = $(libunwind_la_SOURCES_aarch64) \ ++ $(libunwind_la_SOURCES_arm) \ + $(libunwind_la_SOURCES_hppa) \ + $(libunwind_la_SOURCES_ia64) \ + $(libunwind_la_SOURCES_mips) \ +@@ -579,6 +615,7 @@ EXTRA_DIST = $(libunwind_la_SOURCES_arm) + $(libunwind_la_SOURCES_common) \ + $(libunwind_la_SOURCES_local) \ + $(libunwind_la_SOURCES_generic) \ ++ $(libunwind_aarch64_la_SOURCES_aarch64) \ + $(libunwind_arm_la_SOURCES_arm) \ + $(libunwind_hppa_la_SOURCES_hppa) \ + $(libunwind_ia64_la_SOURCES_ia64) \ +--- /dev/null ++++ b/src/aarch64/Gcreate_addr_space.c +@@ -0,0 +1,60 @@ ++/* libunwind - a platform-independent unwind library ++ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com> ++ Copyright (C) 2013 Linaro Limited ++ ++This file is part of libunwind. ++ ++Permission is hereby granted, free of charge, to any person obtaining ++a copy of this software and associated documentation files (the ++"Software"), to deal in the Software without restriction, including ++without limitation the rights to use, copy, modify, merge, publish, ++distribute, sublicense, and/or sell copies of the Software, and to ++permit persons to whom the Software is furnished to do so, subject to ++the following conditions: ++ ++The above copyright notice and this permission notice shall be ++included in all copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ ++ ++#include <string.h> ++#include <stdlib.h> ++ ++#include "unwind_i.h" ++ ++PROTECTED unw_addr_space_t ++unw_create_addr_space (unw_accessors_t *a, int byte_order) ++{ ++#ifdef UNW_LOCAL_ONLY ++ return NULL; ++#else ++ unw_addr_space_t as; ++ ++ /* AArch64 supports little-endian and big-endian. */ ++ if (byte_order != 0 && byte_order != __LITTLE_ENDIAN ++ && byte_order != __BIG_ENDIAN) ++ return NULL; ++ ++ as = malloc (sizeof (*as)); ++ if (!as) ++ return NULL; ++ ++ memset (as, 0, sizeof (*as)); ++ ++ as->acc = *a; ++ ++ /* Default to little-endian for AArch64. */ ++ if (byte_order == 0 || byte_order == __LITTLE_ENDIAN) ++ as->big_endian = 0; ++ else ++ as->big_endian = 1; ++ ++ return as; ++#endif ++} +--- /dev/null ++++ b/src/aarch64/Gget_proc_info.c +@@ -0,0 +1,39 @@ ++/* libunwind - a platform-independent unwind library ++ Copyright (C) 2008 CodeSourcery ++ ++This file is part of libunwind. ++ ++Permission is hereby granted, free of charge, to any person obtaining ++a copy of this software and associated documentation files (the ++"Software"), to deal in the Software without restriction, including ++without limitation the rights to use, copy, modify, merge, publish, ++distribute, sublicense, and/or sell copies of the Software, and to ++permit persons to whom the Software is furnished to do so, subject to ++the following conditions: ++ ++The above copyright notice and this permission notice shall be ++included in all copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ ++ ++#include "unwind_i.h" ++ ++PROTECTED int ++unw_get_proc_info (unw_cursor_t *cursor, unw_proc_info_t *pi) ++{ ++ struct cursor *c = (struct cursor *) cursor; ++ int ret; ++ ++ ret = dwarf_make_proc_info (&c->dwarf); ++ if (ret < 0) ++ return ret; ++ ++ *pi = c->dwarf.pi; ++ return 0; ++} +--- /dev/null ++++ b/src/aarch64/Gget_save_loc.c +@@ -0,0 +1,100 @@ ++/* libunwind - a platform-independent unwind library ++ Copyright (C) 2008 CodeSourcery ++ Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com> ++ Copyright (C) 2013 Linaro Limited ++ ++This file is part of libunwind. ++ ++Permission is hereby granted, free of charge, to any person obtaining ++a copy of this software and associated documentation files (the ++"Software"), to deal in the Software without restriction, including ++without limitation the rights to use, copy, modify, merge, publish, ++distribute, sublicense, and/or sell copies of the Software, and to ++permit persons to whom the Software is furnished to do so, subject to ++the following conditions: ++ ++The above copyright notice and this permission notice shall be ++included in all copies or substantial portions of the Software. ++ ++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ++LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ++OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ++WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ ++ ++#include "unwind_i.h" ++ ++PROTECTED int ++u |
