From 70a04a287a2875c82e6822c36e071afba5b63a62 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Wed, 29 Jan 2014 18:58:56 +0100 Subject: libc: mips: Fix setjmp/longjmp for MIPS64 N64 ABI When booting a Linux system with qemu-system-mips64 the execution of $(pwd) in the ash shell triggers a segmentation fault. Ash uses setjmp/longjmp for exception handling. After looking at the glibc implementation, I found some differences, with this patch tries to resolve. Now the system boots up fine and no segmentation faults occur. The global pointer should be restored and the types for the register values should be wide enough. See: http://www.cygwin.com/ml/libc-alpha/2003-03/msg00363.html Signed-off-by: Waldemar Brodkorb Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/mips/setjmp_aux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libc/sysdeps/linux/mips/setjmp_aux.c') diff --git a/libc/sysdeps/linux/mips/setjmp_aux.c b/libc/sysdeps/linux/mips/setjmp_aux.c index 559fe4e6c..9cffcc66c 100644 --- a/libc/sysdeps/linux/mips/setjmp_aux.c +++ b/libc/sysdeps/linux/mips/setjmp_aux.c @@ -28,7 +28,7 @@ int #if _MIPS_SIM == _MIPS_SIM_ABI64 -__sigsetjmp_aux (jmp_buf env, int savemask, long sp, long fp) +__sigsetjmp_aux (jmp_buf env, int savemask, long long sp, long long fp, long long gp) #else /* O32 || N32 */ __sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp) #endif /* O32 || N32 */ @@ -62,14 +62,14 @@ __sigsetjmp_aux (jmp_buf env, int savemask, int sp, int fp) #endif /* .. and the stack pointer; */ - env[0].__jmpbuf[0].__sp = (void *) sp; + env[0].__jmpbuf[0].__sp = (ptrsize) sp; /* .. and the FP; it'll be in s8. */ - env[0].__jmpbuf[0].__fp = (void *) fp; + env[0].__jmpbuf[0].__fp = (ptrsize) fp; /* .. and the GP; */ #if _MIPS_SIM == _MIPS_SIM_ABI64 - __asm__ __volatile__ ("sd $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp)); + env[0].__jmpbuf[0].__gp = (ptrsize) gp; #else __asm__ __volatile__ ("sw $gp, %0" : : "m" (env[0].__jmpbuf[0].__gp)); #endif -- cgit v1.2.3