+2015-10-13 H.J. Lu <hongjiu.lu@intel.com>
+
+ * sysdeps/unix/sysv/linux/sysdep.h: New file.
+ * sysdeps/unix/sysv/linux/i386/sysdep.c: Likewise.
+ * sysdeps/unix/sysv/linux/alpha/sysdep.h: Include
+ <sysdeps/unix/sysv/linux/sysdep.h>.
+ * sysdeps/unix/sysv/linux/arm/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/generic/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/hppa/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/ia64/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/microblaze/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/mips/mips32/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/sh/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep.h: Likewise.
+ * sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) == csu]
+ (sysdep-dl-routines): Add sysdep.
+ [$(subdir) == nptl] (libpthread-routines): Likewise.
+ [$(subdir) == rt] (librt-routines): Likewise.
+ * sysdeps/unix/sysv/linux/i386/clone.S (__clone): Don't check
+ PIC when branching to SYSCALL_ERROR_LABEL.
+ * sysdeps/unix/sysv/linux/i386/sysdep.S: Removed.
+ * sysdeps/unix/sysv/linux/i386/sysdep.h: Include
+ <sysdeps/unix/sysv/linux/sysdep.h>.
+ (SYSCALL_ERROR_LABEL): Changed to __syscall_error.
+ (SYSCALL_ERROR_ERRNO): Removed.
+ (SYSCALL_ERROR_HANDLER): Changed to empty.
+ (SYSCALL_ERROR_HANDLER_TLS_STORE): Likewise.
+ (__syscall_error): New prototype.
+ [IS_IN (libc)] (INLINE_SYSCALL): New macro.
+ (INLINE_SYSCALL_ERROR_RETURN_VALUE): Likewise.
+
2015-10-13 H.J. Lu <hongjiu.lu@intel.com>
[BZ #19124]
#endif
/* There is some commonality. */
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/alpha/sysdep.h>
#include <tls.h>
#define _LINUX_ARM_SYSDEP_H 1
/* There is some commonality. */
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/arm/sysdep.h>
/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */
#include <bits/wordsize.h>
#include <kernel-features.h>
#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/sysdep.h>
/* Provide the common name to allow more code reuse. */
#define __NR__llseek __NR_llseek
#define _LINUX_HPPA_SYSDEP_H 1
#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/hppa/sysdep.h>
/* Defines RTLD_PRIVATE_ERRNO. */
ifeq ($(subdir),stdlib)
gen-as-const-headers += ucontext_i.sym
endif
+
+ifeq ($(subdir),csu)
+sysdep-dl-routines += sysdep
+endif
+
+ifeq ($(subdir),nptl)
+# pull in __syscall_error routine
+libpthread-routines += sysdep
+endif
+
+ifeq ($(subdir),rt)
+# pull in __syscall_error routine
+librt-routines += sysdep
+endif
/* Sanity check arguments. */
movl $-EINVAL,%eax
movl FUNC(%esp),%ecx /* no NULL function pointers */
-#ifdef PIC
- jecxz SYSCALL_ERROR_LABEL
-#else
testl %ecx,%ecx
jz SYSCALL_ERROR_LABEL
-#endif
movl STACK(%esp),%ecx /* no NULL stack pointers */
-#ifdef PIC
- jecxz SYSCALL_ERROR_LABEL
-#else
testl %ecx,%ecx
jz SYSCALL_ERROR_LABEL
-#endif
/* Insert the argument onto the new stack. Make sure the new
thread is started with an alignment of (mod 16). */
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <errno.h>
#include <sysdep.h>
-/* The following code is only used in the shared library when we
- compile the reentrant version. Otherwise each system call defines
- each own version. */
-
-#ifndef PIC
-
-/* The syscall stubs jump here when they detect an error.
- The code for Linux is almost identical to the canonical Unix/i386
- code, except that the error number in %eax is negated. */
-
-#undef CALL_MCOUNT
-#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %eax. */
-
- .text
-ENTRY (__syscall_error)
- negl %eax
-
-#define __syscall_error __syscall_error_1
-#include <sysdeps/unix/i386/sysdep.S>
-
-#endif /* !PIC */
+/* This routine is jumped to by all the syscall handlers, to stash
+ an error number into errno. ERROR is the negative error number
+ returned from the x86 kernel. */
+int
+__attribute__ ((__regparm__ (1)))
+__syscall_error (int error)
+{
+ __set_errno (-error);
+ return -1;
+}
#define _LINUX_I386_SYSDEP_H 1
/* There is some commonality. */
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/i386/sysdep.h>
/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */
#include <dl-sysdep.h>
/* We don't want the label for the error handle to be global when we define
it here. */
-#ifdef PIC
-# define SYSCALL_ERROR_LABEL 0f
-#else
-# define SYSCALL_ERROR_LABEL syscall_error
-#endif
+#define SYSCALL_ERROR_LABEL __syscall_error
#undef PSEUDO
#define PSEUDO(name, syscall_name, args) \
#define ret_ERRVAL ret
-#ifndef PIC
-# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
-#else
-
-# if RTLD_PRIVATE_ERRNO
-# define SYSCALL_ERROR_HANDLER \
-0:SETUP_PIC_REG(cx); \
- addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
- negl %eax; \
- movl %eax, rtld_errno@GOTOFF(%ecx); \
- orl $-1, %eax; \
- ret;
-
-# elif defined _LIBC_REENTRANT
-
-# if IS_IN (libc)
-# define SYSCALL_ERROR_ERRNO __libc_errno
-# else
-# define SYSCALL_ERROR_ERRNO errno
-# endif
-# define SYSCALL_ERROR_HANDLER \
-0:SETUP_PIC_REG (cx); \
- addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
- movl SYSCALL_ERROR_ERRNO@GOTNTPOFF(%ecx), %ecx; \
- negl %eax; \
- SYSCALL_ERROR_HANDLER_TLS_STORE (%eax, %ecx); \
- orl $-1, %eax; \
- ret;
-# ifndef NO_TLS_DIRECT_SEG_REFS
-# define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
- movl src, %gs:(destoff)
-# else
-# define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
- addl %gs:0, destoff; \
- movl src, (destoff)
-# endif
-# else
-/* Store (- %eax) into errno through the GOT. */
-# define SYSCALL_ERROR_HANDLER \
-0:SETUP_PIC_REG(cx); \
- addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
- negl %eax; \
- movl errno@GOT(%ecx), %ecx; \
- movl %eax, (%ecx); \
- orl $-1, %eax; \
- ret;
-# endif /* _LIBC_REENTRANT */
-#endif /* PIC */
-
+#define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.c is used. */
/* The original calling convention for system calls on Linux/i386 is
to use int $0x80. */
#else /* !__ASSEMBLER__ */
+extern int __syscall_error (int)
+ attribute_hidden __attribute__ ((__regparm__ (1)));
+
/* We need some help from the assembler to generate optimal code. We
define some macros here which later will be used. */
asm (".L__X'%ebx = 1\n\t"
/* Define a macro which expands inline into the wrapper code for a system
call. */
#undef INLINE_SYSCALL
-#define INLINE_SYSCALL(name, nr, args...) \
+#if IS_IN (libc)
+# define INLINE_SYSCALL(name, nr, args...) \
+ ({ \
+ unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
+ __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, )) \
+ ? __syscall_error (-INTERNAL_SYSCALL_ERRNO (resultvar, )) \
+ : (int) resultvar; })
+#else
+# define INLINE_SYSCALL(name, nr, args...) \
({ \
unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
resultvar = 0xffffffff; \
} \
(int) resultvar; })
+#endif
+
+/* Set error number and return -1. Return the internal function,
+ __syscall_error, which sets errno from the negative error number
+ and returns -1, to avoid PIC. */
+#undef INLINE_SYSCALL_ERROR_RETURN_VALUE
+#define INLINE_SYSCALL_ERROR_RETURN_VALUE(resultvar) \
+ __syscall_error (-(resultvar))
/* List of system calls which are supported as vsyscalls. */
# define HAVE_CLOCK_GETTIME_VSYSCALL 1
#define _LINUX_IA64_SYSDEP_H 1
#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/ia64/sysdep.h>
#include <dl-sysdep.h>
#include <tls.h>
License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <tls.h>
/* Defines RTLD_PRIVATE_ERRNO. */
#define _LINUX_MICROBLAZE_SYSDEP_H 1
#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/microblaze/sysdep.h>
/* Defines RTLD_PRIVATE_ERRNO. */
#define _LINUX_MIPS_MIPS32_SYSDEP_H 1
/* There is some commonality. */
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/mips/mips32/sysdep.h>
#include <tls.h>
#define _LINUX_MIPS_SYSDEP_H 1
/* There is some commonality. */
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/mips/mips64/n32/sysdep.h>
#include <tls.h>
#define _LINUX_MIPS_SYSDEP_H 1
/* There is some commonality. */
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/mips/mips64/n64/sysdep.h>
#include <tls.h>
#ifndef _LINUX_POWERPC_SYSDEP_H
#define _LINUX_POWERPC_SYSDEP_H 1
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/powerpc/sysdep.h>
#include <tls.h>
#ifndef _LINUX_POWERPC_SYSDEP_H
#define _LINUX_POWERPC_SYSDEP_H 1
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/powerpc/sysdep.h>
#include <tls.h>
#include <sysdeps/s390/s390-32/sysdep.h>
#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <dl-sysdep.h> /* For RTLD_PRIVATE_ERRNO. */
#include <tls.h>
#include <sysdeps/s390/s390-64/sysdep.h>
#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <dl-sysdep.h> /* For RTLD_PRIVATE_ERRNO. */
#include <tls.h>
#define _LINUX_SH_SYSDEP_H 1
/* There is some commonality. */
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/sh/sysdep.h>
#include <tls.h>
#define _LINUX_SPARC_SYSDEP_H 1
#include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/sparc/sysdep.h>
#ifdef __ASSEMBLER__
--- /dev/null
+/* Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Set error number and return -1. A target may choose to return the
+ internal function, __syscall_error, which sets errno and returns -1.
+ We use -1l, instead of -1, so that it can be casted to (void *). */
+#define INLINE_SYSCALL_ERROR_RETURN_VALUE(err) \
+ ({ \
+ __set_errno (err); \
+ -1l; \
+ })
#define _LINUX_X86_64_SYSDEP_H 1
/* There is some commonality. */
+#include <sysdeps/unix/sysv/linux/sysdep.h>
#include <sysdeps/unix/x86_64/sysdep.h>
#include <tls.h>