]> granicus.if.org Git - strace/commitdiff
Refactor stack pointers
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 4 Dec 2018 22:31:41 +0000 (22:31 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 5 Dec 2018 16:10:05 +0000 (16:10 +0000)
Change all linux/*/arch_regs.c to provide either ARCH_SP_REG
or ARCH_SP_PEEK_ADDR.  Introduce get_stack_pointer(), rewrite
all code accessing stack pointers to use get_stack_pointer().
On some architectures stack pointers were referred to as frame pointers,
clean up this confusion.

* defs.h (get_stack_pointer): New prototype.
* syscall.c (get_stack_pointer): New function.
* linux/arch_rt_sigframe.c: New file.
* linux/aarch64/arch_regs.c (aarch64_sp_ptr, arm_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/alpha/arch_regs.c: Import linux/alpha/arch_regs.h.
(REG_FP): Rename to REG_SP.
(ARCH_SP_PEEK_ADDR): New macro.
* linux/alpha/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/arc/arch_regs.c (arc_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/arm/arch_regs.c (arm_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/arm/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/avr32/arch_regs.c (avr32_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/bfin/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/hppa/arch_regs.c: Import linux/hppa/arch_regs.h.
(PT_GR30, ARCH_SP_PEEK_ADDR): New macros.
* linux/hppa/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/i386/arch_regs.c (i386_esp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/i386/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/i386/arch_sigreturn.c (arch_sigreturn): Likewise.
* linux/ia64/arch_regs.c (ia64_frame_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/ia64/arch_regs.h (ia64_frame_ptr): Remove.
* linux/ia64/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/m68k/arch_regs.c (m68k_usp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/m68k/arch_rt_sigframe.c: Link to i386/arch_rt_sigframe.c.
* linux/m68k/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/metag/arch_regs.c (metag_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/metag/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/microblaze/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/mips/arch_regs.c: Import linux/mips/arch_regs.h.
(mips_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/mips/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/nios2/arch_regs.c (nios2_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/or1k/arch_regs.c (or1k_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/powerpc/arch_regs.c (ppc_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/powerpc/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/powerpc/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/powerpc64/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/riscv/arch_regs.c (riscv_sp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/s390/arch_regs.c (s390_frame_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/s390/arch_sigreturn.c (S390_FRAME_PTR): Remove.
(arch_sigreturn): Use get_stack_pointer.
* linux/s390x/arch_regs.c (s390_frame_ptr, s390x_frame_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/s390x/arch_sigreturn.c (S390_FRAME_PTR): Remove.
* linux/sh/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/sh64/arch_regs.c: Likewise.
* linux/sparc/arch_regs.c: Import linux/sparc/arch_regs.h.
(sparc_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/sparc/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/sparc64/arch_rt_sigframe.c (FUNC_GET_RT_SIGFRAME_ADDR): Use
get_stack_pointer.
* linux/tile/arch_regs.c (tile_regs): Add static qualifier.
(ARCH_SP_REG): New macro.
* linux/tile/arch_sigreturn.c (arch_sigreturn): Use get_stack_pointer.
* linux/x86_64/arch_regs.c (i386_esp_ptr, x86_64_rsp_ptr): Remove.
(ARCH_SP_REG): New macro.
* linux/x86_64/arch_regs.h (i386_esp_ptr, x86_64_rsp_ptr): Remove.
* linux/x86_64/arch_rt_sigframe.c: Link to i386/arch_rt_sigframe.c.
* linux/xtensa/arch_regs.c (ARCH_SP_PEEK_ADDR): New macro.
* linux/aarch64/arch_regs.h: Remove.
* linux/aarch64/arch_rt_sigframe.c: Remove.
* linux/alpha/arch_regs.h: Remove.
* linux/alpha/arch_rt_sigframe.c: Remove.
* linux/arc/arch_regs.h: Remove.
* linux/arc/arch_rt_sigframe.c: Remove.
* linux/arm/arch_regs.h: Remove.
* linux/arm/arch_rt_sigframe.c: Remove.
* linux/avr32/arch_regs.h: Remove.
* linux/avr32/arch_rt_sigframe.c: Remove.
* linux/bfin/arch_rt_sigframe.c: Remove.
* linux/hppa/arch_regs.h: Remove.
* linux/i386/arch_regs.h: Remove.
* linux/m68k/arch_regs.h: Remove.
* linux/metag/arch_regs.h: Remove.
* linux/microblaze/arch_rt_sigframe.c: Remove.
* linux/mips/arch_regs.h: Remove.
* linux/mips/arch_rt_sigframe.c: Remove.
* linux/nios2/arch_regs.h: Remove.
* linux/nios2/arch_rt_sigframe.c: Remove.
* linux/or1k/arch_regs.h: Remove.
* linux/or1k/arch_rt_sigframe.c: Remove.
* linux/powerpc/arch_regs.h: Remove.
* linux/powerpc64/arch_regs.h: Remove.
* linux/riscv/arch_regs.h: Remove.
* linux/riscv/arch_rt_sigframe.c: Remove.
* linux/s390/arch_regs.h: Remove.
* linux/s390/arch_rt_sigframe.c: Remove.
* linux/s390x/arch_regs.h: Remove.
* linux/s390x/arch_rt_sigframe.c: Remove.
* linux/sh/arch_rt_sigframe.c: Remove.
* linux/sh64/arch_rt_sigframe.c: Remove.
* linux/sparc/arch_regs.h: Remove.
* linux/sparc/arch_rt_sigframe.c: Remove.
* linux/sparc64/arch_regs.h: Remove.
* linux/tile/arch_regs.h: Remove.
* linux/tile/arch_rt_sigframe.c: Remove.
* linux/xtensa/arch_rt_sigframe.c: Remove.
* Makefile.am (EXTRA_DIST): Remove them, add linux/arch_rt_sigframe.c.

87 files changed:
Makefile.am
defs.h
linux/aarch64/arch_regs.c
linux/aarch64/arch_regs.h [deleted file]
linux/aarch64/arch_rt_sigframe.c [deleted file]
linux/alpha/arch_regs.c
linux/alpha/arch_regs.h [deleted file]
linux/alpha/arch_rt_sigframe.c [deleted file]
linux/alpha/arch_sigreturn.c
linux/arc/arch_regs.c
linux/arc/arch_regs.h [deleted file]
linux/arc/arch_rt_sigframe.c [deleted file]
linux/arch_rt_sigframe.c [moved from linux/bfin/arch_rt_sigframe.c with 88% similarity]
linux/arm/arch_regs.c
linux/arm/arch_regs.h [deleted file]
linux/arm/arch_rt_sigframe.c [deleted file]
linux/arm/arch_sigreturn.c
linux/avr32/arch_regs.c
linux/avr32/arch_regs.h [deleted file]
linux/avr32/arch_rt_sigframe.c [deleted file]
linux/bfin/arch_regs.c
linux/hppa/arch_regs.c
linux/hppa/arch_regs.h [deleted file]
linux/hppa/arch_rt_sigframe.c
linux/i386/arch_regs.c
linux/i386/arch_regs.h [deleted file]
linux/i386/arch_rt_sigframe.c
linux/i386/arch_sigreturn.c
linux/ia64/arch_regs.c
linux/ia64/arch_regs.h
linux/ia64/arch_rt_sigframe.c
linux/m68k/arch_regs.c
linux/m68k/arch_regs.h [deleted file]
linux/m68k/arch_rt_sigframe.c
linux/m68k/arch_sigreturn.c
linux/metag/arch_regs.c
linux/metag/arch_regs.h [deleted file]
linux/metag/arch_rt_sigframe.c
linux/microblaze/arch_regs.c
linux/microblaze/arch_rt_sigframe.c [deleted file]
linux/mips/arch_regs.c
linux/mips/arch_regs.h [deleted file]
linux/mips/arch_rt_sigframe.c [deleted file]
linux/mips/arch_sigreturn.c
linux/nios2/arch_regs.c
linux/nios2/arch_regs.h [deleted file]
linux/nios2/arch_rt_sigframe.c [deleted file]
linux/or1k/arch_regs.c
linux/or1k/arch_regs.h [deleted file]
linux/or1k/arch_rt_sigframe.c [deleted file]
linux/powerpc/arch_regs.c
linux/powerpc/arch_regs.h [deleted file]
linux/powerpc/arch_rt_sigframe.c
linux/powerpc/arch_sigreturn.c
linux/powerpc64/arch_regs.h [deleted file]
linux/powerpc64/arch_rt_sigframe.c
linux/riscv/arch_regs.c
linux/riscv/arch_regs.h [deleted file]
linux/riscv/arch_rt_sigframe.c [deleted file]
linux/s390/arch_regs.c
linux/s390/arch_regs.h [deleted file]
linux/s390/arch_rt_sigframe.c [deleted file]
linux/s390/arch_sigreturn.c
linux/s390x/arch_regs.c
linux/s390x/arch_regs.h [deleted file]
linux/s390x/arch_rt_sigframe.c [deleted file]
linux/s390x/arch_sigreturn.c
linux/sh/arch_regs.c
linux/sh/arch_rt_sigframe.c [deleted file]
linux/sh64/arch_regs.c
linux/sh64/arch_rt_sigframe.c [deleted file]
linux/sparc/arch_regs.c
linux/sparc/arch_regs.h [deleted file]
linux/sparc/arch_rt_sigframe.c [deleted file]
linux/sparc/arch_sigreturn.c
linux/sparc64/arch_regs.h [deleted file]
linux/sparc64/arch_rt_sigframe.c
linux/tile/arch_regs.c
linux/tile/arch_regs.h [deleted file]
linux/tile/arch_rt_sigframe.c [deleted file]
linux/tile/arch_sigreturn.c
linux/x86_64/arch_regs.c
linux/x86_64/arch_regs.h
linux/x86_64/arch_rt_sigframe.c
linux/xtensa/arch_regs.c
linux/xtensa/arch_rt_sigframe.c [deleted file]
syscall.c

index 66111ceef89b1f2777e17f9cca728276937c63b4..7da98a360b5d2d9d5409ccc2a139b3d0bd6faa72 100644 (file)
@@ -434,8 +434,6 @@ EXTRA_DIST =                                \
        linux/64/syscallent.h           \
        linux/aarch64/arch_defs_.h      \
        linux/aarch64/arch_regs.c       \
-       linux/aarch64/arch_regs.h       \
-       linux/aarch64/arch_rt_sigframe.c        \
        linux/aarch64/arch_sigreturn.c  \
        linux/aarch64/get_error.c       \
        linux/aarch64/get_scno.c        \
@@ -454,8 +452,6 @@ EXTRA_DIST =                                \
        linux/alpha/arch_defs_.h        \
        linux/alpha/arch_getrval2.c     \
        linux/alpha/arch_regs.c         \
-       linux/alpha/arch_regs.h         \
-       linux/alpha/arch_rt_sigframe.c  \
        linux/alpha/arch_sigreturn.c    \
        linux/alpha/errnoent.h          \
        linux/alpha/get_error.c         \
@@ -471,8 +467,6 @@ EXTRA_DIST =                                \
        linux/alpha/syscallent.h        \
        linux/alpha/userent.h           \
        linux/arc/arch_regs.c           \
-       linux/arc/arch_regs.h           \
-       linux/arc/arch_rt_sigframe.c    \
        linux/arc/get_error.c           \
        linux/arc/get_scno.c            \
        linux/arc/get_syscall_args.c    \
@@ -485,11 +479,10 @@ EXTRA_DIST =                              \
        linux/arch_defs_.h              \
        linux/arch_kvm.c                \
        linux/arch_regs.h               \
+       linux/arch_rt_sigframe.c        \
        linux/arch_sigreturn.c          \
        linux/arm/arch_defs_.h          \
        linux/arm/arch_regs.c           \
-       linux/arm/arch_regs.h           \
-       linux/arm/arch_rt_sigframe.c    \
        linux/arm/arch_sigreturn.c      \
        linux/arm/get_error.c           \
        linux/arm/get_scno.c            \
@@ -504,8 +497,6 @@ EXTRA_DIST =                                \
        linux/arm/syscallent.h          \
        linux/arm/userent.h             \
        linux/avr32/arch_regs.c         \
-       linux/avr32/arch_regs.h         \
-       linux/avr32/arch_rt_sigframe.c  \
        linux/avr32/get_error.c         \
        linux/avr32/get_scno.c          \
        linux/avr32/get_syscall_args.c  \
@@ -518,7 +509,6 @@ EXTRA_DIST =                                \
        linux/avr32/userent.h           \
        linux/bfin/arch_defs_.h         \
        linux/bfin/arch_regs.c          \
-       linux/bfin/arch_rt_sigframe.c   \
        linux/bfin/get_error.c          \
        linux/bfin/get_scno.c           \
        linux/bfin/get_syscall_args.c   \
@@ -536,7 +526,6 @@ EXTRA_DIST =                                \
        linux/getregs_old.h             \
        linux/hppa/arch_defs_.h         \
        linux/hppa/arch_regs.c          \
-       linux/hppa/arch_regs.h          \
        linux/hppa/arch_rt_sigframe.c   \
        linux/hppa/errnoent.h           \
        linux/hppa/get_error.c          \
@@ -554,7 +543,6 @@ EXTRA_DIST =                                \
        linux/i386/arch_kvm.c           \
        linux/i386/arch_defs_.h         \
        linux/i386/arch_regs.c          \
-       linux/i386/arch_regs.h          \
        linux/i386/arch_rt_sigframe.c   \
        linux/i386/arch_sigreturn.c     \
        linux/i386/get_error.c          \
@@ -588,7 +576,6 @@ EXTRA_DIST =                                \
        linux/inet_diag.h               \
        linux/m68k/arch_defs_.h         \
        linux/m68k/arch_regs.c          \
-       linux/m68k/arch_regs.h          \
        linux/m68k/arch_rt_sigframe.c   \
        linux/m68k/arch_sigreturn.c     \
        linux/m68k/get_error.c          \
@@ -603,7 +590,6 @@ EXTRA_DIST =                                \
        linux/m68k/syscallent.h         \
        linux/m68k/userent.h            \
        linux/metag/arch_regs.c         \
-       linux/metag/arch_regs.h         \
        linux/metag/arch_rt_sigframe.c  \
        linux/metag/get_error.c         \
        linux/metag/get_scno.c          \
@@ -616,7 +602,6 @@ EXTRA_DIST =                                \
        linux/metag/syscallent.h        \
        linux/microblaze/arch_defs_.h   \
        linux/microblaze/arch_regs.c    \
-       linux/microblaze/arch_rt_sigframe.c     \
        linux/microblaze/arch_sigreturn.c       \
        linux/microblaze/get_error.c    \
        linux/microblaze/get_scno.c     \
@@ -632,8 +617,6 @@ EXTRA_DIST =                                \
        linux/mips/arch_defs_.h         \
        linux/mips/arch_getrval2.c      \
        linux/mips/arch_regs.c          \
-       linux/mips/arch_regs.h          \
-       linux/mips/arch_rt_sigframe.c   \
        linux/mips/arch_sigreturn.c     \
        linux/mips/errnoent.h           \
        linux/mips/genstub.sh           \
@@ -656,8 +639,6 @@ EXTRA_DIST =                                \
        linux/netlink_diag.h            \
        linux/nios2/arch_defs_.h        \
        linux/nios2/arch_regs.c         \
-       linux/nios2/arch_regs.h         \
-       linux/nios2/arch_rt_sigframe.c  \
        linux/nios2/get_error.c         \
        linux/nios2/get_scno.c          \
        linux/nios2/get_syscall_args.c  \
@@ -669,8 +650,6 @@ EXTRA_DIST =                                \
        linux/nios2/syscallent.h        \
        linux/nr_prefix.c               \
        linux/or1k/arch_regs.c          \
-       linux/or1k/arch_regs.h          \
-       linux/or1k/arch_rt_sigframe.c   \
        linux/or1k/get_error.c          \
        linux/or1k/get_scno.c           \
        linux/or1k/get_syscall_args.c   \
@@ -684,7 +663,6 @@ EXTRA_DIST =                                \
        linux/packet_diag.h             \
        linux/powerpc/arch_defs_.h      \
        linux/powerpc/arch_regs.c       \
-       linux/powerpc/arch_regs.h       \
        linux/powerpc/arch_rt_sigframe.c        \
        linux/powerpc/arch_sigreturn.c  \
        linux/powerpc/errnoent.h        \
@@ -702,7 +680,6 @@ EXTRA_DIST =                                \
        linux/powerpc/userent.h         \
        linux/powerpc64/arch_defs_.h    \
        linux/powerpc64/arch_regs.c     \
-       linux/powerpc64/arch_regs.h     \
        linux/powerpc64/arch_rt_sigframe.c      \
        linux/powerpc64/arch_sigreturn.c        \
        linux/powerpc64/errnoent.h      \
@@ -725,8 +702,6 @@ EXTRA_DIST =                                \
        linux/raw_syscall.h             \
        linux/riscv/arch_defs_.h        \
        linux/riscv/arch_regs.c         \
-       linux/riscv/arch_regs.h         \
-       linux/riscv/arch_rt_sigframe.c  \
        linux/riscv/get_error.c         \
        linux/riscv/get_scno.c          \
        linux/riscv/get_syscall_args.c  \
@@ -742,8 +717,6 @@ EXTRA_DIST =                                \
        linux/rt_sigframe.h             \
        linux/s390/arch_defs_.h         \
        linux/s390/arch_regs.c          \
-       linux/s390/arch_regs.h          \
-       linux/s390/arch_rt_sigframe.c   \
        linux/s390/arch_sigreturn.c     \
        linux/s390/get_error.c          \
        linux/s390/get_scno.c           \
@@ -760,8 +733,6 @@ EXTRA_DIST =                                \
        linux/s390/userent1.h           \
        linux/s390x/arch_defs_.h        \
        linux/s390x/arch_regs.c         \
-       linux/s390x/arch_regs.h         \
-       linux/s390x/arch_rt_sigframe.c  \
        linux/s390x/arch_sigreturn.c    \
        linux/s390x/get_error.c         \
        linux/s390x/get_scno.c          \
@@ -780,7 +751,6 @@ EXTRA_DIST =                                \
        linux/sh/arch_defs_.h           \
        linux/sh/arch_getrval2.c        \
        linux/sh/arch_regs.c            \
-       linux/sh/arch_rt_sigframe.c     \
        linux/sh/get_error.c            \
        linux/sh/get_scno.c             \
        linux/sh/get_syscall_args.c     \
@@ -796,7 +766,6 @@ EXTRA_DIST =                                \
        linux/sh64/arch_defs_.h         \
        linux/sh64/arch_regs.c          \
        linux/sh64/arch_regs.h          \
-       linux/sh64/arch_rt_sigframe.c   \
        linux/sh64/get_error.c          \
        linux/sh64/get_scno.c           \
        linux/sh64/get_syscall_args.c   \
@@ -817,8 +786,6 @@ EXTRA_DIST =                                \
        linux/sparc/arch_defs_.h        \
        linux/sparc/arch_getrval2.c     \
        linux/sparc/arch_regs.c         \
-       linux/sparc/arch_regs.h         \
-       linux/sparc/arch_rt_sigframe.c  \
        linux/sparc/arch_sigreturn.c    \
        linux/sparc/errnoent.h          \
        linux/sparc/get_error.c         \
@@ -836,7 +803,6 @@ EXTRA_DIST =                                \
        linux/sparc64/arch_defs_.h      \
        linux/sparc64/arch_getrval2.c   \
        linux/sparc64/arch_regs.c       \
-       linux/sparc64/arch_regs.h       \
        linux/sparc64/arch_rt_sigframe.c        \
        linux/sparc64/arch_sigreturn.c  \
        linux/sparc64/errnoent.h        \
@@ -859,8 +825,6 @@ EXTRA_DIST =                                \
        linux/syscall.h                 \
        linux/tile/arch_defs_.h         \
        linux/tile/arch_regs.c          \
-       linux/tile/arch_regs.h          \
-       linux/tile/arch_rt_sigframe.c   \
        linux/tile/arch_sigreturn.c     \
        linux/tile/get_error.c          \
        linux/tile/get_scno.c           \
@@ -927,7 +891,6 @@ EXTRA_DIST =                                \
        linux/x86_64/syscallent2.h      \
        linux/x86_64/userent.h          \
        linux/xtensa/arch_regs.c        \
-       linux/xtensa/arch_rt_sigframe.c \
        linux/xtensa/get_error.c        \
        linux/xtensa/get_scno.c         \
        linux/xtensa/get_syscall_args.c \
diff --git a/defs.h b/defs.h
index 3003a5569823f3c6a8b679f21defb9aa8613d8e2..25c9f4db37d3ad25082109d57114793b796092ae 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -443,6 +443,7 @@ extern void set_sortby(const char *);
 extern void set_overhead(int);
 
 extern bool get_instruction_pointer(struct tcb *, kernel_ulong_t *);
+extern bool get_stack_pointer(struct tcb *, kernel_ulong_t *);
 extern void print_instruction_pointer(struct tcb *);
 
 extern int syscall_entering_decode(struct tcb *);
index 234d8c3b67f7f345feae6c8b03a129267e77f427..03cd7d4c007fd162ea5a584d2717910957148f71 100644 (file)
@@ -27,15 +27,16 @@ static union {
 #define aarch64_regs   arm_regs_union.aarch64_r
 #define arm_regs       arm_regs_union.arm_r
 
-uint64_t *const aarch64_sp_ptr = (uint64_t *) &aarch64_regs.sp;
-uint32_t *const arm_sp_ptr = &arm_regs.ARM_sp;
 static struct iovec aarch64_io = {
        .iov_base = &arm_regs_union
 };
 
 #define ARCH_REGS_FOR_GETREGSET arm_regs_union
 #define ARCH_IOVEC_FOR_GETREGSET aarch64_io
-#define ARCH_PC_REG ((aarch64_io.iov_len == sizeof(arm_regs)) ? arm_regs.ARM_pc : aarch64_regs.pc)
+#define ARCH_PC_REG \
+       ((aarch64_io.iov_len == sizeof(arm_regs)) ? arm_regs.ARM_pc : aarch64_regs.pc)
+#define ARCH_SP_REG \
+       ((aarch64_io.iov_len == sizeof(arm_regs)) ? arm_regs.ARM_sp : aarch64_regs.sp)
 
 #define ARCH_PERSONALITY_0_IOV_SIZE sizeof(aarch64_regs)
 #define ARCH_PERSONALITY_1_IOV_SIZE sizeof(arm_regs)
diff --git a/linux/aarch64/arch_regs.h b/linux/aarch64/arch_regs.h
deleted file mode 100644 (file)
index 9a5e33e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-extern uint64_t *const aarch64_sp_ptr;
-extern uint32_t *const arm_sp_ptr;
diff --git a/linux/aarch64/arch_rt_sigframe.c b/linux/aarch64/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 5400a52..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#undef FUNC_GET_RT_SIGFRAME_ADDR
-#define        FUNC_GET_RT_SIGFRAME_ADDR       \
-       static kernel_ulong_t arm_get_rt_sigframe_addr(struct tcb *tcp)
-
-#include "arm/arch_rt_sigframe.c"
-
-#undef FUNC_GET_RT_SIGFRAME_ADDR
-#define        FUNC_GET_RT_SIGFRAME_ADDR       DEF_FUNC_GET_RT_SIGFRAME_ADDR
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return tcp->currpers == 1 ? arm_get_rt_sigframe_addr(tcp)
-                                 : *aarch64_sp_ptr;
-}
index 4d397996286dc4c152fc6dc255a89de6894c7c99..a35e8651f4098327078812492aeea780ae7c464a 100644 (file)
@@ -1,3 +1,11 @@
 static unsigned long alpha_r0;
 static unsigned long alpha_a3;
+
+#define REG_R0 0
+#define REG_A0 16
+#define REG_A3 19
+#define REG_SP 30
+#define REG_PC 64
+
 #define ARCH_PC_PEEK_ADDR REG_PC
+#define ARCH_SP_PEEK_ADDR REG_SP
diff --git a/linux/alpha/arch_regs.h b/linux/alpha/arch_regs.h
deleted file mode 100644 (file)
index 66277fd..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#define REG_R0 0
-#define REG_A0 16
-#define REG_A3 19
-#define REG_FP 30
-#define REG_PC 64
diff --git a/linux/alpha/arch_rt_sigframe.c b/linux/alpha/arch_rt_sigframe.c
deleted file mode 100644 (file)
index d341be1..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       unsigned long addr;
-
-       return upeek(tcp, REG_FP, &addr) ? 0 : addr;
-}
index 396187ab88b6f77116c3f57316833feb8efe31c8..b8b7716ef6968a17426c9cd41fb038dc040cb9ae 100644 (file)
@@ -3,7 +3,7 @@ arch_sigreturn(struct tcb *tcp)
 {
        unsigned long addr;
 
-       if (upeek(tcp, REG_FP, &addr) < 0)
+       if (!get_stack_pointer(tcp, &addr))
                return;
        addr += offsetof(struct sigcontext, sc_mask);
 
index 88bb799887f00d920082f8daf3203b4f4657dcdd..07849a3ceed32e8d744113e23def8a1d0b744efd 100644 (file)
@@ -1,4 +1,4 @@
 static struct user_regs_struct arc_regs;
-unsigned long *const arc_sp_ptr = &arc_regs.scratch.sp;
 #define ARCH_REGS_FOR_GETREGSET arc_regs
 #define ARCH_PC_REG arc_regs.efa
+#define ARCH_SP_REG arc_regs.scratch.sp
diff --git a/linux/arc/arch_regs.h b/linux/arc/arch_regs.h
deleted file mode 100644 (file)
index 75c850a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern unsigned long *const arc_sp_ptr;
diff --git a/linux/arc/arch_rt_sigframe.c b/linux/arc/arch_rt_sigframe.c
deleted file mode 100644 (file)
index a735d04..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return *arc_sp_ptr;
-}
similarity index 88%
rename from linux/bfin/arch_rt_sigframe.c
rename to linux/arch_rt_sigframe.c
index 1692685c4af40b927c4bced81e309f7dad90ef0d..3103091531ecf753c2b40910d062b6daf03b564f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* This is a generic definition for compatible architectures.  */
+
 FUNC_GET_RT_SIGFRAME_ADDR
 {
-       unsigned long addr;
-
-       return upeek(tcp, PT_USP, &addr) ? 0 : addr;
+       kernel_ulong_t sp;
+       return get_stack_pointer(tcp, &sp) ? sp : 0;
 }
index 8b73cb864330fe2b64eec331b6036267ec35ef5a..1a8269c17fcb5377c8deb4ab73e7e35475b8c9e2 100644 (file)
@@ -1,5 +1,5 @@
 static struct pt_regs arm_regs;
-unsigned long *const arm_sp_ptr = (unsigned long *) &arm_regs.ARM_sp;
 
 #define ARCH_REGS_FOR_GETREGS arm_regs
 #define ARCH_PC_REG arm_regs.ARM_pc
+#define ARCH_SP_REG arm_regs.ARM_sp
diff --git a/linux/arm/arch_regs.h b/linux/arm/arch_regs.h
deleted file mode 100644 (file)
index 4edd50c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern unsigned long *const arm_sp_ptr;
diff --git a/linux/arm/arch_rt_sigframe.c b/linux/arm/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 0282bd3..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return *arm_sp_ptr;
-}
index a2b710041ce285795215906d7e208a28f23cf8c0..6edc764973b4ceeb7f6962af83e8c151183aecd9 100644 (file)
@@ -1,18 +1,21 @@
 static void
 arch_sigreturn(struct tcb *tcp)
 {
+       kernel_ulong_t sp;
+       if (!get_stack_pointer(tcp, &sp))
+               return;
+
 #define SIZEOF_STRUCT_SIGINFO 128
 #define SIZEOF_STRUCT_SIGCONTEXT (21 * 4)
 #define OFFSETOF_STRUCT_UCONTEXT_UC_SIGMASK (5 * 4 + SIZEOF_STRUCT_SIGCONTEXT)
 
-       const unsigned long addr =
+       const kernel_ulong_t addr =
 #ifdef AARCH64
                tcp->currpers == 0 ?
-                       (*aarch64_sp_ptr + SIZEOF_STRUCT_SIGINFO +
+                       (sp + SIZEOF_STRUCT_SIGINFO +
                         offsetof(ucontext_t, uc_sigmask)) :
 #endif
-                       (*arm_sp_ptr +
-                        OFFSETOF_STRUCT_UCONTEXT_UC_SIGMASK);
+                       (sp + OFFSETOF_STRUCT_UCONTEXT_UC_SIGMASK);
        tprints("{mask=");
        print_sigset_addr(tcp, addr);
        tprints("}");
index 2f88d8f00e2a6b85e60b2fd46fd5df8b8fe4592b..578e2acb817ff67124d2ead1cb320b1bf9d252dc 100644 (file)
@@ -1,4 +1,4 @@
 static struct pt_regs avr32_regs;
-unsigned long *const avr32_sp_ptr = &avr32_regs.sp;
 #define ARCH_REGS_FOR_GETREGS avr32_regs
 #define ARCH_PC_REG avr32_regs.pc
+#define ARCH_SP_REG avr32_regs.sp
diff --git a/linux/avr32/arch_regs.h b/linux/avr32/arch_regs.h
deleted file mode 100644 (file)
index 4ed62dd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern unsigned long *const avr32_sp_ptr;
diff --git a/linux/avr32/arch_rt_sigframe.c b/linux/avr32/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 6650f8e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return *avr32_sp_ptr;
-}
index ea76cb98604514d586d31d105f11c94092913a3e..6017f67d33d4fc400be2657a8fbfcded79b62b7f 100644 (file)
@@ -1,2 +1,3 @@
 static unsigned long bfin_r0;
 #define ARCH_PC_PEEK_ADDR PT_PC
+#define ARCH_SP_PEEK_ADDR PT_USP
index 7113bdb681eabaf84d0db30be442c92bd2486780..2a19ddabe24cc1cc10a00a848f1739064c07decc 100644 (file)
@@ -1,2 +1,11 @@
 static unsigned long hppa_r28;
+
+#define PT_GR20 (20*4)
+#define PT_GR26 (26*4)
+#define PT_GR28 (28*4)
+#define PT_GR30 (30*4)
+#define PT_IAOQ0 (106*4)
+#define PT_IAOQ1 (107*4)
+
 #define ARCH_PC_PEEK_ADDR PT_IAOQ0
+#define ARCH_SP_PEEK_ADDR PT_GR30
diff --git a/linux/hppa/arch_regs.h b/linux/hppa/arch_regs.h
deleted file mode 100644 (file)
index d42fc14..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#define PT_GR20 (20*4)
-#define PT_GR26 (26*4)
-#define PT_GR28 (28*4)
-#define PT_IAOQ0 (106*4)
-#define PT_IAOQ1 (107*4)
index aaf2ffe75c5391c9abc8d918ea26a6fca6bcf789..b340f2075939297a69f5beb00f58eb2eb0d20863 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,6 @@ FUNC_GET_RT_SIGFRAME_ADDR
 {
        unsigned long addr;
 
-       return upeek(tcp, 4 * 30, &addr)
-               ? 0 : (addr & ~1UL) - RT_SIGFRAME_SIZE;
+       return get_stack_pointer(tcp, &addr)
+               ? (addr & ~1UL) - RT_SIGFRAME_SIZE : 0;
 }
index 0dcea1f051f06c0f3339cbca83881ccb45ab085e..a5cf9e90ba9c932cb89eb1c9b2816ceb3b5a882d 100644 (file)
@@ -1,5 +1,5 @@
 static struct user_regs_struct i386_regs;
-unsigned long *const i386_esp_ptr = (unsigned long *) &i386_regs.esp;
 
 #define ARCH_REGS_FOR_GETREGS i386_regs
 #define ARCH_PC_REG i386_regs.eip
+#define ARCH_SP_REG i386_regs.esp
diff --git a/linux/i386/arch_regs.h b/linux/i386/arch_regs.h
deleted file mode 100644 (file)
index 6f62209..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern unsigned long *const i386_esp_ptr;
index b50840820e93fe57be7915b15eec4c39e1901629..7b611e93f7ae9baeef8fca45955062e919f79b49 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,5 +27,6 @@
 
 FUNC_GET_RT_SIGFRAME_ADDR
 {
-       return *i386_esp_ptr - 4;
+       kernel_ulong_t sp;
+       return get_stack_pointer(tcp, &sp) ? sp - current_klongsize : 0;
 }
index 9446994ef1cca3dc7da732f28722ee99ed8d1ec5..058a4a6e04252da1fb784e108f4dcb4cd311aba0 100644 (file)
@@ -13,10 +13,10 @@ arch_sigreturn(struct tcb *tcp)
                uint32_t struct_fpstate_padding[156];
                uint32_t extramask;
        } frame;
