From c8d6b02d714251afc82157eabb8752fd0010030e Mon Sep 17 00:00:00 2001 From: Dmitry Chestnykh Date: Tue, 30 Apr 2024 20:49:33 +0300 Subject: sparc: Fix incorrect sigreturn stub function implementation. This function haven't have prologue/epilogue/cfi directives etc. Signed-off-by: Dmitry Chestnykh --- libc/sysdeps/linux/sparc/Makefile.arch | 2 +- libc/sysdeps/linux/sparc/sigaction.c | 25 ++----------------------- libc/sysdeps/linux/sparc/sigreturn_stub.S | 14 ++++++++++++++ libc/sysdeps/linux/sparc/sysdep.h | 9 +++++++++ 4 files changed, 26 insertions(+), 24 deletions(-) create mode 100644 libc/sysdeps/linux/sparc/sigreturn_stub.S (limited to 'libc/sysdeps/linux') diff --git a/libc/sysdeps/linux/sparc/Makefile.arch b/libc/sysdeps/linux/sparc/Makefile.arch index d34624f36..c9529b344 100644 --- a/libc/sysdeps/linux/sparc/Makefile.arch +++ b/libc/sysdeps/linux/sparc/Makefile.arch @@ -6,7 +6,7 @@ # CSRC-y := brk.c __syscall_error.c sigaction.c -SSRC-y := __longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \ +SSRC-y := __longjmp.S setjmp.S sigreturn_stub.S bsd-setjmp.S bsd-_setjmp.S \ syscall.S urem.S udiv.S umul.S sdiv.S rem.S pipe.S fork.S vfork.S clone.S CSRC-$(UCLIBC_HAS_CONTEXT_FUNCS) += makecontext.c diff --git a/libc/sysdeps/linux/sparc/sigaction.c b/libc/sysdeps/linux/sparc/sigaction.c index 7895e3acd..447943e3a 100644 --- a/libc/sysdeps/linux/sparc/sigaction.c +++ b/libc/sysdeps/linux/sparc/sigaction.c @@ -30,8 +30,8 @@ _syscall5(int, rt_sigaction, int, a, int, b, int, c, int, d, int, e) -static void __rt_sigreturn_stub(void); -static void __sigreturn_stub(void); +void __rt_sigreturn_stub(void); +void __sigreturn_stub(void); int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact) { @@ -75,24 +75,3 @@ libc_hidden_weak(sigaction) # endif #endif - -static void -__rt_sigreturn_stub(void) -{ - __asm__( - "mov %0, %%g1\n\t" - "ta 0x10\n\t" - : /* no outputs */ - : "i" (__NR_rt_sigreturn) - ); -} -static void -__sigreturn_stub(void) -{ - __asm__( - "mov %0, %%g1\n\t" - "ta 0x10\n\t" - : /* no outputs */ - : "i" (__NR_sigreturn) - ); -} diff --git a/libc/sysdeps/linux/sparc/sigreturn_stub.S b/libc/sysdeps/linux/sparc/sigreturn_stub.S new file mode 100644 index 000000000..33f51409b --- /dev/null +++ b/libc/sysdeps/linux/sparc/sigreturn_stub.S @@ -0,0 +1,14 @@ +#include + + nop + nop + +ENTRY_NOCFI (__rt_sigreturn_stub) + mov __NR_rt_sigreturn, %g1 + ta 0x10 +END_NOCFI (__rt_sigreturn_stub) + +ENTRY_NOCFI (__sigreturn_stub) + mov __NR_sigreturn, %g1 + ta 0x10 +END_NOCFI (__sigreturn_stub) diff --git a/libc/sysdeps/linux/sparc/sysdep.h b/libc/sysdeps/linux/sparc/sysdep.h index c3897ec08..761d21454 100644 --- a/libc/sysdeps/linux/sparc/sysdep.h +++ b/libc/sysdeps/linux/sparc/sysdep.h @@ -17,6 +17,15 @@ C_LABEL(name) \ cfi_startproc; +#define ENTRY_NOCFI(name) \ + .align 4; \ + .global C_SYMBOL_NAME(name); \ + .type name, @function; \ +C_LABEL(name) + +#define END_NOCFI(name) \ + .size name, . - name + #define END(name) \ cfi_endproc; \ .size name, . - name -- cgit v1.2.3