From c57cf9acf5f73cb85232dd0243d114c5f32be264 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sat, 11 Mar 2017 21:49:06 +0000 Subject: [PATCH] Introduce get_rt_sigframe_addr function Add get_rt_sigframe_addr function for all supported architectures. It is going to be used in a parser of rt_sigreturn syscall. * defs.h (get_rt_sigframe_addr): New function prototype. * rt_sigframe.c: New file. * Makefile.am (strace_SOURCES): Add it. * linux/aarch64/arch_rt_sigframe.c: New file. * linux/alpha/arch_rt_sigframe.c: Likewise. * linux/arc/arch_rt_sigframe.c: Likewise. * linux/arm/arch_rt_sigframe.c: Likewise. * linux/avr32/arch_rt_sigframe.c: Likewise. * linux/bfin/arch_rt_sigframe.c: Likewise. * linux/crisv10/arch_rt_sigframe.c: Likewise. * linux/crisv32/arch_rt_sigframe.c: Likewise. * linux/hppa/arch_rt_sigframe.c: Likewise. * linux/i386/arch_rt_sigframe.c: Likewise. * linux/ia64/arch_rt_sigframe.c: Likewise. * linux/m68k/arch_rt_sigframe.c: Likewise. * linux/metag/arch_rt_sigframe.c: Likewise. * linux/microblaze/arch_rt_sigframe.c: Likewise. * linux/mips/arch_rt_sigframe.c: Likewise. * linux/nios2/arch_rt_sigframe.c: Likewise. * linux/or1k/arch_rt_sigframe.c: Likewise. * linux/powerpc/arch_rt_sigframe.c: Likewise. * linux/powerpc64/arch_rt_sigframe.c: Likewise. * linux/riscv/arch_rt_sigframe.c: Likewise. * linux/s390/arch_rt_sigframe.c: Likewise. * linux/s390x/arch_rt_sigframe.c: Likewise. * linux/sh/arch_rt_sigframe.c: Likewise. * linux/sh64/arch_rt_sigframe.c: Likewise. * linux/sparc/arch_rt_sigframe.c: Likewise. * linux/sparc64/arch_rt_sigframe.c: Likewise. * linux/tile/arch_rt_sigframe.c: Likewise. * linux/x32/arch_rt_sigframe.c: Likewise. * linux/x86_64/arch_rt_sigframe.c: Likewise. * linux/xtensa/arch_rt_sigframe.c: Likewise. * Makefile.am (EXTRA_DIST): Add them. --- Makefile.am | 31 ++++++++++++++++++++++ defs.h | 4 ++- linux/aarch64/arch_rt_sigframe.c | 41 +++++++++++++++++++++++++++++ linux/alpha/arch_rt_sigframe.c | 33 +++++++++++++++++++++++ linux/arc/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/arm/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/avr32/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/bfin/arch_rt_sigframe.c | 33 +++++++++++++++++++++++ linux/crisv10/arch_rt_sigframe.c | 33 +++++++++++++++++++++++ linux/crisv32/arch_rt_sigframe.c | 1 + linux/hppa/arch_rt_sigframe.c | 41 +++++++++++++++++++++++++++++ linux/i386/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/ia64/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/m68k/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/metag/arch_rt_sigframe.c | 33 +++++++++++++++++++++++ linux/microblaze/arch_rt_sigframe.c | 33 +++++++++++++++++++++++ linux/mips/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/nios2/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/or1k/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/powerpc/arch_rt_sigframe.c | 33 +++++++++++++++++++++++ linux/powerpc64/arch_rt_sigframe.c | 41 +++++++++++++++++++++++++++++ linux/riscv/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/s390/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/s390x/arch_rt_sigframe.c | 1 + linux/sh/arch_rt_sigframe.c | 33 +++++++++++++++++++++++ linux/sh64/arch_rt_sigframe.c | 1 + linux/sparc/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/sparc64/arch_rt_sigframe.c | 34 ++++++++++++++++++++++++ linux/tile/arch_rt_sigframe.c | 31 ++++++++++++++++++++++ linux/x32/arch_rt_sigframe.c | 1 + linux/x86_64/arch_rt_sigframe.c | 41 +++++++++++++++++++++++++++++ linux/xtensa/arch_rt_sigframe.c | 33 +++++++++++++++++++++++ rt_sigframe.c | 36 +++++++++++++++++++++++++ 33 files changed, 939 insertions(+), 1 deletion(-) create mode 100644 linux/aarch64/arch_rt_sigframe.c create mode 100644 linux/alpha/arch_rt_sigframe.c create mode 100644 linux/arc/arch_rt_sigframe.c create mode 100644 linux/arm/arch_rt_sigframe.c create mode 100644 linux/avr32/arch_rt_sigframe.c create mode 100644 linux/bfin/arch_rt_sigframe.c create mode 100644 linux/crisv10/arch_rt_sigframe.c create mode 100644 linux/crisv32/arch_rt_sigframe.c create mode 100644 linux/hppa/arch_rt_sigframe.c create mode 100644 linux/i386/arch_rt_sigframe.c create mode 100644 linux/ia64/arch_rt_sigframe.c create mode 100644 linux/m68k/arch_rt_sigframe.c create mode 100644 linux/metag/arch_rt_sigframe.c create mode 100644 linux/microblaze/arch_rt_sigframe.c create mode 100644 linux/mips/arch_rt_sigframe.c create mode 100644 linux/nios2/arch_rt_sigframe.c create mode 100644 linux/or1k/arch_rt_sigframe.c create mode 100644 linux/powerpc/arch_rt_sigframe.c create mode 100644 linux/powerpc64/arch_rt_sigframe.c create mode 100644 linux/riscv/arch_rt_sigframe.c create mode 100644 linux/s390/arch_rt_sigframe.c create mode 100644 linux/s390x/arch_rt_sigframe.c create mode 100644 linux/sh/arch_rt_sigframe.c create mode 100644 linux/sh64/arch_rt_sigframe.c create mode 100644 linux/sparc/arch_rt_sigframe.c create mode 100644 linux/sparc64/arch_rt_sigframe.c create mode 100644 linux/tile/arch_rt_sigframe.c create mode 100644 linux/x32/arch_rt_sigframe.c create mode 100644 linux/x86_64/arch_rt_sigframe.c create mode 100644 linux/xtensa/arch_rt_sigframe.c create mode 100644 rt_sigframe.c diff --git a/Makefile.am b/Makefile.am index 23da49b0..31682d4d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -209,6 +209,7 @@ strace_SOURCES = \ regs.h \ renameat.c \ resource.c \ + rt_sigframe.c \ rtc.c \ sched.c \ sched_attr.h \ @@ -316,6 +317,7 @@ EXTRA_DIST = \ linux/64/syscallent.h \ linux/aarch64/arch_regs.c \ linux/aarch64/arch_regs.h \ + linux/aarch64/arch_rt_sigframe.c\ linux/aarch64/arch_sigreturn.c \ linux/aarch64/errnoent1.h \ linux/aarch64/get_error.c \ @@ -333,6 +335,7 @@ EXTRA_DIST = \ 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 \ @@ -348,6 +351,7 @@ EXTRA_DIST = \ 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 \ @@ -360,6 +364,7 @@ EXTRA_DIST = \ linux/arch_sigreturn.c \ 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 \ @@ -372,6 +377,7 @@ EXTRA_DIST = \ 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 \ @@ -382,6 +388,7 @@ EXTRA_DIST = \ linux/avr32/syscallent.h \ linux/avr32/userent.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 \ @@ -394,6 +401,7 @@ EXTRA_DIST = \ linux/bfin/syscallent.h \ linux/bfin/userent.h \ linux/crisv10/arch_regs.c \ + linux/crisv10/arch_rt_sigframe.c\ linux/crisv10/arch_sigreturn.c \ linux/crisv10/get_error.c \ linux/crisv10/get_scno.c \ @@ -405,6 +413,7 @@ EXTRA_DIST = \ linux/crisv10/syscallent.h \ linux/crisv10/userent.h \ linux/crisv32/arch_regs.c \ + linux/crisv32/arch_rt_sigframe.c\ linux/crisv32/arch_sigreturn.c \ linux/crisv32/get_error.c \ linux/crisv32/get_scno.c \ @@ -420,6 +429,7 @@ EXTRA_DIST = \ linux/getregs_old.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 \ linux/hppa/get_scno.c \ @@ -434,6 +444,7 @@ EXTRA_DIST = \ linux/hppa/syscallent.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 \ linux/i386/get_scno.c \ @@ -449,6 +460,7 @@ EXTRA_DIST = \ linux/ia64/arch_getrval2.c \ linux/ia64/arch_regs.c \ linux/ia64/arch_regs.h \ + linux/ia64/arch_rt_sigframe.c \ linux/ia64/arch_sigreturn.c \ linux/ia64/get_error.c \ linux/ia64/get_scno.c \ @@ -463,6 +475,7 @@ EXTRA_DIST = \ linux/inet_diag.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 \ linux/m68k/get_scno.c \ @@ -476,6 +489,7 @@ EXTRA_DIST = \ 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 \ linux/metag/get_syscall_args.c \ @@ -485,6 +499,7 @@ EXTRA_DIST = \ linux/metag/set_scno.c \ linux/metag/syscallent.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 \ @@ -499,6 +514,7 @@ EXTRA_DIST = \ 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 \ @@ -521,6 +537,7 @@ EXTRA_DIST = \ linux/netlink_diag.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 \ @@ -531,6 +548,7 @@ EXTRA_DIST = \ linux/nios2/syscallent.h \ 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 \ @@ -543,6 +561,7 @@ EXTRA_DIST = \ linux/personality.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 \ linux/powerpc/get_error.c \ @@ -558,6 +577,7 @@ EXTRA_DIST = \ linux/powerpc/userent.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 \ linux/powerpc64/errnoent1.h \ @@ -580,6 +600,7 @@ EXTRA_DIST = \ linux/ptp_clock.h \ linux/riscv/arch_regs.c \ linux/riscv/arch_regs.h \ + linux/riscv/arch_rt_sigframe.c \ linux/riscv/errnoent1.h \ linux/riscv/get_error.c \ linux/riscv/get_scno.c \ @@ -596,6 +617,7 @@ EXTRA_DIST = \ linux/rt_sigframe.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 \ @@ -611,6 +633,7 @@ EXTRA_DIST = \ linux/s390/userent1.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 \ @@ -624,6 +647,7 @@ EXTRA_DIST = \ linux/s390x/userent.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 \ @@ -637,6 +661,7 @@ EXTRA_DIST = \ linux/sh/userent0.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 \ @@ -653,6 +678,7 @@ EXTRA_DIST = \ 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/gen.pl \ @@ -670,6 +696,7 @@ EXTRA_DIST = \ 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 \ linux/sparc64/errnoent1.h \ @@ -692,6 +719,7 @@ EXTRA_DIST = \ linux/syscall.h \ linux/tile/arch_regs.c \ linux/tile/arch_regs.h \ + linux/tile/arch_rt_sigframe.c \ linux/tile/arch_sigreturn.c \ linux/tile/errnoent1.h \ linux/tile/get_error.c \ @@ -714,6 +742,7 @@ EXTRA_DIST = \ linux/userent0.h \ linux/x32/arch_regs.c \ linux/x32/arch_regs.h \ + linux/x32/arch_rt_sigframe.c \ linux/x32/arch_sigreturn.c \ linux/x32/errnoent1.h \ linux/x32/get_error.c \ @@ -732,6 +761,7 @@ EXTRA_DIST = \ linux/x32/userent.h \ linux/x86_64/arch_regs.c \ linux/x86_64/arch_regs.h \ + linux/x86_64/arch_rt_sigframe.c \ linux/x86_64/arch_sigreturn.c \ linux/x86_64/errnoent1.h \ linux/x86_64/errnoent2.h \ @@ -757,6 +787,7 @@ 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 629efcd5..793971e8 100644 --- a/defs.h +++ b/defs.h @@ -411,7 +411,9 @@ extern void call_summary(FILE *); extern void clear_regs(void); extern void get_regs(pid_t pid); -extern int get_scno(struct tcb *tcp); +extern int get_scno(struct tcb *); +extern kernel_ulong_t get_rt_sigframe_addr(struct tcb *); + /** * Convert syscall number to syscall name. * diff --git a/linux/aarch64/arch_rt_sigframe.c b/linux/aarch64/arch_rt_sigframe.c new file mode 100644 index 00000000..5400a523 --- /dev/null +++ b/linux/aarch64/arch_rt_sigframe.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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; +} diff --git a/linux/alpha/arch_rt_sigframe.c b/linux/alpha/arch_rt_sigframe.c new file mode 100644 index 00000000..3343183d --- /dev/null +++ b/linux/alpha/arch_rt_sigframe.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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->pid, REG_FP, &addr) ? 0 : addr; +} diff --git a/linux/arc/arch_rt_sigframe.c b/linux/arc/arch_rt_sigframe.c new file mode 100644 index 00000000..a735d046 --- /dev/null +++ b/linux/arc/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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; +} diff --git a/linux/arm/arch_rt_sigframe.c b/linux/arm/arch_rt_sigframe.c new file mode 100644 index 00000000..0282bd37 --- /dev/null +++ b/linux/arm/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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; +} diff --git a/linux/avr32/arch_rt_sigframe.c b/linux/avr32/arch_rt_sigframe.c new file mode 100644 index 00000000..6650f8e7 --- /dev/null +++ b/linux/avr32/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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; +} diff --git a/linux/bfin/arch_rt_sigframe.c b/linux/bfin/arch_rt_sigframe.c new file mode 100644 index 00000000..d84b8348 --- /dev/null +++ b/linux/bfin/arch_rt_sigframe.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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->pid, PT_USP, &addr) ? 0 : addr; +} diff --git a/linux/crisv10/arch_rt_sigframe.c b/linux/crisv10/arch_rt_sigframe.c new file mode 100644 index 00000000..f3d5f108 --- /dev/null +++ b/linux/crisv10/arch_rt_sigframe.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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->pid, 4 * PT_USP, &addr) ? 0 : addr; +} diff --git a/linux/crisv32/arch_rt_sigframe.c b/linux/crisv32/arch_rt_sigframe.c new file mode 100644 index 00000000..2f457462 --- /dev/null +++ b/linux/crisv32/arch_rt_sigframe.c @@ -0,0 +1 @@ +#include "crisv10/arch_rt_sigframe.c" diff --git a/linux/hppa/arch_rt_sigframe.c b/linux/hppa/arch_rt_sigframe.c new file mode 100644 index 00000000..e3c62fa5 --- /dev/null +++ b/linux/hppa/arch_rt_sigframe.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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. + */ + +#include "rt_sigframe.h" + +#define SIGFRAME (sizeof(long) * 16) +#define FUNCTIONCALLFRAME (sizeof(long) * 12) +#define RT_SIGFRAME_SIZE \ + (((sizeof(struct_rt_sigframe) + FUNCTIONCALLFRAME)) & -SIGFRAME) + +FUNC_GET_RT_SIGFRAME_ADDR +{ + unsigned long addr; + + return upeek(tcp->pid, 4 * 30, &addr) + ? 0 : (addr & ~1UL) - RT_SIGFRAME_SIZE; +} diff --git a/linux/i386/arch_rt_sigframe.c b/linux/i386/arch_rt_sigframe.c new file mode 100644 index 00000000..b5084082 --- /dev/null +++ b/linux/i386/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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 *i386_esp_ptr - 4; +} diff --git a/linux/ia64/arch_rt_sigframe.c b/linux/ia64/arch_rt_sigframe.c new file mode 100644 index 00000000..f6e660c0 --- /dev/null +++ b/linux/ia64/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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 *ia64_frame_ptr + 16; +} diff --git a/linux/m68k/arch_rt_sigframe.c b/linux/m68k/arch_rt_sigframe.c new file mode 100644 index 00000000..9ba26e1b --- /dev/null +++ b/linux/m68k/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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; +} diff --git a/linux/metag/arch_rt_sigframe.c b/linux/metag/arch_rt_sigframe.c new file mode 100644 index 00000000..898c5d24 --- /dev/null +++ b/linux/metag/arch_rt_sigframe.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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. + */ + +#include "rt_sigframe.h" + +FUNC_GET_RT_SIGFRAME_ADDR +{ + return *metag_sp_ptr - sizeof(struct_rt_sigframe); +} diff --git a/linux/microblaze/arch_rt_sigframe.c b/linux/microblaze/arch_rt_sigframe.c new file mode 100644 index 00000000..10d03db6 --- /dev/null +++ b/linux/microblaze/arch_rt_sigframe.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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->pid, 4 * 1, &addr) ? 0 : addr; +} diff --git a/linux/mips/arch_rt_sigframe.c b/linux/mips/arch_rt_sigframe.c new file mode 100644 index 00000000..03acc73f --- /dev/null +++ b/linux/mips/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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; +} diff --git a/linux/nios2/arch_rt_sigframe.c b/linux/nios2/arch_rt_sigframe.c new file mode 100644 index 00000000..7359f116 --- /dev/null +++ b/linux/nios2/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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; +} diff --git a/linux/or1k/arch_rt_sigframe.c b/linux/or1k/arch_rt_sigframe.c new file mode 100644 index 00000000..4f8cbbe4 --- /dev/null +++ b/linux/or1k/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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; +} diff --git a/linux/powerpc/arch_rt_sigframe.c b/linux/powerpc/arch_rt_sigframe.c new file mode 100644 index 00000000..4a1c4315 --- /dev/null +++ b/linux/powerpc/arch_rt_sigframe.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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. + */ + +#define SIGNAL_FRAMESIZE32 64 + +FUNC_GET_RT_SIGFRAME_ADDR +{ + return ppc_regs.gpr[1] + SIGNAL_FRAMESIZE32 + 16; +} diff --git a/linux/powerpc64/arch_rt_sigframe.c b/linux/powerpc64/arch_rt_sigframe.c new file mode 100644 index 00000000..333f7080 --- /dev/null +++ b/linux/powerpc64/arch_rt_sigframe.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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 ppc_get_rt_sigframe_addr(struct tcb *tcp) + +#include "powerpc/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 + ? ppc_get_rt_sigframe_addr(tcp) : ppc_regs.gpr[1]; +} diff --git a/linux/riscv/arch_rt_sigframe.c b/linux/riscv/arch_rt_sigframe.c new file mode 100644 index 00000000..54526c49 --- /dev/null +++ b/linux/riscv/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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; +} diff --git a/linux/s390/arch_rt_sigframe.c b/linux/s390/arch_rt_sigframe.c new file mode 100644 index 00000000..2cd468b9 --- /dev/null +++ b/linux/s390/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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; +} diff --git a/linux/s390x/arch_rt_sigframe.c b/linux/s390x/arch_rt_sigframe.c new file mode 100644 index 00000000..9731c0e7 --- /dev/null +++ b/linux/s390x/arch_rt_sigframe.c @@ -0,0 +1 @@ +#include "s390/arch_rt_sigframe.c" diff --git a/linux/sh/arch_rt_sigframe.c b/linux/sh/arch_rt_sigframe.c new file mode 100644 index 00000000..ae16e3f5 --- /dev/null +++ b/linux/sh/arch_rt_sigframe.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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->pid, sizeof(long) * 15, &addr) ? 0 : addr; +} diff --git a/linux/sh64/arch_rt_sigframe.c b/linux/sh64/arch_rt_sigframe.c new file mode 100644 index 00000000..21204e3b --- /dev/null +++ b/linux/sh64/arch_rt_sigframe.c @@ -0,0 +1 @@ +#include "sh/arch_rt_sigframe.c" diff --git a/linux/sparc/arch_rt_sigframe.c b/linux/sparc/arch_rt_sigframe.c new file mode 100644 index 00000000..418443ea --- /dev/null +++ b/linux/sparc/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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]; +} diff --git a/linux/sparc64/arch_rt_sigframe.c b/linux/sparc64/arch_rt_sigframe.c new file mode 100644 index 00000000..0bad84da --- /dev/null +++ b/linux/sparc64/arch_rt_sigframe.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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. + */ + +#define STACK_BIAS 2047 + +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; +} diff --git a/linux/tile/arch_rt_sigframe.c b/linux/tile/arch_rt_sigframe.c new file mode 100644 index 00000000..8d15e5c2 --- /dev/null +++ b/linux/tile/arch_rt_sigframe.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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; +} diff --git a/linux/x32/arch_rt_sigframe.c b/linux/x32/arch_rt_sigframe.c new file mode 100644 index 00000000..1cc45e5f --- /dev/null +++ b/linux/x32/arch_rt_sigframe.c @@ -0,0 +1 @@ +#include "x86_64/arch_rt_sigframe.c" diff --git a/linux/x86_64/arch_rt_sigframe.c b/linux/x86_64/arch_rt_sigframe.c new file mode 100644 index 00000000..d2c7867f --- /dev/null +++ b/linux/x86_64/arch_rt_sigframe.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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); +} diff --git a/linux/xtensa/arch_rt_sigframe.c b/linux/xtensa/arch_rt_sigframe.c new file mode 100644 index 00000000..a40c76a5 --- /dev/null +++ b/linux/xtensa/arch_rt_sigframe.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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->pid, REG_A_BASE + 3, &addr) ? 0 : addr; +} diff --git a/rt_sigframe.c b/rt_sigframe.c new file mode 100644 index 00000000..d9bcb4ff --- /dev/null +++ b/rt_sigframe.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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. + */ + +#include "defs.h" +#include "regs.h" +#include "ptrace.h" + +#define DEF_FUNC_GET_RT_SIGFRAME_ADDR \ + kernel_ulong_t get_rt_sigframe_addr(struct tcb *tcp) +#define FUNC_GET_RT_SIGFRAME_ADDR DEF_FUNC_GET_RT_SIGFRAME_ADDR + +#include "arch_rt_sigframe.c" -- 2.40.0