+       kernel_ulong_t sp;
 
-       if (umove(tcp, *i386_esp_ptr, &frame) < 0) {
-               tprintf("{mask=%#lx}", (unsigned long) *i386_esp_ptr);
-       } else {
+       if (get_stack_pointer(tcp, &sp) &&
+           !umove_or_printaddr(tcp, sp, &frame)) {
                uint32_t mask[2] = { frame.oldmask, frame.extramask };
                tprintsigmask_addr("{mask=", mask);
                tprints("}");
index b79918e3ec33ad346162e3e68d56c4fb0cdeb1c0..9251eaae0221741b0e19d1d31249ee694fb3f37b 100644 (file)
@@ -1,5 +1,5 @@
 static struct pt_all_user_regs ia64_regs;
-unsigned long *const ia64_frame_ptr = &ia64_regs.gr[12];
 
 #define ARCH_REGS_FOR_GETREGS ia64_regs
 #define ARCH_PC_REG ia64_regs.br[0]
+#define ARCH_SP_REG ia64_regs.gr[12]
index 7ad969c8258d043231ec9d206d3f60dfb3ad0615..2dcdc414860400230f844dccfe02990e2d8c2c54 100644 (file)
@@ -1,2 +1 @@
 #include <asm/ptrace_offsets.h>
-extern unsigned long *const ia64_frame_ptr;
index f6e660c0b32d002a9baeb214b5b9f23aa5b5a5fa..542febe520f78e6a0ee1168764a35c63b09ddc07 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,5 +27,6 @@
 
 FUNC_GET_RT_SIGFRAME_ADDR
 {
-       return *ia64_frame_ptr + 16;
+       kernel_ulong_t sp;
+       return get_stack_pointer(tcp, &sp) ? sp + 16 : 0;
 }
index 3d4c3d9e48018422bd19d191415aff9941e9cca6..084895806dcb8c5309191f5fa24597c1d61ede94 100644 (file)
@@ -1,4 +1,4 @@
 static struct user_regs_struct m68k_regs;
-unsigned long *const m68k_usp_ptr = (unsigned long *) &m68k_regs.usp;
-#define ARCH_PC_REG m68k_regs.pc
 #define ARCH_REGS_FOR_GETREGS m68k_regs
+#define ARCH_PC_REG m68k_regs.pc
+#define ARCH_SP_REG m68k_regs.usp
diff --git a/linux/m68k/arch_regs.h b/linux/m68k/arch_regs.h
deleted file mode 100644 (file)
index 424ec11..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern unsigned long *const m68k_usp_ptr;
index 9ba26e1b11896505976a25d6925c7d00cda6d498..bb60b44d4ea8d9225deb2ea98c190be55436e62e 100644 (file)
@@ -1,31 +1 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return *m68k_usp_ptr - 4;
-}
+#include "i386/arch_rt_sigframe.c"
index b1402683987257d4ef9d432c3dc9d18ba9c5e18e..382815cd7bee1339772abad10446d2c6273e05a8 100644 (file)
@@ -1,20 +1,21 @@
 static void
 arch_sigreturn(struct tcb *tcp)
 {
-       unsigned long addr;
+       unsigned long addr, sp;
 
        /* Fetch pointer to struct sigcontext.  */
-       if (umove(tcp, *m68k_usp_ptr + 2 * sizeof(int), &addr) < 0)
+       if (!get_stack_pointer(tcp, &sp) ||
+           umove_or_printaddr(tcp, sp + 2 * sizeof(int), &addr))
                return;
 
        unsigned long mask[NSIG_BYTES / sizeof(long)];
        /* Fetch first word of signal mask.  */
-       if (umove(tcp, addr, &mask[0]) < 0)
+       if (umove_or_printaddr(tcp, addr, &mask[0]))
                return;
 
        /* Fetch remaining words of signal mask, located immediately before.  */
        addr -= sizeof(mask) - sizeof(long);
-       if (umoven(tcp, addr, sizeof(mask) - sizeof(long), &mask[1]) < 0)
+       if (umoven_or_printaddr(tcp, addr, sizeof(mask) - sizeof(long), &mask[1]))
                return;
 
        tprintsigmask_addr("{mask=", mask);
index 5944723aab9d57597c75a335f3e30e584bf8a17c..08179fae25b11ed36ec6def9a8e484c0aa44f708 100644 (file)
@@ -1,4 +1,4 @@
 static struct user_gp_regs metag_regs;
-unsigned long *const metag_sp_ptr = &metag_regs.ax[0][0];
 #define ARCH_REGS_FOR_GETREGSET metag_regs
 #define ARCH_PC_REG metag_regs.pc
+#define ARCH_SP_REG metag_regs.ax[0][0]
diff --git a/linux/metag/arch_regs.h b/linux/metag/arch_regs.h
deleted file mode 100644 (file)
index 3344c92..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern unsigned long *const metag_sp_ptr;
index 898c5d243d8698453ff070b1a8a7e3eea125793c..0e4152342cec036d11facfe7f4753202b6e80033 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,5 +29,7 @@
 
 FUNC_GET_RT_SIGFRAME_ADDR
 {
-       return *metag_sp_ptr - sizeof(struct_rt_sigframe);
+       kernel_ulong_t sp;
+       return get_stack_pointer(tcp, &sp)
+               ? sp - sizeof(struct_rt_sigframe) : 0;
 }
index a5fec6112ab3d5c7c23947b1d9a4ccf26bfe9ec8..79f2dda08ac8d8caa9ea00896a652588cb876b3d 100644 (file)
@@ -1,2 +1,3 @@
 static unsigned long microblaze_r3;
 #define ARCH_PC_PEEK_ADDR PT_PC
+#define ARCH_SP_PEEK_ADDR PT_GPR(1)
diff --git a/linux/microblaze/arch_rt_sigframe.c b/linux/microblaze/arch_rt_sigframe.c
deleted file mode 100644 (file)
index dcecd1a..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       unsigned long addr;
-
-       return upeek(tcp, 4 * 1, &addr) ? 0 : addr;
-}
index 44f6bd5e84ed3f4005bc4bfc7386a9ce0e90ea46..2f604d83a7a178e48e6a939108a52c74651e1608 100644 (file)
@@ -1,4 +1,21 @@
-struct mips_regs mips_regs; /* not static */
+static struct {
+       uint64_t uregs[38];
+} mips_regs;
+
+#define REG_V0 2
+#define REG_A0 4
+
+#define mips_REG_V0 mips_regs.uregs[REG_V0]
+#define mips_REG_A0 mips_regs.uregs[REG_A0 + 0]
+#define mips_REG_A1 mips_regs.uregs[REG_A0 + 1]
+#define mips_REG_A2 mips_regs.uregs[REG_A0 + 2]
+#define mips_REG_A3 mips_regs.uregs[REG_A0 + 3]
+#define mips_REG_A4 mips_regs.uregs[REG_A0 + 4]
+#define mips_REG_A5 mips_regs.uregs[REG_A0 + 5]
+#define mips_REG_SP mips_regs.uregs[29]
+#define mips_REG_EPC mips_regs.uregs[34]
+
 /* PTRACE_GETREGS on MIPS is available since linux v2.6.15. */
 #define ARCH_REGS_FOR_GETREGS mips_regs
 #define ARCH_PC_REG mips_REG_EPC
+#define ARCH_SP_REG mips_REG_SP
diff --git a/linux/mips/arch_regs.h b/linux/mips/arch_regs.h
deleted file mode 100644 (file)
index 6372bad..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-struct mips_regs {
-       uint64_t uregs[38];
-};
-
-extern struct mips_regs mips_regs;
-
-#define REG_V0 2
-#define REG_A0 4
-
-#define mips_REG_V0 mips_regs.uregs[REG_V0]
-#define mips_REG_A0 mips_regs.uregs[REG_A0 + 0]
-#define mips_REG_A1 mips_regs.uregs[REG_A0 + 1]
-#define mips_REG_A2 mips_regs.uregs[REG_A0 + 2]
-#define mips_REG_A3 mips_regs.uregs[REG_A0 + 3]
-#define mips_REG_A4 mips_regs.uregs[REG_A0 + 4]
-#define mips_REG_A5 mips_regs.uregs[REG_A0 + 5]
-#define mips_REG_SP mips_regs.uregs[29]
-#define mips_REG_EPC mips_regs.uregs[34]
diff --git a/linux/mips/arch_rt_sigframe.c b/linux/mips/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 03acc73..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return mips_REG_SP;
-}
index 522b731522b56db2a04dee44e820ad92af58d203..aeac7c215924c9ee26bd265b978f1626a20b8413 100644 (file)
@@ -3,12 +3,14 @@ arch_sigreturn(struct tcb *tcp)
 {
        /* 64-bit ABIs do not have old sigreturn. */
 #ifdef LINUX_MIPSO32
+       kernel_ulong_t addr;
+       if (!get_stack_pointer(tcp, &addr))
+               return;
        /*
         * offsetof(struct sigframe, sf_mask) ==
         * sizeof(sf_ass) + sizeof(sf_pad) + sizeof(struct sigcontext)
         */
-       const kernel_ulong_t addr = mips_REG_SP + 6 * 4 +
-                                  sizeof(struct sigcontext);
+       addr += 6 * 4 + sizeof(struct sigcontext);
 
        tprints("{mask=");
        print_sigset_addr(tcp, addr);
index c18a3aa53010c8cd664d28ee5b47adb3ab00c424..ecbef0eec3a7593aa20f28da06919c35a18b3581 100644 (file)
@@ -1,4 +1,4 @@
 static struct user_pt_regs nios2_regs;
-unsigned int *const nios2_sp_ptr = &nios2_regs.regs[PTR_SP];
 # define ARCH_REGS_FOR_GETREGSET nios2_regs
 #define ARCH_PC_REG nios2_regs.regs[PTR_EA]
+#define ARCH_SP_REG nios2_regs.regs[PTR_SP]
diff --git a/linux/nios2/arch_regs.h b/linux/nios2/arch_regs.h
deleted file mode 100644 (file)
index c4230ed..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern unsigned int *const nios2_sp_ptr;
diff --git a/linux/nios2/arch_rt_sigframe.c b/linux/nios2/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 7359f11..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return *nios2_sp_ptr;
-}
index 80ce7639d2e3c05a152d844f23331568ca67c7a1..efdef98967ee70d50695a662361dd114249ec3dd 100644 (file)
@@ -1,4 +1,4 @@
 static struct user_regs_struct or1k_regs;
