From 3ba575169aabc83993759305c0394f58ad1ce3e0 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 31 Aug 2011 17:30:41 -0700 Subject: Fix sparc localplt testcase failures. --- sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h | 110 ++++++++++++++----------- sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h | 108 +++++++++++++----------- sysdeps/unix/sysv/linux/sparc/sysdep.h | 89 ++++++++++++-------- 3 files changed, 175 insertions(+), 132 deletions(-) (limited to 'sysdeps/unix/sysv/linux') diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h index 3cb0a48c95..8af045dc2b 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h @@ -57,20 +57,14 @@ C_LABEL(name) \ #define LOC(name) .L##name - /* If the offset to __syscall_error fits into a signed 22-bit - * immediate branch offset, the linker will relax the call into - * a normal branch. - */ #define PSEUDO(name, syscall_name, args) \ .text; \ - .globl __syscall_error; \ ENTRY(name); \ LOADSYSCALL(syscall_name); \ ta 0x10; \ bcc 1f; \ - mov %o7, %g1; \ - call __syscall_error; \ - mov %g1, %o7; \ + nop; \ + SYSCALL_ERROR_HANDLER \ 1: #define PSEUDO_NOERRNO(name, syscall_name, args)\ @@ -88,50 +82,70 @@ ENTRY(name); \ #define PSEUDO_END(name) \ END(name) -#else /* __ASSEMBLER__ */ - -#if defined SHARED && defined DO_VERSIONING && defined PIC \ - && !defined NO_HIDDEN && !defined NOT_IN_libc -# define CALL_ERRNO_LOCATION "call __GI___errno_location;" +#ifndef PIC +# define SYSCALL_ERROR_HANDLER \ + mov %o7, %g1; \ + call __syscall_error; \ + mov %g1, %o7; #else -# define CALL_ERRNO_LOCATION "call __errno_location;" -#endif +# if RTLD_PRIVATE_ERRNO +# define SYSCALL_ERROR_HANDLER \ +0: SETUP_PIC_REG(o2,g1) \ + sethi %hi(rtld_errno), %g1; \ + or %g1, %lo(rtld_errno), %g1; \ + ld [%o2 + %g1], %g1; \ + st %o0, [%g1]; \ + jmp %o7 + 8; \ + mov -1, %o0; +# elif defined _LIBC_REENTRANT + +# if USE___THREAD +# ifndef NOT_IN_libc +# define SYSCALL_ERROR_ERRNO __libc_errno +# else +# define SYSCALL_ERROR_ERRNO errno +# endif +# define SYSCALL_ERROR_HANDLER \ +0: SETUP_PIC_REG(o2,g1) \ + sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \ + add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \ + ld [%o2 + %g1], %g1, %tie_ld(SYSCALL_ERROR_ERRNO); \ + st %o0, [%g7 + %g1]; \ + jmp %o7 + 8; \ + mov -1, %o0; +# else +# define SYSCALL_ERROR_HANDLER \ +0: save %sp, -96, %sp; \ + cfi_def_cfa_register(%fp); \ + cfi_window_save; \ + cfi_register (%o7, %i7); \ + call __errno_location; \ + nop; \ + st %i0, [%o0]; \ + jmp %i7 + 8; \ + restore %g0, -1, %o0; +# endif +# else +# define SYSCALL_ERROR_HANDLER \ +0: SETUP_PIC_REG(o2,g1) \ + sethi %hi(errno), %g1; \ + or %g1, %lo(errno), %g1; \ + ld [%o2 + %g1], %g1; \ + st %o0, [%g1]; \ + jmp %o7 + 8; \ + mov -1, %o0; +# endif /* _LIBC_REENTRANT */ +#endif /* PIC */ + + +#else /* __ASSEMBLER__ */ #define __SYSCALL_STRING \ "ta 0x10;" \ - "bcs 2f;" \ - " nop;" \ - "1:" \ - ".subsection 2;" \ - "2:" \ - "save %%sp, -192, %%sp;" \ - CALL_ERRNO_LOCATION \ - " nop;" \ - "st %%i0,[%%o0];" \ - "ba 1b;" \ - " restore %%g0, -1, %%o0;" \ - ".previous;" - -#define __CLONE_SYSCALL_STRING \ - "ta 0x10;" \ - "bcs 2f;" \ - " sub %%o1, 1, %%o1;" \ - "and %%o0, %%o1, %%o0;" \ - "1:" \ - ".subsection 2;" \ - "2:" \ - "save %%sp, -192, %%sp;" \ - CALL_ERRNO_LOCATION \ - " nop;" \ - "st %%i0, [%%o0];" \ - "ba 1b;" \ - " restore %%g0, -1, %%o0;" \ - ".previous;" - -#define __INTERNAL_SYSCALL_STRING \ - "ta 0x10;" \ - "bcs,a 1f;" \ - " sub %%g0, %%o0, %%o0;" \ + "bcc 1f;" \ + " mov 0, %%g1;" \ + "sub %%g0, %%o0, %%o0;" \ + "mov 1, %%g1;" \ "1:" #define __SYSCALL_CLOBBERS \ diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h index 79fa13de75..bdd1d45bd7 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h @@ -21,7 +21,7 @@ #ifndef _LINUX_SPARC64_SYSDEP_H #define _LINUX_SPARC64_SYSDEP_H 1 -#include +#include #ifdef IS_IN_rtld # include /* Defines RTLD_PRIVATE_ERRNO. */ @@ -64,20 +64,14 @@ C_LABEL(name) \ cfi_endproc; \ .size name, . - name - /* If the offset to __syscall_error fits into a signed 22-bit - * immediate branch offset, the linker will relax the call into - * a normal branch. - */ #define PSEUDO(name, syscall_name, args) \ .text; \ - .globl __syscall_error; \ ENTRY(name); \ LOADSYSCALL(syscall_name); \ ta 0x6d; \ bcc,pt %xcc, 1f; \ - mov %o7, %g1; \ - call __syscall_error; \ - mov %g1, %o7; \ + nop; \ + SYSCALL_ERROR_HANDLER \ 1: #define PSEUDO_NOERRNO(name, syscall_name, args)\ @@ -95,51 +89,69 @@ ENTRY(name); \ #define PSEUDO_END(name) \ END(name) - -/* Careful here! This "ret" define can interfere; use jmpl if unsure. */ -#define ret retl; nop -#define ret_NOERRNO retl; nop -#define ret_ERRVAL retl; nop -#define r0 %o0 -#define r1 %o1 -#define MOVE(x,y) mov x, y +#ifndef PIC +# define SYSCALL_ERROR_HANDLER \ + mov %o7, %g1; \ + call __syscall_error; \ + mov %g1, %o7; +#else +# if RTLD_PRIVATE_ERRNO +# define SYSCALL_ERROR_HANDLER \ +0: SETUP_PIC_REG(o2,g1) \ + sethi %hi(rtld_errno), %g1; \ + or %g1, %lo(rtld_errno), %g1; \ + ldx [%o2 + %g1], %g1; \ + st %o0, [%g1]; \ + jmp %o7 + 8; \ + mov -1, %o0; +# elif defined _LIBC_REENTRANT + +# if USE___THREAD +# ifndef NOT_IN_libc +# define SYSCALL_ERROR_ERRNO __libc_errno +# else +# define SYSCALL_ERROR_ERRNO errno +# endif +# define SYSCALL_ERROR_HANDLER \ +0: SETUP_PIC_REG(o2,g1) \ + sethi %tie_hi22(SYSCALL_ERROR_ERRNO), %g1; \ + add %g1, %tie_lo10(SYSCALL_ERROR_ERRNO), %g1; \ + ldx [%o2 + %g1], %g1, %tie_ldx(SYSCALL_ERROR_ERRNO);\ + st %o0, [%g7 + %g1]; \ + jmp %o7 + 8; \ + mov -1, %o0; +# else +# define SYSCALL_ERROR_HANDLER \ +0: save %sp, -176, %sp; \ + cfi_def_cfa_register(%fp); \ + cfi_window_save; \ + cfi_register (%o7, %i7); \ + call __errno_location; \ + nop; \ + st %i0, [%o0]; \ + jmp %i7 + 8; \ + restore %g0, -1, %o0; +# endif +# else +# define SYSCALL_ERROR_HANDLER \ +0: SETUP_PIC_REG(o2,g1) \ + sethi %hi(errno), %g1; \ + or %g1, %lo(errno), %g1; \ + ldx [%o2 + %g1], %g1; \ + st %o0, [%g1]; \ + jmp %o7 + 8; \ + mov -1, %o0; +# endif /* _LIBC_REENTRANT */ +#endif /* PIC */ #else /* __ASSEMBLER__ */ -#if defined SHARED && defined DO_VERSIONING && defined PIC \ - && !defined NO_HIDDEN && !defined NOT_IN_libc -# define CALL_ERRNO_LOCATION "call __GI___errno_location;" -#else -# define CALL_ERRNO_LOCATION "call __errno_location;" -#endif - #define __SYSCALL_STRING \ "ta 0x6d;" \ "bcc,pt %%xcc, 1f;" \ - " nop;" \ - "save %%sp, -192, %%sp;" \ - CALL_ERRNO_LOCATION \ - " nop;" \ - "st %%i0,[%%o0];" \ - "restore %%g0, -1, %%o0;" \ - "1:" - -#define __CLONE_SYSCALL_STRING \ - "ta 0x6d;" \ - "bcc,pt %%xcc, 1f;" \ - " sub %%o1, 1, %%o1;" \ - "save %%sp, -192, %%sp;" \ - CALL_ERRNO_LOCATION \ - " mov -1, %%i1;" \ - "st %%i0,[%%o0];" \ - "restore %%g0, -1, %%o0;" \ - "1:" \ - "and %%o0, %%o1, %%o0" - -#define __INTERNAL_SYSCALL_STRING \ - "ta 0x6d;" \ - "bcs,a,pt %%xcc, 1f;" \ - " sub %%g0, %%o0, %%o0;" \ + " mov 0, %%g1;" \ + "sub %%g0, %%o0, %%o0;" \ + "mov 1, %%g1;" \ "1:" #define __SYSCALL_CLOBBERS \ diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h index 101638a53f..f69e1a92ff 100644 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h @@ -21,101 +21,109 @@ #define _LINUX_SPARC_SYSDEP_H 1 #undef INLINE_SYSCALL -#define INLINE_SYSCALL(name, nr, args...) \ - inline_syscall##nr(__SYSCALL_STRING, __NR_##name, args) +#define INLINE_SYSCALL(name, nr, args...) \ +({ INTERNAL_SYSCALL_DECL(err); \ + unsigned int resultvar = INTERNAL_SYSCALL(name, err, nr, args); \ + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, err), 0)) \ + { \ + __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err)); \ + resultvar = 0xffffffff; \ + } \ + (int) resultvar; \ +}) #undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) do { } while (0) +#define INTERNAL_SYSCALL_DECL(err) \ + register long err __asm__("g1"); #undef INTERNAL_SYSCALL #define INTERNAL_SYSCALL(name, err, nr, args...) \ - inline_syscall##nr(__INTERNAL_SYSCALL_STRING, __NR_##name, args) + inline_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args) #undef INTERNAL_SYSCALL_NCS #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ - inline_syscall##nr(__INTERNAL_SYSCALL_STRING, name, args) + inline_syscall##nr(__SYSCALL_STRING, err, name, args) #undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val, err) \ - ((unsigned long) (val) >= -515L) +#define INTERNAL_SYSCALL_ERROR_P(val, err) ((err) != 0) #undef INTERNAL_SYSCALL_ERRNO #define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) -#define inline_syscall0(string,name,dummy...) \ +#define inline_syscall0(string,err,name,dummy...) \ ({ \ register long __o0 __asm__ ("o0"); \ - register long __g1 __asm__ ("g1") = name; \ - __asm __volatile (string : "=r" (__g1), "=r" (__o0) : \ - "0" (__g1) : \ + err = name; \ + __asm __volatile (string : "=r" (err), "=r" (__o0) : \ + "0" (err) : \ __SYSCALL_CLOBBERS); \ __o0; \ }) -#define inline_syscall1(string,name,arg1) \ +#define inline_syscall1(string,err,name,arg1) \ ({ \ register long __o0 __asm__ ("o0") = (long)(arg1); \ - register long __g1 __asm__ ("g1") = name; \ - __asm __volatile (string : "=r" (__g1), "=r" (__o0) : \ - "0" (__g1), "1" (__o0) : \ + err = name; \ + __asm __volatile (string : "=r" (err), "=r" (__o0) : \ + "0" (err), "1" (__o0) : \ __SYSCALL_CLOBBERS); \ __o0; \ }) -#define inline_syscall2(string,name,arg1,arg2) \ +#define inline_syscall2(string,err,name,arg1,arg2) \ ({ \ register long __o0 __asm__ ("o0") = (long)(arg1); \ register long __o1 __asm__ ("o1") = (long)(arg2); \ - register long __g1 __asm__ ("g1") = name; \ - __asm __volatile (string : "=r" (__g1), "=r" (__o0) : \ - "0" (__g1), "1" (__o0), "r" (__o1) : \ + err = name; \ + __asm __volatile (string : "=r" (err), "=r" (__o0) : \ + "0" (err), "1" (__o0), "r" (__o1) : \ __SYSCALL_CLOBBERS); \ __o0; \ }) -#define inline_syscall3(string,name,arg1,arg2,arg3) \ +#define inline_syscall3(string,err,name,arg1,arg2,arg3) \ ({ \ register long __o0 __asm__ ("o0") = (long)(arg1); \ register long __o1 __asm__ ("o1") = (long)(arg2); \ register long __o2 __asm__ ("o2") = (long)(arg3); \ - register long __g1 __asm__ ("g1") = name; \ - __asm __volatile (string : "=r" (__g1), "=r" (__o0) : \ - "0" (__g1), "1" (__o0), "r" (__o1), \ + err = name; \ + __asm __volatile (string : "=r" (err), "=r" (__o0) : \ + "0" (err), "1" (__o0), "r" (__o1), \ "r" (__o2) : \ __SYSCALL_CLOBBERS); \ __o0; \ }) -#define inline_syscall4(string,name,arg1,arg2,arg3,arg4) \ +#define inline_syscall4(string,err,name,arg1,arg2,arg3,arg4) \ ({ \ register long __o0 __asm__ ("o0") = (long)(arg1); \ register long __o1 __asm__ ("o1") = (long)(arg2); \ register long __o2 __asm__ ("o2") = (long)(arg3); \ register long __o3 __asm__ ("o3") = (long)(arg4); \ - register long __g1 __asm__ ("g1") = name; \ - __asm __volatile (string : "=r" (__g1), "=r" (__o0) : \ - "0" (__g1), "1" (__o0), "r" (__o1), \ + err = name; \ + __asm __volatile (string : "=r" (err), "=r" (__o0) : \ + "0" (err), "1" (__o0), "r" (__o1), \ "r" (__o2), "r" (__o3) : \ __SYSCALL_CLOBBERS); \ __o0; \ }) -#define inline_syscall5(string,name,arg1,arg2,arg3,arg4,arg5) \ +#define inline_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5) \ ({ \ register long __o0 __asm__ ("o0") = (long)(arg1); \ register long __o1 __asm__ ("o1") = (long)(arg2); \ register long __o2 __asm__ ("o2") = (long)(arg3); \ register long __o3 __asm__ ("o3") = (long)(arg4); \ register long __o4 __asm__ ("o4") = (long)(arg5); \ - register long __g1 __asm__ ("g1") = name; \ - __asm __volatile (string : "=r" (__g1), "=r" (__o0) : \ - "0" (__g1), "1" (__o0), "r" (__o1), \ + err = name; \ + __asm __volatile (string : "=r" (err), "=r" (__o0) : \ + "0" (err), "1" (__o0), "r" (__o1), \ "r" (__o2), "r" (__o3), "r" (__o4) : \ __SYSCALL_CLOBBERS); \ __o0; \ }) -#define inline_syscall6(string,name,arg1,arg2,arg3,arg4,arg5,arg6) \ +#define inline_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6) \ ({ \ register long __o0 __asm__ ("o0") = (long)(arg1); \ register long __o1 __asm__ ("o1") = (long)(arg2); \ @@ -123,9 +131,9 @@ register long __o3 __asm__ ("o3") = (long)(arg4); \ register long __o4 __asm__ ("o4") = (long)(arg5); \ register long __o5 __asm__ ("o5") = (long)(arg6); \ - register long __g1 __asm__ ("g1") = name; \ - __asm __volatile (string : "=r" (__g1), "=r" (__o0) : \ - "0" (__g1), "1" (__o0), "r" (__o1), \ + err = name; \ + __asm __volatile (string : "=r" (err), "=r" (__o0) : \ + "0" (err), "1" (__o0), "r" (__o1), \ "r" (__o2), "r" (__o3), "r" (__o4), \ "r" (__o5) : \ __SYSCALL_CLOBBERS); \ @@ -140,11 +148,20 @@ register long __o3 __asm__ ("o3") = (long)(arg4); \ register long __o4 __asm__ ("o4") = (long)(arg5); \ register long __g1 __asm__ ("g1") = __NR_clone; \ - __asm __volatile (__CLONE_SYSCALL_STRING : \ + __asm __volatile (__SYSCALL_STRING : \ "=r" (__g1), "=r" (__o0), "=r" (__o1) : \ "0" (__g1), "1" (__o0), "2" (__o1), \ "r" (__o2), "r" (__o3), "r" (__o4) : \ __SYSCALL_CLOBBERS); \ + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (__o0, __g1), 0)) \ + { \ + __set_errno (INTERNAL_SYSCALL_ERRNO (__o0, __g1)); \ + __o0 = -1L; \ + } \ + else \ + { \ + __o0 &= (__o1 - 1); \ + } \ __o0; \ }) -- cgit v1.2.3