summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael Munday <mike.munday@ibm.com>2017-12-05 10:05:41 -0500
committerDave Watson <davejwatson@fb.com>2018-01-09 07:37:55 -0800
commit441adc46ffe775d83446ec7253f5259864069cba (patch)
treec0b5c5fa1535f7007c047b10a54f4413e8a7dbeb /include
parent4c07b170372feb174e11775a01ea3bd718d636d6 (diff)
downloadlibunwind-441adc46ffe775d83446ec7253f5259864069cba.tar.gz
Add port to Linux on IBM Z (s390x)
This adds a port to Linux on the IBM Z platform (a.k.a s390x). It only supports the 64-bit ABI. Most functionality is working and all the tests pass with the exception of the coredump tests*. Unwinding is only supported if DWARF unwind information is present. libunwind can't currently make use of the backchain (if present). The getcontext/setcontext functions only preserve/restore a subset of registers. Currently this only consists of callee-saved registers and some parameter registers. Vector registers and access registers are not saved (and aren't callee- saved) by getcontext and cannot currently be modified. They will however be restored unmodified after resuming a context from a signal handler. There is no special libunwind support for setjmp, the functionality is emulated using glibc (I think all the ports do this for modern Linux kernels). * Unwinding on s390x requires floating point register access which the coredump library doesn't currently support.
Diffstat (limited to 'include')
-rw-r--r--include/libunwind-s390x.h144
-rw-r--r--include/libunwind.h.in2
-rw-r--r--include/tdep-s390x/dwarf-config.h52
-rw-r--r--include/tdep-s390x/jmpbuf.h35
-rw-r--r--include/tdep-s390x/libunwind_i.h262
-rw-r--r--include/tdep/libunwind_i.h.in2
6 files changed, 497 insertions, 0 deletions
diff --git a/include/libunwind-s390x.h b/include/libunwind-s390x.h
new file mode 100644
index 00000000..d95d700e
--- /dev/null
+++ b/include/libunwind-s390x.h
@@ -0,0 +1,144 @@
+/* libunwind - a platform-independent unwind library
+ Copyright (C) 2002-2004 Hewlett-Packard Co
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
+
+ Modified for s390x by Michael Munday <mike.munday@ibm.com>
+
+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 <sys/types.h>
+#include <inttypes.h>
+#include <ucontext.h>
+
+#define UNW_TARGET s390x
+#define UNW_TARGET_S390X 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 384
+
+typedef uint64_t unw_word_t;
+typedef int64_t unw_sword_t;
+
+typedef long double unw_tdep_fpreg_t;
+
+typedef enum
+ {
+ /* general purpose registers */
+ UNW_S390X_R0,
+ UNW_S390X_R1,
+ UNW_S390X_R2,
+ UNW_S390X_R3,
+ UNW_S390X_R4,
+ UNW_S390X_R5,
+ UNW_S390X_R6,
+ UNW_S390X_R7,
+ UNW_S390X_R8,
+ UNW_S390X_R9,
+ UNW_S390X_R10,
+ UNW_S390X_R11,
+ UNW_S390X_R12,
+ UNW_S390X_R13,
+ UNW_S390X_R14,
+ UNW_S390X_R15,
+
+ /* floating point registers */
+ UNW_S390X_F0,
+ UNW_S390X_F1,
+ UNW_S390X_F2,
+ UNW_S390X_F3,
+ UNW_S390X_F4,
+ UNW_S390X_F5,
+ UNW_S390X_F6,
+ UNW_S390X_F7,
+ UNW_S390X_F8,
+ UNW_S390X_F9,
+ UNW_S390X_F10,
+ UNW_S390X_F11,
+ UNW_S390X_F12,
+ UNW_S390X_F13,
+ UNW_S390X_F14,
+ UNW_S390X_F15,
+
+ /* PSW */
+ UNW_S390X_IP,
+
+ UNW_TDEP_LAST_REG = UNW_S390X_IP,
+
+ /* TODO: access, vector registers */
+
+ /* frame info (read-only) */
+ UNW_S390X_CFA,
+
+ UNW_TDEP_IP = UNW_S390X_IP,
+ UNW_TDEP_SP = UNW_S390X_R15,
+
+ /* TODO: placeholders */
+ UNW_TDEP_EH = UNW_S390X_R0,
+ }
+s390x_regnum_t;
+
+#define UNW_TDEP_NUM_EH_REGS 2 /* XXX Not sure what this means */
+
+typedef struct unw_tdep_save_loc
+ {
+ /* Additional target-dependent info on a save location. */
+ char unused;
+ }
+unw_tdep_save_loc_t;
+
+/* On s390x, we can directly use ucontext_t as the unwind context. */
+typedef ucontext_t unw_tdep_context_t;
+
+typedef struct
+ {
+ /* no s390x-specific auxiliary proc-info */
+ char unused;
+ }
+unw_tdep_proc_info_t;
+
+#include "libunwind-dynamic.h"
+#include "libunwind-common.h"
+
+#define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext)
+#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
+
+extern int unw_tdep_getcontext (unw_tdep_context_t *);
+extern int unw_tdep_is_fpreg (int);
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* LIBUNWIND_H */
diff --git a/include/libunwind.h.in b/include/libunwind.h.in
index 7a56168c..a13e7767 100644
--- a/include/libunwind.h.in
+++ b/include/libunwind.h.in
@@ -25,6 +25,8 @@
# include "libunwind-x86_64.h"
#elif defined __tilegx__
# include "libunwind-tilegx.h"
+#elif defined __s390x__
+# include "libunwind-s390x.h"
#else
# error "Unsupported arch"
#endif
diff --git a/include/tdep-s390x/dwarf-config.h b/include/tdep-s390x/dwarf-config.h
new file mode 100644
index 00000000..ca419bd5
--- /dev/null
+++ b/include/tdep-s390x/dwarf-config.h
@@ -0,0 +1,52 @@
+/* libunwind - a platform-independent unwind library
+ Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P.
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
+
+ Modified for x86_64 by Max Asbock <masbock@us.ibm.com>
+
+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. */
+
+/* copy of include/tdep-x86/dwarf-config.h, modified slightly for x86-64
+ some consolidation is possible here */
+
+#ifndef dwarf_config_h
+#define dwarf_config_h
+
+/* derived from DWARF register mappings in Z ELF ABI */
+#define DWARF_NUM_PRESERVED_REGS 66
+#define DWARF_REGNUM_MAP_LENGTH DWARF_NUM_PRESERVED_REGS
+
+/* Return TRUE if the ADDR_SPACE uses big-endian byte-order. */
+#define dwarf_is_big_endian(addr_space) 1
+
+/* 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;
+ unw_word_t type; /* see S390X_LOC_TYPE_* macros. */
+ }
+dwarf_loc_t;
+
+#endif /* dwarf_config_h */
diff --git a/include/tdep-s390x/jmpbuf.h b/include/tdep-s390x/jmpbuf.h
new file mode 100644
index 00000000..50923752
--- /dev/null
+++ b/include/tdep-s390x/jmpbuf.h
@@ -0,0 +1,35 @@
+/* libunwind - a platform-independent unwind library
+ Copyright (C) 2004 Hewlett-Packard Co
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
+
+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. */
+
+#if defined __linux__
+
+/* Use glibc's jump-buffer indices; NPTL peeks at SP: */
+
+#define JB_SP 9 // __gregs[9]
+#define JB_RP 8 // __gregs[8]
+#define JB_MASK_SAVED 18 // __mask_was_saved
+#define JB_MASK 19 // __saved_mask
+
+#endif
diff --git a/include/tdep-s390x/libunwind_i.h b/include/tdep-s390x/libunwind_i.h
new file mode 100644
index 00000000..4296ea4b
--- /dev/null
+++ b/include/tdep-s390x/libunwind_i.h
@@ -0,0 +1,262 @@
+/* libunwind - a platform-independent unwind library
+ Copyright (C) 2002-2005 Hewlett-Packard Co
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
+
+ Modified for x86_64 by Max Asbock <masbock@us.ibm.com>
+
+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 S390X_LIBUNWIND_I_H
+#define S390X_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"
+
+struct unw_addr_space
+ {
+ struct unw_accessors acc;
+ 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 */
+
+ /* Format of sigcontext structure and address at which it is
+ stored: */
+ enum
+ {
+ S390X_SCF_NONE = 0, /* no signal frame encountered */
+ S390X_SCF_LINUX_SIGFRAME = 1, /* Linux struct sigcontext */
+ S390X_SCF_LINUX_RT_SIGFRAME = 2, /* Linux ucontext_t */
+ }
+ sigcontext_format;
+ unw_word_t sigcontext_addr;
+ unw_word_t sigcontext_sp;
+ unw_word_t sigcontext_pc;
+ int validate;
+ ucontext_t *uc;
+ };
+
+static inline ucontext_t *
+dwarf_get_uc(const struct dwarf_cursor *cursor)
+{
+ const struct cursor *c = (struct cursor *) cursor->as_arg;
+ return c->uc;
+}
+
+#define DWARF_GET_LOC(l) ((l).val)
+# define DWARF_LOC_TYPE_MEM (0 << 0)
+# define DWARF_LOC_TYPE_FP (1 << 0)
+# define DWARF_LOC_TYPE_REG (1 << 1)
+# define DWARF_LOC_TYPE_VAL (1 << 2)
+
+# 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_IS_MEM_LOC(l) ((l).type == DWARF_LOC_TYPE_MEM)
+# define DWARF_IS_VAL_LOC(l) (((l).type & DWARF_LOC_TYPE_VAL) != 0)
+
+# define DWARF_LOC(r, t) ((dwarf_loc_t) { .val = (r), .type = (t) })
+# define DWARF_VAL_LOC(c,v) DWARF_LOC ((v), DWARF_LOC_TYPE_VAL)
+# define DWARF_MEM_LOC(c,m) DWARF_LOC ((m), DWARF_LOC_TYPE_MEM)
+
+#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_REG_LOC(c,r) (DWARF_LOC((unw_word_t) \
+ tdep_uc_addr(dwarf_get_uc(c), (r)), 0))
+# define DWARF_FPREG_LOC(c,r) (DWARF_LOC((unw_word_t) \
+ tdep_uc_addr(dwarf_get_uc(c), (r)), 0))
+
+#else /* !UNW_LOCAL_ONLY */
+
+# 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_REG_LOC(c,r) DWARF_LOC((r), DWARF_LOC_TYPE_REG)
+# define DWARF_FPREG_LOC(c,r) DWARF_LOC((r), (DWARF_LOC_TYPE_REG \
+ | DWARF_LOC_TYPE_FP))
+
+#endif /* !UNW_LOCAL_ONLY */
+
+static inline int
+dwarf_getfp (struct dwarf_cursor *c, dwarf_loc_t loc, unw_fpreg_t *val)
+{
+ assert(sizeof unw_fpreg_t == sizeof unw_word_t);
+
+ if (DWARF_IS_NULL_LOC (loc))
+ return -UNW_EBADREG;
+
+ if (DWARF_IS_FP_LOC (loc))
+ return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), val,
+ 0, c->as_arg);
+ /* FPRs may be saved in GPRs */
+ if (DWARF_IS_REG_LOC (loc))
+ return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), (unw_word_t*)val,
+ 0, c->as_arg);
+ if (DWARF_IS_MEM_LOC (loc))
+ return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), (unw_word_t*)val,
+ 0, c->as_arg);
+ assert(DWARF_IS_VAL_LOC (loc));
+ *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)
+{
+ assert(sizeof unw_fpreg_t == sizeof unw_word_t);
+ assert(!DWARF_IS_VAL_LOC (loc));
+
+ if (DWARF_IS_NULL_LOC (loc))
+ return -UNW_EBADREG;
+
+ if (DWARF_IS_FP_LOC (loc))
+ return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), &val,
+ 1, c->as_arg);
+ /* FPRs may be saved in GPRs */
+ if (DWARF_IS_REG_LOC (loc))
+ return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), (unw_word_t*) &val,
+ 1, c->as_arg);
+
+ assert(DWARF_IS_MEM_LOC (loc));
+ return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), (unw_word_t*) &val,
+ 1, c->as_arg);
+}
+
+static inline int
+dwarf_get (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t *val)
+{
+ assert(sizeof unw_fpreg_t == sizeof unw_word_t);
+
+ if (DWARF_IS_NULL_LOC (loc))
+ return -UNW_EBADREG;
+
+ if (DWARF_IS_REG_LOC (loc))
+ return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), val,
+ 0, c->as_arg);
+ if (DWARF_IS_MEM_LOC (loc))
+ return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), val,
+ 0, c->as_arg);
+ /* GPRs may be saved in FPRs */
+ if (DWARF_IS_FP_LOC (loc))
+ return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), (unw_fpreg_t*)val,
+ 0, c->as_arg);
+ assert(DWARF_IS_VAL_LOC (loc));
+ *val = DWARF_GET_LOC (loc);
+ return 0;
+}
+
+static inline int
+dwarf_put (struct dwarf_cursor *c, dwarf_loc_t loc, unw_word_t val)
+{
+ assert(sizeof unw_fpreg_t == sizeof unw_word_t);
+ assert(!DWARF_IS_VAL_LOC (loc));
+
+ if (DWARF_IS_NULL_LOC (loc))
+ return -UNW_EBADREG;
+
+ if (DWARF_IS_REG_LOC (loc))
+ return (*c->as->acc.access_reg) (c->as, DWARF_GET_LOC (loc), &val,
+ 1, c->as_arg);
+ /* GPRs may be saved in FPRs */
+ if (DWARF_IS_FP_LOC (loc))
+ return (*c->as->acc.access_fpreg) (c->as, DWARF_GET_LOC (loc), (unw_fpreg_t*) &val,
+ 1, c->as_arg);
+
+ assert(DWARF_IS_MEM_LOC (loc));
+ return (*c->as->acc.access_mem) (c->as, DWARF_GET_LOC (loc), &val,
+ 1, c->as_arg);
+}
+
+#define tdep_getcontext_trace unw_getcontext
+#define tdep_init_done UNW_OBJ(init_done)
+#define tdep_init_mem_validate UNW_OBJ(init_mem_validate)
+#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_get_elf_image UNW_ARCH_OBJ(get_elf_image)
+#define tdep_get_exe_image_path UNW_ARCH_OBJ(get_exe_image_path)
+#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) 0
+#define tdep_reuse_frame(c,rs) do {} while(0)
+#define tdep_stash_frame(cs,rs) do {} while(0)
+#define tdep_trace(cur,addr,n) (-UNW_ENOINFO)
+#define tdep_uc_addr UNW_OBJ(uc_addr)
+
+#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) 1
+
+extern int tdep_init_done;
+
+extern void tdep_init (void);
+extern void tdep_init_mem_validate (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 void tdep_get_exe_image_path (char *path);
+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 /* S390X_LIBUNWIND_I_H */
diff --git a/include/tdep/libunwind_i.h.in b/include/tdep/libunwind_i.h.in
index af05a7fb..c4729964 100644
--- a/include/tdep/libunwind_i.h.in
+++ b/include/tdep/libunwind_i.h.in
@@ -25,6 +25,8 @@
# include "tdep-x86_64/libunwind_i.h"
#elif defined __tilegx__
# include "tdep-tilegx/libunwind_i.h"
+#elif defined __s390x__
+# include "tdep-s390x/libunwind_i.h"
#else
# error "Unsupported arch"
#endif