-unsigned long *const or1k_sp_ptr = &or1k_regs.gpr[1];
 #define ARCH_REGS_FOR_GETREGSET or1k_regs
 #define ARCH_PC_REG or1k_regs.pc
+#define ARCH_SP_REG or1k_regs.gpr[1]
diff --git a/linux/or1k/arch_regs.h b/linux/or1k/arch_regs.h
deleted file mode 100644 (file)
index 44a78ec..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern unsigned long *const or1k_sp_ptr;
diff --git a/linux/or1k/arch_rt_sigframe.c b/linux/or1k/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 4f8cbbe..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return *or1k_sp_ptr;
-}
index dd573f71ebf16e13bb385ee7ad4760a0f1ab9bf1..37cddc5761a49bafc0cacbf2af76827ecececb1f 100644 (file)
@@ -1,4 +1,5 @@
-struct pt_regs ppc_regs; /* not static */
+static struct pt_regs ppc_regs;
 
 #define ARCH_REGS_FOR_GETREGS ppc_regs
 #define ARCH_PC_REG ppc_regs.nip
+#define ARCH_SP_REG ppc_regs.gpr[1]
diff --git a/linux/powerpc/arch_regs.h b/linux/powerpc/arch_regs.h
deleted file mode 100644 (file)
index 1296e83..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern struct pt_regs ppc_regs;
index 4a1c431527a9cfbc354f04234ce9afb430e0b674..b9d40470d9dce6364f206c37766a6ed9b6148b53 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,5 +29,6 @@
 
 FUNC_GET_RT_SIGFRAME_ADDR
 {
-       return ppc_regs.gpr[1] + SIGNAL_FRAMESIZE32 + 16;
+       kernel_ulong_t sp;
+       return get_stack_pointer(tcp, &sp) ? sp + SIGNAL_FRAMESIZE32 + 16 : 0;
 }
index 5a5ca3aecf8467881fdadd9030cc1079be5d94a6..227a7970b4c6ec885d45aaae1ef47559caba34f8 100644 (file)
@@ -1,8 +1,12 @@
 static void
 arch_sigreturn(struct tcb *tcp)
 {
+       kernel_ulong_t addr;
+       if (!get_stack_pointer(tcp, &addr))
+               return;
+
        /* Skip dummy stack frame. */
-       const unsigned long addr = ppc_regs.gpr[1] + 64;
+       addr += 64;
 
 #ifdef POWERPC64
        /* The only sigreturn on ppc64 is compat_sys_sigreturn. */
@@ -19,9 +23,7 @@ arch_sigreturn(struct tcb *tcp)
 
        sigreturn_context sc;
 
-       if (umove(tcp, addr, &sc) < 0) {
-               tprintf("{mask=%#lx}", addr);
-       } else {
+       if (!umove_or_printaddr(tcp, addr, &sc)) {
                const unsigned int mask[NSIG_BYTES / sizeof(int)] = {
                        sc.oldmask,
                        sc._unused[3]
diff --git a/linux/powerpc64/arch_regs.h b/linux/powerpc64/arch_regs.h
deleted file mode 100644 (file)
index 05e4fe1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "powerpc/arch_regs.h"
index 333f70809e3203191f5dd309595601340d446fc7..444b163a73652f3afe06fbb75c9ddbf1625d4d11 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,8 @@
 
 FUNC_GET_RT_SIGFRAME_ADDR
 {
-       return tcp->currpers == 1
-               ? ppc_get_rt_sigframe_addr(tcp) : ppc_regs.gpr[1];
+       if (tcp->currpers == 1)
+               return ppc_get_rt_sigframe_addr(tcp);
+       kernel_ulong_t sp;
+       return get_stack_pointer(tcp, &sp) ? sp : 0;
 }
index 58010df27b809c3a54ba64990dbefcb57a018df0..b6c08bc96dbc7b0e589360ceca6b4e767ec847a2 100644 (file)
@@ -1,4 +1,4 @@
 static struct user_regs_struct riscv_regs;
-unsigned long *const riscv_sp_ptr = &riscv_regs.sp;
 #define ARCH_REGS_FOR_GETREGSET riscv_regs
 #define ARCH_PC_REG riscv_regs.pc
+#define ARCH_SP_REG riscv_regs.sp
diff --git a/linux/riscv/arch_regs.h b/linux/riscv/arch_regs.h
deleted file mode 100644 (file)
index f270281..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern unsigned long *const riscv_sp_ptr;
diff --git a/linux/riscv/arch_rt_sigframe.c b/linux/riscv/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 54526c4..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return *riscv_sp_ptr;
-}
index fefb7630dc6e45f51ea153b78252034a3fe3c57e..414123e48b58cd16edb4d724753a780667e6880e 100644 (file)
@@ -1,5 +1,5 @@
 /* PTRACE_GETREGSET on S390 is available since linux v2.6.27. */
 static struct user_regs_struct s390_regset;
-unsigned long *const s390_frame_ptr = &s390_regset.gprs[15];
 #define ARCH_REGS_FOR_GETREGSET s390_regset
 #define ARCH_PC_REG s390_regset.psw.addr
+#define ARCH_SP_REG s390_regset.gprs[15]
diff --git a/linux/s390/arch_regs.h b/linux/s390/arch_regs.h
deleted file mode 100644 (file)
index 586326f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern unsigned long *const s390_frame_ptr;
diff --git a/linux/s390/arch_rt_sigframe.c b/linux/s390/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 2cd468b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return *s390_frame_ptr;
-}
index 9c9e0ddff50b29b6ded3d7ed5bef31ea76074a1a..f63ef132371fb5f03def09aa2daa83ddd0686926 100644 (file)
@@ -1,6 +1,3 @@
-#ifndef S390_FRAME_PTR
-# define S390_FRAME_PTR s390_frame_ptr
-#endif
 #ifndef SIGNAL_FRAMESIZE
 # define SIGNAL_FRAMESIZE __SIGNAL_FRAMESIZE
 #endif
 static void
 arch_sigreturn(struct tcb *tcp)
 {
-       PTR_TYPE mask[NSIG_BYTES / sizeof(PTR_TYPE)];
-       const PTR_TYPE addr = *S390_FRAME_PTR + SIGNAL_FRAMESIZE;
+       kernel_ulong_t addr;
 
-       if (umove(tcp, addr, &mask) < 0) {
-               tprintf("{mask=%#llx}", zero_extend_signed_to_ull(addr));
-       } else {
+       if (!get_stack_pointer(tcp, &addr))
+               return;
+       addr += SIGNAL_FRAMESIZE;
+
+       PTR_TYPE mask[NSIG_BYTES / sizeof(PTR_TYPE)];
+       if (!umove_or_printaddr(tcp, addr, &mask)) {
                tprintsigmask_addr("{mask=", mask);
                tprints("}");
        }
index 58f7b782383c31ee92f1ebe56b7c941aab9d85cb..1dd35dbba501c6b305e3b430c7644cc2673fac76 100644 (file)
@@ -20,9 +20,6 @@ static union {
 #define s390_regset    s390x_regs_union.s390_regs
 #define s390x_regset   s390x_regs_union.s390x_regs
 
-uint32_t *const s390_frame_ptr = &s390_regset.gprs[15];
-unsigned long *const s390x_frame_ptr = &s390x_regset.gprs[15];
-
 static struct iovec s390x_io = {
        .iov_base = &s390x_regs_union,
 };
@@ -33,6 +30,9 @@ static struct iovec s390x_io = {
 #define ARCH_PC_REG \
        (s390x_io.iov_len == sizeof(s390_regset) ? \
                             s390_regset.psw.addr : s390x_regset.psw.addr)
+#define ARCH_SP_REG \
+       (s390x_io.iov_len == sizeof(s390_regset) ? \
+                            s390_regset.gprs[15] : s390x_regset.gprs[15])
 
 #define ARCH_PERSONALITY_0_IOV_SIZE sizeof(s390x_regset)
 #define ARCH_PERSONALITY_1_IOV_SIZE sizeof(s390_regset)
diff --git a/linux/s390x/arch_regs.h b/linux/s390x/arch_regs.h
deleted file mode 100644 (file)
index 1f8b57a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-extern uint32_t *const s390_frame_ptr;
-extern unsigned long *const s390x_frame_ptr;
diff --git a/linux/s390x/arch_rt_sigframe.c b/linux/s390x/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 9c0255f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return tcp->currpers == 1 ? *s390_frame_ptr : *s390x_frame_ptr;
-}
index edc9edd50f73796712a6315986b84e6e1481e886..4065e0640a3d20195f8dcb3333ecc50e8a9bacf1 100644 (file)
@@ -4,15 +4,12 @@
 
 #define SIGNAL_FRAMESIZE       S390_SIGNAL_FRAMESIZE
 #define PTR_TYPE               uint32_t
-#define S390_FRAME_PTR         s390_frame_ptr
 #define arch_sigreturn s390_arch_sigreturn
 #include "s390/arch_sigreturn.c"
 #undef arch_sigreturn
-#undef S390_FRAME_PTR
 #undef PTR_TYPE
 #undef SIGNAL_FRAMESIZE
 
-#define S390_FRAME_PTR         s390x_frame_ptr
 #define arch_sigreturn s390x_arch_sigreturn
 #include "s390/arch_sigreturn.c"
 #undef arch_sigreturn
index 5429b4f5c7974410c6ed5afbbc0aa5b94d7da1b3..8ea0fc40c51c28e30594d27298410c8d234b50ca 100644 (file)
@@ -1,2 +1,3 @@
 static unsigned long sh_r0;
 #define ARCH_PC_PEEK_ADDR (4 * REG_PC)
+#define ARCH_SP_PEEK_ADDR (4 * 15)
diff --git a/linux/sh/arch_rt_sigframe.c b/linux/sh/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 3c4f6f2..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       unsigned long addr;
-
-       return upeek(tcp, sizeof(long) * 15, &addr) ? 0 : addr;
-}
index 8b3202a8ad8d4335762c3c57681d3858b3b0889f..787ae22f892e180c95a31c600e83c9c9b92bca78 100644 (file)
@@ -1,2 +1,3 @@
 static unsigned long sh64_r9;
 #define ARCH_PC_PEEK_ADDR REG_PC
+#define ARCH_SP_PEEK_ADDR REG_GENERAL(15)
diff --git a/linux/sh64/arch_rt_sigframe.c b/linux/sh64/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 21204e3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "sh/arch_rt_sigframe.c"
index c0f22e6c849736c2da1762ad8664581247387260..7a28d46462beb1d8a95b3a2e9db3ca0e6d513f93 100644 (file)
@@ -1,3 +1,12 @@
-struct pt_regs sparc_regs; /* not static */
+static struct pt_regs sparc_regs;
+
+/* Indexes into the pt_regs.u_reg[] array -- UREG_XX from kernel are all off
+ * by 1 and use Ix instead of Ox.  These work for both 32 and 64 bit Linux. */
+#define U_REG_G1 0
+#define U_REG_O0 7
+#define U_REG_O1 8
+#define U_REG_FP 13
+
 #define ARCH_REGS_FOR_GETREGS sparc_regs
 #define ARCH_PC_REG sparc_regs.pc
+#define ARCH_SP_REG sparc_regs.u_regs[U_REG_FP]
diff --git a/linux/sparc/arch_regs.h b/linux/sparc/arch_regs.h
deleted file mode 100644 (file)
index ac11a1d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-extern struct pt_regs sparc_regs;
-/* Indexes into the pt_regs.u_reg[] array -- UREG_XX from kernel are all off
- * by 1 and use Ix instead of Ox.  These work for both 32 and 64 bit Linux. */
-#define U_REG_G1 0
-#define U_REG_O0 7
-#define U_REG_O1 8
-#define U_REG_FP 13
diff --git a/linux/sparc/arch_rt_sigframe.c b/linux/sparc/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 418443e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return sparc_regs.u_regs[U_REG_FP];
-}
index 2170a7baf6afd006270be2b5da94b53e55165b2b..13edd425acc11ae25595bc069a6e86f9b5e381d8 100644 (file)
 static void
 arch_sigreturn(struct tcb *tcp)
 {
-       unsigned long addr = sparc_regs.u_regs[U_REG_FP] +
-               SIZEOF_STRUCT_SPARC_STACKF + SIZEOF_STRUCT_PT_REGS;
+       kernel_ulong_t addr;
+       if (!get_stack_pointer(tcp, &addr))
+               return;
+       addr += SIZEOF_STRUCT_SPARC_STACKF + SIZEOF_STRUCT_PT_REGS;
        struct {
                unsigned int mask;
                char fpu_save[PERSONALITY_WORDSIZE];
@@ -20,9 +22,7 @@ arch_sigreturn(struct tcb *tcp)
                unsigned int extramask[NSIG_BYTES / sizeof(int) - 1];
        } frame;
 
-       if (umove(tcp, addr, &frame) < 0) {
-               tprintf("{mask=%#lx}", addr);
-       } else {
+       if (!umove_or_printaddr(tcp, addr, &frame)) {
                unsigned int mask[NSIG_BYTES / sizeof(int)];
 
                mask[0] = frame.mask;
diff --git a/linux/sparc64/arch_regs.h b/linux/sparc64/arch_regs.h
deleted file mode 100644 (file)
index a49ad53..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "sparc/arch_regs.h"
index 0bad84da4d5950abf400280f5ab4012305ebfbaf..58e5eca8aead25fdd0ca407509c59a2f4550e6f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,6 +29,9 @@
 
 FUNC_GET_RT_SIGFRAME_ADDR
 {
-       return tcp->currpers == 1 ? sparc_regs.u_regs[U_REG_FP] & 0xffffffffUL
-                                 : sparc_regs.u_regs[U_REG_FP] + STACK_BIAS;
+       kernel_ulong_t sp;
+       if (!get_stack_pointer(tcp, &sp))
+               return 0;
+       return tcp->currpers == 1 ? sp & 0xffffffffUL
+                                 : sp + STACK_BIAS;
 }
index 6a7309d23c28ba9c7bed52fb90f29d9cd9875ad2..cd048baad7117144ccfe703db58618c357d9fc10 100644 (file)
@@ -1,3 +1,4 @@
-struct pt_regs tile_regs; /* not static */
+static struct pt_regs tile_regs;
 #define ARCH_REGS_FOR_GETREGS tile_regs
 #define ARCH_PC_REG tile_regs.pc
+#define ARCH_SP_REG tile_regs.sp
diff --git a/linux/tile/arch_regs.h b/linux/tile/arch_regs.h
deleted file mode 100644 (file)
index cd3f72b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extern struct pt_regs tile_regs;
diff --git a/linux/tile/arch_rt_sigframe.c b/linux/tile/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 8d15e5c..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return tile_regs.sp;
-}
index 7042cfd51ea8cfdb917b1ed53c6acde79fca630e..92631f4d5475f1170ee8b7c59e6c3b4d57c338a2 100644 (file)
@@ -1,10 +1,13 @@
 static void
 arch_sigreturn(struct tcb *tcp)
 {
+       kernel_ulong_t addr;
+       if (!get_stack_pointer(tcp, &addr))
+               return;
+
        /* offset of ucontext in the kernel's sigframe structure */
 #define SIGFRAME_UC_OFFSET C_ABI_SAVE_AREA_SIZE + sizeof(siginfo_t)
-       const unsigned long addr = tile_regs.sp + SIGFRAME_UC_OFFSET +
-                                  offsetof(ucontext_t, uc_sigmask);
+       addr += SIGFRAME_UC_OFFSET + offsetof(ucontext_t, uc_sigmask);
 
        tprints("{mask=");
        print_sigset_addr(tcp, addr);
index daee69f9e285bd02679152e1c44aa2a4df93df7e..ac719b6b93edf706791eeb542ce2fbdeaca44d5c 100644 (file)
@@ -30,12 +30,13 @@ static union {
 #define x86_64_regs x86_regs_union.x86_64_r
 #define i386_regs   x86_regs_union.i386_r
 
-uint32_t *const i386_esp_ptr = &i386_regs.esp;
-uint64_t *const x86_64_rsp_ptr = (uint64_t *) &x86_64_regs.rsp;
 static struct iovec x86_io = {
        .iov_base = &x86_regs_union
 };
 
 #define ARCH_REGS_FOR_GETREGSET x86_regs_union
 #define ARCH_IOVEC_FOR_GETREGSET x86_io
-#define ARCH_PC_REG (x86_io.iov_len == sizeof(i386_regs) ? i386_regs.eip : x86_64_regs.rip)
+#define ARCH_PC_REG \
+       (x86_io.iov_len == sizeof(i386_regs) ? i386_regs.eip : x86_64_regs.rip)
+#define ARCH_SP_REG \
+       (x86_io.iov_len == sizeof(i386_regs) ? i386_regs.esp : x86_64_regs.rsp)
index d502ca4bf20271b43aa525748eeb726650fe4d18..6676bb8d6db6d1da0c9c995d4e86fbe41719a457 100644 (file)
@@ -1,5 +1,3 @@
-extern uint32_t *const i386_esp_ptr;
-extern uint64_t *const x86_64_rsp_ptr;
 
 /* <asm/ptrace.h> does not provide these definitions.  */
 #define R15            0
index d2c7867f7153b58db574f93c1146706d945afa69..bb60b44d4ea8d9225deb2ea98c190be55436e62e 100644 (file)
@@ -1,41 +1 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#undef FUNC_GET_RT_SIGFRAME_ADDR
-#define        FUNC_GET_RT_SIGFRAME_ADDR       \
-       static kernel_ulong_t i386_get_rt_sigframe_addr(struct tcb *tcp)
-
 #include "i386/arch_rt_sigframe.c"
-
-#undef FUNC_GET_RT_SIGFRAME_ADDR
-#define        FUNC_GET_RT_SIGFRAME_ADDR       DEF_FUNC_GET_RT_SIGFRAME_ADDR
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       return tcp->currpers == 1 ? i386_get_rt_sigframe_addr(tcp)
-                                 : *x86_64_rsp_ptr - sizeof(kernel_ulong_t);
-}
index 67e5f010f9d9a080dd9138e649886e7a3bb28ff5..5b85fda9d607ae1191a61cf19974e2dbd0bc3a0f 100644 (file)
@@ -1,2 +1,3 @@
 static unsigned long xtensa_a2;
 #define ARCH_PC_PEEK_ADDR REG_PC
+#define ARCH_SP_PEEK_ADDR (REG_A_BASE + 1)
diff --git a/linux/xtensa/arch_rt_sigframe.c b/linux/xtensa/arch_rt_sigframe.c
deleted file mode 100644 (file)
index 97ffe6c..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
-       unsigned long addr;
-
-       return upeek(tcp, REG_A_BASE + 3, &addr) ? 0 : addr;
-}
index e1b2f20e95c6d511e46c68c9c23b239473df75de..9107fe50750a59bdfd338f76703fd531d60f2851 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -1195,6 +1195,23 @@ get_instruction_pointer(struct tcb *tcp, kernel_ulong_t *ip)
 #endif
 }
 
+bool
+get_stack_pointer(struct tcb *tcp, kernel_ulong_t *sp)
+{
+#if defined ARCH_SP_REG
+       if (get_regs(tcp) < 0)
+               return false;
+       *sp = (kernel_ulong_t) ARCH_SP_REG;
+       return true;
+#elif defined ARCH_SP_PEEK_ADDR
+       if (upeek(tcp, ARCH_SP_PEEK_ADDR, sp) < 0)
+               return false;
+       return true;
+#else
+       return false;
+#endif
+}
+
 /*
  * Returns:
  * 0: "ignore this ptrace stop", syscall_entering_decode() should return a "bail