2017-01-01 00:14:16 +00:00
|
|
|
/* Copyright (C) 2001-2017 Free Software Foundation, Inc.
|
2001-09-19 10:37:31 +00:00
|
|
|
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
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2001-09-19 10:37:31 +00:00
|
|
|
|
|
|
|
#ifndef _LINUX_X86_64_SYSDEP_H
|
|
|
|
#define _LINUX_X86_64_SYSDEP_H 1
|
|
|
|
|
|
|
|
/* There is some commonality. */
|
Add INLINE_SYSCALL_ERROR_RETURN_VALUE
For ia32 PIC, the first thing of many syscalls does is to call
__x86.get_pc_thunk.reg to load PC into reg in case there is an error,
which is required for setting errno. In most cases, there are no
errors. But we still call __x86.get_pc_thunk.reg. This patch adds
INLINE_SYSCALL_ERROR_RETURN_VALUE so that i386 can optimize setting
errno by branching to the internal __syscall_error without PLT.
With i386 INLINE_SYSCALL_ERROR_RETURN_VALUE and i386 syscall inlining
optimization for GCC 5, for sysdeps/unix/sysv/linux/fchmodat.c with
-O2 -march=i686 -mtune=generic, GCC 5.2 now generates:
<fchmodat>:
0: push %ebx
1: mov 0x14(%esp),%eax
5: mov 0x8(%esp),%ebx
9: mov 0xc(%esp),%ecx
d: mov 0x10(%esp),%edx
11: test $0xfffffeff,%eax
16: jne 38 <fchmodat+0x38>
18: test $0x1,%ah
1b: jne 48 <fchmodat+0x48>
1d: mov $0x132,%eax
22: call *%gs:0x10
29: cmp $0xfffff000,%eax
2e: ja 58 <fchmodat+0x58>
30: pop %ebx
31: ret
32: lea 0x0(%esi),%esi
38: pop %ebx
39: mov $0xffffffea,%eax
3e: jmp 3f <fchmodat+0x3f> 3f: R_386_PC32 __syscall_error
43: nop
44: lea 0x0(%esi,%eiz,1),%esi
48: pop %ebx
49: mov $0xffffffa1,%eax
4e: jmp 4f <fchmodat+0x4f> 4f: R_386_PC32 __syscall_error
53: nop
54: lea 0x0(%esi,%eiz,1),%esi
58: pop %ebx
59: jmp 5a <fchmodat+0x5a> 5a: R_386_PC32 __syscall_error
instead of
<fchmodat>:
0: sub $0x8,%esp
3: mov 0x18(%esp),%eax
7: mov %ebx,(%esp)
a: call b <fchmodat+0xb> b: R_386_PC32 __x86.get_pc_thunk.bx
f: add $0x2,%ebx 11: R_386_GOTPC _GLOBAL_OFFSET_TABLE_
15: mov %edi,0x4(%esp)
19: test $0xfffffeff,%eax
1e: jne 70 <fchmodat+0x70>
20: test $0x1,%ah
23: jne 88 <fchmodat+0x88>
25: mov 0x14(%esp),%edx
29: mov 0x10(%esp),%ecx
2d: mov 0xc(%esp),%edi
31: xchg %ebx,%edi
33: mov $0x132,%eax
38: call *%gs:0x10
3f: xchg %edi,%ebx
41: cmp $0xfffff000,%eax
46: ja 58 <fchmodat+0x58>
48: mov (%esp),%ebx
4b: mov 0x4(%esp),%edi
4f: add $0x8,%esp
52: ret
53: nop
54: lea 0x0(%esi,%eiz,1),%esi
58: mov 0x0(%ebx),%edx 5a: R_386_TLS_GOTIE __libc_errno
5e: neg %eax
60: mov %eax,%gs:(%edx)
63: mov $0xffffffff,%eax
68: jmp 48 <fchmodat+0x48>
6a: lea 0x0(%esi),%esi
70: mov 0x0(%ebx),%eax 72: R_386_TLS_GOTIE __libc_errno
76: movl $0x16,%gs:(%eax)
7d: mov $0xffffffff,%eax
82: jmp 48 <fchmodat+0x48>
84: lea 0x0(%esi,%eiz,1),%esi
88: mov 0x0(%ebx),%eax 8a: R_386_TLS_GOTIE __libc_errno
8e: movl $0x5f,%gs:(%eax)
95: mov $0xffffffff,%eax
9a: jmp 48 <fchmodat+0x48>
* 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 18:58:53 +00:00
|
|
|
#include <sysdeps/unix/sysv/linux/sysdep.h>
|
2001-09-19 10:37:31 +00:00
|
|
|
#include <sysdeps/unix/x86_64/sysdep.h>
|
2002-10-14 18:10:15 +00:00
|
|
|
#include <tls.h>
|
2001-09-19 10:37:31 +00:00
|
|
|
|
2014-11-20 15:39:43 +00:00
|
|
|
#if IS_IN (rtld)
|
* sysdeps/generic/bits/libc-tsd.h [USE___THREAD]: Conditional
changed from [USE_TLS && HAVE___THREAD].
* sysdeps/i386/dl-machine.h (elf_machine_type_class, elf_machine_rel):
Disable TLS relocs if [RTLD_BOOTSTRAP && !USE___THREAD].
* sysdeps/x86_64/dl-machine.h
(elf_machine_type_class, elf_machine_rela): Likewise.
* sysdeps/sh/dl-machine.h (elf_machine_type_class, elf_machine_rela):
Likewise.
* include/link.h (struct link_map): Remove member l_tls_tp_initialized.
* elf/rtld.c (_dl_start_final, dl_main): Don't use it.
(_dl_start): Conditionalize PT_TLS check on [USE___THREAD].
* sysdeps/i386/dl-tls.h (__TLS_GET_ADDR): Use ___tls_get_addr_internal
instead of ___tls_get_addr.
(___tls_get_addr_internal): Add attribute_hidden to decl.
* sysdeps/generic/ldsodefs.h (struct rtld_global): New variable
_dl_error_catch_tsd.
* elf/rtld.c (startup_error_tsd): New function.
(dl_main): Point _dl_error_catch_tsd at that.
* elf/dl-error.c: Don't use libc-tsd.h for DL_ERROR,
use new function pointer instead.
* elf/dl-tsd.c: New file.
* elf/Makefile (routines): Add it.
2002-10-07 Roland McGrath <roland@redhat.com>
* elf/dl-misc.c (_dl_debug_vdprintf): Use INTERNAL_SYSCALL macro for
writev if it's available. Otherwise if [RTLD_PRIVATE_ERRNO] then
take _dl_load_lock around calling __writev.
* sysdeps/unix/sysv/linux/i386/sysdep.h (INTERNAL_SYSCALL): New macro.
(INLINE_SYSCALL): Use that.
* sysdeps/generic/dl-sysdep.h: New file.
* sysdeps/mach/hurd/dl-sysdep.h: New file.
* sysdeps/generic/ldsodefs.h: Include <dl-sysdep.h>.
* include/errno.h [IS_IN_rtld]: Include <dl-sysdep.h> to define ...
[RTLD_PRIVATE_ERRNO]: Use a hidden global variable for errno and
access it directly.
* elf/dl-minimal.c (__errno_location): Removed.
* sysdeps/unix/i386/sysdep.S (__syscall_errno) [RTLD_PRIVATE_ERRNO]:
Use GOTOFF access for errno.
* sysdeps/unix/sysv/linux/i386/sysdep.h
[RTLD_PRIVATE_ERRNO] (SYSCALL_ERROR_HANDLER): Likewise.
* sysdeps/unix/x86_64/sysdep.S (__syscall_errno) [RTLD_PRIVATE_ERRNO]:
Use PC-relative access for errno.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h
[RTLD_PRIVATE_ERRNO] (SYSCALL_ERROR_HANDLER): Likewise.
* include/tls.h: New file.
(USE___THREAD): New macro.
Define to 1 under [USE_TLS && HAVE___THREAD] and only when compiling
libc or libpthread.
* sysdeps/unix/sysv/linux/i386/sysdep.h [USE___THREAD]: Conditional
changed from [USE_TLS && HAVE___THREAD].
* sysdeps/unix/sysv/linux/x86_64/sysdep.h: Likewise.
* sysdeps/unix/i386/sysdep.S: Likewise.
* sysdeps/unix/x86_64/sysdep.S: Likewise.
* include/errno.h: Likewise.
* include/netdb.h: Likewise.
* include/resolv.h: Likewise.
* sysdeps/generic/errno.c: New file.
* csu/Makefile (aux): New variable, list errno.
* sysdeps/unix/sysv/linux/i386/sysdep.S (errno, _errno): Remove defns.
* sysdeps/unix/sysv/linux/m68k/sysdep.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/sysdep.S: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.S: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.S: Likewise.
* sysdeps/unix/sysv/linux/arm/sysdep.S: Likewise.
* sysdeps/unix/sysv/linux/cris/sysdep.S: Likewise.
* sysdeps/unix/sysv/linux/hppa/sysdep.c: Likewise.
* sysdeps/unix/sysv/linux/ia64/sysdep.S: Likewise.
* sysdeps/unix/sysv/linux/powerpc/sysdep.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sysdep.S: Likewise.
* sysdeps/unix/sysv/linux/sh/sysdep.S: Likewise.
* sysdeps/unix/alpha/sysdep.S: Likewise.
* sysdeps/generic/start.c: Likewise.
* sysdeps/unix/start.c: Likewise.
* sysdeps/unix/arm/start.c: Likewise.
* sysdeps/unix/bsd/ultrix4/mips/start.S: Likewise.
* sysdeps/unix/sparc/start.c: Likewise.
* sysdeps/unix/sysv/irix4/start.c: Likewise.
* sysdeps/unix/sysv/linux/mips/sysdep.S: File removed.
* manual/search.texi (Tree Search Function, Hash Search Function):
Mention search.h clearly.
2002-10-05 Roland McGrath <roland@redhat.com>
* elf/dl-fxstat64.c: File removed.
* elf/dl-xstat64.c: File removed.
* elf/Makefile (rtld-routines): Remove them.
* sysdeps/unix/sysv/linux/xstat64.c: Remove RTLD_STAT64 conditionals.
Instead, use strong_alias instead of versioned_symbol in the
!SHLIB_COMPAT case.
* sysdeps/unix/sysv/linux/fxstat64.c: Likewise.
* sysdeps/unix/sysv/linux/lxstat64.c: Likewise.
* include/shlib-compat.h
(SHLIB_COMPAT): Require that IS_IN_##lib be defined nonzero.
[! NOT_IN_libc] (IS_IN_libc): Define it.
* cppflags-iterator.mk (CPPFLAGS-$(cpp-src)): Use -Dx=1 not just -Dx.
* elf/Makefile (CPPFLAGS-.os): Likewise.
* sunrpc/rpc_main.c (main): Don't declare with noreturn attribute.
Return the status instead of calling exit.
* Makeconfig (CFLAGS): Prepend -std=gnu99.
* Makerules (+make-deps): Use $(CFLAGS) only for .c sources.
Remove superfluous rm command, whose @ plus make bugs hid
all these commands from the make output.
* include/stubs-prologue.h: New file. Give #error under #ifdef _LIBC.
* Makefile ($(inst_includedir)/gnu/stubs.h): Depend on it.
Use that file's contents instead of literal echo's for the prologue.
* include/features.h: Include <gnu/stubs.h> unconditionally.
* include/gnu/stubs.h: New file.
2002-09-30 Roland McGrath <roland@redhat.com>
* elf/rtld-Rules: New file.
* elf/Makefile ($(objpfx)librtld.map, $(objpfx)librtld.mk,
$(objpfx)rtld-libc.a): New targets.
(generated): Add them.
(reloc-link): Remove -o $@ from the variable.
($(objpfx)dl-allobjs.os): Add -o $@ after $(reloc-link).
(distribute): Add rtld-Rules.
(CPPFLAGS-.os): Define this instead of CFLAGS-.os.
* Makerules ($(+sysdir_pfx)sysd-rules): Emit rules for rtld-% targets.
(common-mostlyclean, common-clean): Clean up rtld-* files.
* sysdeps/unix/make-syscalls.sh: Add rtld-*.os target name to rules.
2002-10-11 10:52:20 +00:00
|
|
|
# include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
|
|
|
|
#endif
|
|
|
|
|
2001-09-19 10:37:31 +00:00
|
|
|
/* For Linux we can use the system call table in the header file
|
|
|
|
/usr/include/asm/unistd.h
|
|
|
|
of the kernel. But these symbols do not follow the SYS_* syntax
|
|
|
|
so we have to redefine the `SYS_ify' macro here. */
|
|
|
|
#undef SYS_ify
|
|
|
|
#define SYS_ify(syscall_name) __NR_##syscall_name
|
|
|
|
|
2002-09-28 04:15:00 +00:00
|
|
|
/* This is a kludge to make syscalls.list find these under the names
|
|
|
|
pread and pwrite, since some kernel headers define those names
|
|
|
|
and some define the *64 names for the same system calls. */
|
|
|
|
#if !defined __NR_pread && defined __NR_pread64
|
|
|
|
# define __NR_pread __NR_pread64
|
|
|
|
#endif
|
|
|
|
#if !defined __NR_pwrite && defined __NR_pwrite64
|
|
|
|
# define __NR_pwrite __NR_pwrite64
|
|
|
|
#endif
|
|
|
|
|
2003-05-05 08:45:16 +00:00
|
|
|
/* This is to help the old kernel headers where __NR_semtimedop is not
|
|
|
|
available. */
|
|
|
|
#ifndef __NR_semtimedop
|
|
|
|
# define __NR_semtimedop 220
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2001-09-19 10:37:31 +00:00
|
|
|
#ifdef __ASSEMBLER__
|
|
|
|
|
|
|
|
/* Linux uses a negative return value to indicate syscall errors,
|
|
|
|
unlike most Unices, which use the condition codes' carry flag.
|
|
|
|
|
|
|
|
Since version 2.1 the return value of a system call might be
|
|
|
|
negative even if the call succeeded. E.g., the `lseek' system call
|
|
|
|
might return a large offset. Therefore we must not anymore test
|
|
|
|
for < 0, but test for a real error by making sure the value in %eax
|
|
|
|
is a real error number. Linus said he will make sure the no syscall
|
|
|
|
returns a value in -1 .. -4095 as a valid result so we can savely
|
|
|
|
test with -4095. */
|
|
|
|
|
|
|
|
/* We don't want the label for the error handle to be global when we define
|
|
|
|
it here. */
|
2007-08-12 19:03:54 +00:00
|
|
|
# ifdef PIC
|
|
|
|
# define SYSCALL_ERROR_LABEL 0f
|
|
|
|
# else
|
|
|
|
# define SYSCALL_ERROR_LABEL syscall_error
|
|
|
|
# endif
|
2001-09-19 10:37:31 +00:00
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef PSEUDO
|
|
|
|
# define PSEUDO(name, syscall_name, args) \
|
2001-09-19 10:37:31 +00:00
|
|
|
.text; \
|
|
|
|
ENTRY (name) \
|
* locale/programs/ld-ctype.c (ctype_read): When given a repertoire
name of "", store a null pointer instead.
* configure.in (elf): Set to yes for freebsd*, netbsd*.
* configure: Regenerated.
* locale/xlocale.c [! (USE_TLS && HAVE___THREAD)] (__libc_tsd_LOCALE):
Initialize this instead of __libc_tsd_LOCALE_data.
* sysdeps/unix/grantpt.c (pts_name): Convert ENOTTY return from
ptsname_r to EINVAL.
* sysdeps/generic/ptsname.c (__ptsname_r): Return ENOSYS instead of 0.
* rt/Makefile: Revert last change, it was inappropriate to presume aio
implementations depend on pthreads.
* rt/tst-aio.c (do_test): Exit happy if first failure is ENOSYS.
* rt/tst-aio64.c (do_test): Likewise.
* rt/tst-aio2.c (do_test): Likewise.
* rt/tst-aio3.c (do_test): Likewise.
* rt/tst-aio4.c (do_test): Likewise.
* rt/tst-aio5.c (do_test): Likewise.
* rt/tst-aio6.c (do_test): Likewise.
* rt/tst-aio7.c (do_test): Likewise.
* sysdeps/generic/bits/libc-lock.h (__libc_setspecific): Use a cast to
void so as to avoid compiler warnings.
* libio/oldstdfiles.c [! _IO_MTSAFE_IO] (DEF_STDFILE): Don't define
_IO_wide_data_FD, which is never used here.
* libio/iofread.c
[! _IO_MTSAFE_IO] (fread_unlocked): Add libc_hidden_ver defn.
* libio/iofputs.c [! _IO_MTSAFE_IO] (fputs_unlocked): Likewise.
* libio/iofgets.c [! _IO_MTSAFE_IO] (fgets_unlocked): Likewise.
* include/resolv.h [! _LIBC_REENTRANT] (_res): #undef it before decl.
* include/netdb.h [! _LIBC_REENTRANT] (h_errno): Declare normal extern.
* misc/syslog.c (openlog): Conditionalize locking on [_LIBC_REENTRANT].
(closelog): Likewise.
2002-07-06 Bruno Haible <bruno@clisp.org>
* sysdeps/alpha/fpu/fpu_control.h: Comment fix.
* sysdeps/unix/sysv/linux/alpha/pipe.S: Moved to ...
* sysdeps/unix/alpha/pipe.S: ... here.
* sysdeps/unix/bsd/osf/alpha/pipe.S: File removed.
* sysdeps/unix/i386/brk.S: Rename local label to '.Lhere' in ELF.
* sysdeps/unix/i386/brk.S: Add PSEUDO_END invocation.
* sysdeps/unix/i386/fork.S: Likewise.
* sysdeps/unix/i386/pipe.S: Likewise.
* sysdeps/unix/i386/wait.S: Likewise.
* sysdeps/unix/fork.S: Fix PSEUDO_END argument.
* sysdeps/unix/arm/fork.S: Likewise.
* sysdeps/unix/sysv/linux/arm/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/hppa/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/i386/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/sh/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (PSEUDO): Swap DO_CALL
arguments.
(DO_CALL): Swap argument order.
* sysdeps/i386/sysdep.h (PSEUDO): Fix syntax error.
(L): Define right for ELF.
* sysdeps/unix/sysv/linux/i386/sysdep.h (L): Remove definition.
Now defined in sysdeps/i386/sysdep.h.
* sysdeps/posix/readv.c: Ansify function definition.
* sysdeps/posix/writev.c: Likewise.
* stdio-common/tst-fseek.c (main): Don't assume that off_t and size_t
have the same size. Avoid direct cast from size_t to off_t.
* login/tst-utmp.c (simulate_login): Don't leave garbage after the
nul byte in entry[n].ut_user.
(simulate_logout): Likewise.
* login/programs/utmpdump.c (print_entry): Test _HAVE_UT_TYPE,
_HAVE_UT_PID, _HAVE_UT_ID, _HAVE_UT_HOST, instead of assuming the
existence of corresponding members of 'struct utmp'.
* login/tst-utmp.c: Trivialize the test if testing 'struct utmp' and
!_HAVE_UT_TYPE.
* sysdeps/unix/opendir.c (__opendir): If st_blksize is 0 or too small,
allocate a buffer of at least BUFSIZ bytes, not just of
sizeof (struct dirent).
* sysdeps/generic/glob.c: Include <limits.h>.
(NAME_MAX): Define a fallback.
(glob_in_dir): Allocate enough room for a 'struct dirent64' on the
stack.
* posix/tst-dir.c: Include <stddef.h>, for offsetof.
(main): Allocate enough room for a 'struct dirent64' on the stack.
* posix/tst-gnuglob.c (my_DIR): Allocate enough room for a
'struct dirent'.
* sysdeps/unix/sysv/linux/init-first.c: Don't include
kernel-features.h.
* inet/htontest.c: Include <sys/types.h>.
* sysdeps/generic/sys/sysinfo.h: Surround with __{BEGIN,END}_DECLS.
* include/sys/sysctl.h: Comment fix.
* elf/rtld.c (_rtld_global) [! _LIBC_REENTRANT]: Don't initialize
_dl_load_lock.
* libio/fileno.c (fileno_unlocked): Define regardless of _IO_MTSAFE_IO.
* sysdeps/unix/bsd/bsd4.4/syscalls.list (__sigaltstack): New alias.
* sysdeps/unix/inet/syscalls.list (__connect_internal): New alias.
(__getpeername): New alias.
(__getsockname): New alias.
(__socket): New alias.
* sysdeps/unix/common/syscalls.list (getpgid): Remove.
* sysdeps/unix/syscalls.list (__chown_internal): New alias.
(__fcntl_internal): New alias.
(__profil): New alias.
2002-08-26 11:39:12 +00:00
|
|
|
DO_CALL (syscall_name, args); \
|
2001-09-19 10:37:31 +00:00
|
|
|
cmpq $-4095, %rax; \
|
2012-07-16 14:12:47 +00:00
|
|
|
jae SYSCALL_ERROR_LABEL
|
2001-09-19 10:37:31 +00:00
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef PSEUDO_END
|
|
|
|
# define PSEUDO_END(name) \
|
2001-09-19 10:37:31 +00:00
|
|
|
SYSCALL_ERROR_HANDLER \
|
|
|
|
END (name)
|
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef PSEUDO_NOERRNO
|
|
|
|
# define PSEUDO_NOERRNO(name, syscall_name, args) \
|
2003-03-23 19:44:31 +00:00
|
|
|
.text; \
|
|
|
|
ENTRY (name) \
|
|
|
|
DO_CALL (syscall_name, args)
|
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef PSEUDO_END_NOERRNO
|
|
|
|
# define PSEUDO_END_NOERRNO(name) \
|
2003-03-23 19:44:31 +00:00
|
|
|
END (name)
|
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# define ret_NOERRNO ret
|
2003-08-16 08:10:06 +00:00
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef PSEUDO_ERRVAL
|
|
|
|
# define PSEUDO_ERRVAL(name, syscall_name, args) \
|
2003-08-16 06:21:46 +00:00
|
|
|
.text; \
|
|
|
|
ENTRY (name) \
|
|
|
|
DO_CALL (syscall_name, args); \
|
2003-08-16 08:10:06 +00:00
|
|
|
negq %rax
|
2003-08-16 06:21:46 +00:00
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef PSEUDO_END_ERRVAL
|
|
|
|
# define PSEUDO_END_ERRVAL(name) \
|
2003-08-16 06:21:46 +00:00
|
|
|
END (name)
|
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# define ret_ERRVAL ret
|
2003-03-23 19:44:31 +00:00
|
|
|
|
2012-05-21 21:50:21 +00:00
|
|
|
# if defined PIC && defined RTLD_PRIVATE_ERRNO
|
|
|
|
# define SYSCALL_SET_ERRNO \
|
|
|
|
lea rtld_errno(%rip), %RCX_LP; \
|
2012-05-22 12:34:36 +00:00
|
|
|
neg %eax; \
|
|
|
|
movl %eax, (%rcx)
|
2011-09-10 20:50:28 +00:00
|
|
|
# else
|
2014-11-24 09:33:45 +00:00
|
|
|
# if IS_IN (libc)
|
2007-08-12 19:03:54 +00:00
|
|
|
# define SYSCALL_ERROR_ERRNO __libc_errno
|
|
|
|
# else
|
|
|
|
# define SYSCALL_ERROR_ERRNO errno
|
|
|
|
# endif
|
2012-05-21 21:50:21 +00:00
|
|
|
# define SYSCALL_SET_ERRNO \
|
2002-10-16 22:09:55 +00:00
|
|
|
movq SYSCALL_ERROR_ERRNO@GOTTPOFF(%rip), %rcx;\
|
2012-05-22 12:34:36 +00:00
|
|
|
neg %eax; \
|
|
|
|
movl %eax, %fs:(%rcx);
|
2012-05-21 21:50:21 +00:00
|
|
|
# endif
|
|
|
|
|
|
|
|
# ifndef PIC
|
|
|
|
# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
|
|
|
|
# else
|
|
|
|
# define SYSCALL_ERROR_HANDLER \
|
|
|
|
0: \
|
|
|
|
SYSCALL_SET_ERRNO; \
|
|
|
|
or $-1, %RAX_LP; \
|
2012-05-23 18:35:38 +00:00
|
|
|
ret;
|
2007-08-12 19:03:54 +00:00
|
|
|
# endif /* PIC */
|
2001-09-19 10:37:31 +00:00
|
|
|
|
2003-03-04 12:33:28 +00:00
|
|
|
/* The Linux/x86-64 kernel expects the system call parameters in
|
|
|
|
registers according to the following table:
|
2001-09-19 10:37:31 +00:00
|
|
|
|
2003-03-04 12:33:28 +00:00
|
|
|
syscall number rax
|
2001-09-19 10:37:31 +00:00
|
|
|
arg 1 rdi
|
|
|
|
arg 2 rsi
|
|
|
|
arg 3 rdx
|
2003-03-04 12:33:28 +00:00
|
|
|
arg 4 r10
|
2001-09-19 10:37:31 +00:00
|
|
|
arg 5 r8
|
|
|
|
arg 6 r9
|
|
|
|
|
2003-03-04 12:33:28 +00:00
|
|
|
The Linux kernel uses and destroys internally these registers:
|
2001-09-19 10:37:31 +00:00
|
|
|
return address from
|
|
|
|
syscall rcx
|
|
|
|
eflags from syscall r11
|
|
|
|
|
2003-03-04 12:33:28 +00:00
|
|
|
Normal function call, including calls to the system call stub
|
|
|
|
functions in the libc, get the first six parameters passed in
|
|
|
|
registers and the seventh parameter and later on the stack. The
|
|
|
|
register use is as follows:
|
|
|
|
|
|
|
|
system call number in the DO_CALL macro
|
|
|
|
arg 1 rdi
|
|
|
|
arg 2 rsi
|
|
|
|
arg 3 rdx
|
|
|
|
arg 4 rcx
|
|
|
|
arg 5 r8
|
|
|
|
arg 6 r9
|
|
|
|
|
|
|
|
We have to take care that the stack is aligned to 16 bytes. When
|
|
|
|
called the stack is not aligned since the return address has just
|
|
|
|
been pushed.
|
|
|
|
|
2003-03-23 19:44:31 +00:00
|
|
|
|
2003-03-04 12:33:28 +00:00
|
|
|
Syscalls of more than 6 arguments are not supported. */
|
2001-09-19 10:37:31 +00:00
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef DO_CALL
|
|
|
|
# define DO_CALL(syscall_name, args) \
|
2001-09-19 10:37:31 +00:00
|
|
|
DOARGS_##args \
|
2005-03-31 10:02:53 +00:00
|
|
|
movl $SYS_ify (syscall_name), %eax; \
|
2001-09-19 10:37:31 +00:00
|
|
|
syscall;
|
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# define DOARGS_0 /* nothing */
|
|
|
|
# define DOARGS_1 /* nothing */
|
|
|
|
# define DOARGS_2 /* nothing */
|
|
|
|
# define DOARGS_3 /* nothing */
|
|
|
|
# define DOARGS_4 movq %rcx, %r10;
|
|
|
|
# define DOARGS_5 DOARGS_4
|
|
|
|
# define DOARGS_6 DOARGS_5
|
2001-09-19 10:37:31 +00:00
|
|
|
|
|
|
|
#else /* !__ASSEMBLER__ */
|
|
|
|
/* Define a macro which expands inline into the wrapper code for a system
|
|
|
|
call. */
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef INLINE_SYSCALL
|
|
|
|
# define INLINE_SYSCALL(name, nr, args...) \
|
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h: Include
dl-sysdep.h.
(SYSCALL_ERROR_HANDLER): Define RTLD_PRIVATE_ERRNO variant.
(__INTERNAL_SYSCALL_STRING): Define.
* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h: Include
dl-sysdep.h.
(SYSCALL_ERROR_HANDLER): Define RTLD_PRIVATE_ERRNO variant.
(__INTERNAL_SYSCALL_STRING): Define.
* sysdeps/unix/sysv/linux/sparc/sysdep.h (INLINE_SYSCALL): Pass
__SYSCALL_STRING to inline_syscall*.
(INTERNAL_SYSCALL, INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO):
New macros.
(inline_syscall0, inline_syscall1, inline_syscall2, inline_syscall3,
inline_syscall4, inline_syscall5, inline_syscall6): Add string
argument.
2002-10-24 Roland McGrath <roland@redhat.com>
* libio/bug-wfflush.c: New file.
* libio/Makefile (tests): Add bug-wfflush.
2002-10-24 18:49:00 +00:00
|
|
|
({ \
|
2007-12-14 23:38:23 +00:00
|
|
|
unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
|
2014-02-10 13:45:42 +00:00
|
|
|
if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
|
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h: Include
dl-sysdep.h.
(SYSCALL_ERROR_HANDLER): Define RTLD_PRIVATE_ERRNO variant.
(__INTERNAL_SYSCALL_STRING): Define.
* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h: Include
dl-sysdep.h.
(SYSCALL_ERROR_HANDLER): Define RTLD_PRIVATE_ERRNO variant.
(__INTERNAL_SYSCALL_STRING): Define.
* sysdeps/unix/sysv/linux/sparc/sysdep.h (INLINE_SYSCALL): Pass
__SYSCALL_STRING to inline_syscall*.
(INTERNAL_SYSCALL, INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO):
New macros.
(inline_syscall0, inline_syscall1, inline_syscall2, inline_syscall3,
inline_syscall4, inline_syscall5, inline_syscall6): Add string
argument.
2002-10-24 Roland McGrath <roland@redhat.com>
* libio/bug-wfflush.c: New file.
* libio/Makefile (tests): Add bug-wfflush.
2002-10-24 18:49:00 +00:00
|
|
|
{ \
|
2003-01-09 04:19:03 +00:00
|
|
|
__set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
|
2007-12-14 23:38:23 +00:00
|
|
|
resultvar = (unsigned long int) -1; \
|
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h: Include
dl-sysdep.h.
(SYSCALL_ERROR_HANDLER): Define RTLD_PRIVATE_ERRNO variant.
(__INTERNAL_SYSCALL_STRING): Define.
* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h: Include
dl-sysdep.h.
(SYSCALL_ERROR_HANDLER): Define RTLD_PRIVATE_ERRNO variant.
(__INTERNAL_SYSCALL_STRING): Define.
* sysdeps/unix/sysv/linux/sparc/sysdep.h (INLINE_SYSCALL): Pass
__SYSCALL_STRING to inline_syscall*.
(INTERNAL_SYSCALL, INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO):
New macros.
(inline_syscall0, inline_syscall1, inline_syscall2, inline_syscall3,
inline_syscall4, inline_syscall5, inline_syscall6): Add string
argument.
2002-10-24 Roland McGrath <roland@redhat.com>
* libio/bug-wfflush.c: New file.
* libio/Makefile (tests): Add bug-wfflush.
2002-10-24 18:49:00 +00:00
|
|
|
} \
|
2007-12-14 23:38:23 +00:00
|
|
|
(long int) resultvar; })
|
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h: Include
dl-sysdep.h.
(SYSCALL_ERROR_HANDLER): Define RTLD_PRIVATE_ERRNO variant.
(__INTERNAL_SYSCALL_STRING): Define.
* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h: Include
dl-sysdep.h.
(SYSCALL_ERROR_HANDLER): Define RTLD_PRIVATE_ERRNO variant.
(__INTERNAL_SYSCALL_STRING): Define.
* sysdeps/unix/sysv/linux/sparc/sysdep.h (INLINE_SYSCALL): Pass
__SYSCALL_STRING to inline_syscall*.
(INTERNAL_SYSCALL, INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO):
New macros.
(inline_syscall0, inline_syscall1, inline_syscall2, inline_syscall3,
inline_syscall4, inline_syscall5, inline_syscall6): Add string
argument.
2002-10-24 Roland McGrath <roland@redhat.com>
* libio/bug-wfflush.c: New file.
* libio/Makefile (tests): Add bug-wfflush.
2002-10-24 18:49:00 +00:00
|
|
|
|
2012-05-22 19:42:36 +00:00
|
|
|
/* Define a macro with explicit types for arguments, which expands inline
|
|
|
|
into the wrapper code for a system call. It should be used when size
|
|
|
|
of any argument > size of long int. */
|
|
|
|
# undef INLINE_SYSCALL_TYPES
|
|
|
|
# define INLINE_SYSCALL_TYPES(name, nr, args...) \
|
|
|
|
({ \
|
|
|
|
unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \
|
2014-02-10 13:45:42 +00:00
|
|
|
if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
|
2012-05-22 19:42:36 +00:00
|
|
|
{ \
|
|
|
|
__set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
|
|
|
|
resultvar = (unsigned long int) -1; \
|
|
|
|
} \
|
|
|
|
(long int) resultvar; })
|
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef INTERNAL_SYSCALL_DECL
|
|
|
|
# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
|
2003-01-09 04:19:03 +00:00
|
|
|
|
2015-12-16 13:19:57 +00:00
|
|
|
/* Registers clobbered by syscall. */
|
|
|
|
# define REGISTERS_CLOBBERED_BY_SYSCALL "cc", "r11", "cx"
|
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
|
2001-09-19 10:37:31 +00:00
|
|
|
({ \
|
2007-12-14 23:38:23 +00:00
|
|
|
unsigned long int resultvar; \
|
2001-09-19 10:37:31 +00:00
|
|
|
LOAD_ARGS_##nr (args) \
|
Update.
2004-04-09 Andreas Schwab <schwab@suse.de>
* sysdeps/unix/sysv/linux/ia64/sysdep.h (DO_INLINE_SYSCALL): Move
LOAD_ARGS_##nr up front and add LOAD_REGS_##nr.
(LOAD_ARGS_0, LOAD_ARGS_1, LOAD_ARGS_2, LOAD_ARGS_3, LOAD_ARGS_4)
(LOAD_ARGS_5, LOAD_ARGS_6): Load argument values into temporary
variables.
(LOAD_REGS_0, LOAD_REGS_1, LOAD_REGS_2, LOAD_REGS_3, LOAD_REGS_4)
(LOAD_REGS_5, LOAD_REGS_6): New macros to actually load the
syscall argument registers.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (INTERNAL_SYSCALL): Add
LOAD_REGS_##nr.
(LOAD_ARGS_0, LOAD_ARGS_1, LOAD_ARGS_2, LOAD_ARGS_3, LOAD_ARGS_4)
(LOAD_ARGS_5, LOAD_ARGS_6): Load argument values into temporary
variables.
(LOAD_REGS_0, LOAD_REGS_1, LOAD_REGS_2, LOAD_REGS_3, LOAD_REGS_4)
(LOAD_REGS_5, LOAD_REGS_6): New macros to actually load the
syscall argument registers.
2004-04-13 00:27:59 +00:00
|
|
|
LOAD_REGS_##nr \
|
2001-09-19 10:37:31 +00:00
|
|
|
asm volatile ( \
|
|
|
|
"syscall\n\t" \
|
|
|
|
: "=a" (resultvar) \
|
2015-12-16 13:19:57 +00:00
|
|
|
: "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
|
2007-12-14 23:38:23 +00:00
|
|
|
(long int) resultvar; })
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef INTERNAL_SYSCALL
|
|
|
|
# define INTERNAL_SYSCALL(name, err, nr, args...) \
|
2004-09-20 00:16:11 +00:00
|
|
|
INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
|
2001-09-19 10:37:31 +00:00
|
|
|
|
2012-05-22 19:42:36 +00:00
|
|
|
# define INTERNAL_SYSCALL_NCS_TYPES(name, err, nr, args...) \
|
|
|
|
({ \
|
|
|
|
unsigned long int resultvar; \
|
|
|
|
LOAD_ARGS_TYPES_##nr (args) \
|
|
|
|
LOAD_REGS_TYPES_##nr (args) \
|
|
|
|
asm volatile ( \
|
|
|
|
"syscall\n\t" \
|
|
|
|
: "=a" (resultvar) \
|
2015-12-16 13:19:57 +00:00
|
|
|
: "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
|
2012-05-22 19:42:36 +00:00
|
|
|
(long int) resultvar; })
|
|
|
|
# undef INTERNAL_SYSCALL_TYPES
|
|
|
|
# define INTERNAL_SYSCALL_TYPES(name, err, nr, args...) \
|
|
|
|
INTERNAL_SYSCALL_NCS_TYPES (__NR_##name, err, nr, ##args)
|
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef INTERNAL_SYSCALL_ERROR_P
|
|
|
|
# define INTERNAL_SYSCALL_ERROR_P(val, err) \
|
2007-12-14 23:38:23 +00:00
|
|
|
((unsigned long int) (long int) (val) >= -4095L)
|
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (INTERNAL_SYSCALL,
INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO): New macros.
(INLINE_SYSCALL): Use that.
* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h: Include
dl-sysdep.h.
(SYSCALL_ERROR_HANDLER): Define RTLD_PRIVATE_ERRNO variant.
(__INTERNAL_SYSCALL_STRING): Define.
* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h: Include
dl-sysdep.h.
(SYSCALL_ERROR_HANDLER): Define RTLD_PRIVATE_ERRNO variant.
(__INTERNAL_SYSCALL_STRING): Define.
* sysdeps/unix/sysv/linux/sparc/sysdep.h (INLINE_SYSCALL): Pass
__SYSCALL_STRING to inline_syscall*.
(INTERNAL_SYSCALL, INTERNAL_SYSCALL_ERROR_P, INTERNAL_SYSCALL_ERRNO):
New macros.
(inline_syscall0, inline_syscall1, inline_syscall2, inline_syscall3,
inline_syscall4, inline_syscall5, inline_syscall6): Add string
argument.
2002-10-24 Roland McGrath <roland@redhat.com>
* libio/bug-wfflush.c: New file.
* libio/Makefile (tests): Add bug-wfflush.
2002-10-24 18:49:00 +00:00
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# undef INTERNAL_SYSCALL_ERRNO
|
|
|
|
# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
|
|
|
|
|
2015-04-17 17:28:03 +00:00
|
|
|
/* List of system calls which are supported as vsyscalls. */
|
|
|
|
# define HAVE_CLOCK_GETTIME_VSYSCALL 1
|
|
|
|
# define HAVE_GETTIMEOFDAY_VSYSCALL 1
|
2015-04-22 17:21:39 +00:00
|
|
|
# define HAVE_GETCPU_VSYSCALL 1
|
2015-04-17 17:28:03 +00:00
|
|
|
|
2007-08-12 19:03:54 +00:00
|
|
|
# define LOAD_ARGS_0()
|
|
|
|
# define LOAD_REGS_0
|
|
|
|
# define ASM_ARGS_0
|
2001-09-19 10:37:31 +00:00
|
|
|
|
2012-05-22 19:42:36 +00:00
|
|
|
# define LOAD_ARGS_TYPES_1(t1, a1) \
|
|
|
|
t1 __arg1 = (t1) (a1); \
|
2001-09-19 10:37:31 +00:00
|
|
|
LOAD_ARGS_0 ()
|
2012-05-22 19:42:36 +00:00
|
|
|
# define LOAD_REGS_TYPES_1(t1, a1) \
|
|
|
|
register t1 _a1 asm ("rdi") = __arg1; \
|
Update.
2004-04-09 Andreas Schwab <schwab@suse.de>
* sysdeps/unix/sysv/linux/ia64/sysdep.h (DO_INLINE_SYSCALL): Move
LOAD_ARGS_##nr up front and add LOAD_REGS_##nr.
(LOAD_ARGS_0, LOAD_ARGS_1, LOAD_ARGS_2, LOAD_ARGS_3, LOAD_ARGS_4)
(LOAD_ARGS_5, LOAD_ARGS_6): Load argument values into temporary
variables.
(LOAD_REGS_0, LOAD_REGS_1, LOAD_REGS_2, LOAD_REGS_3, LOAD_REGS_4)
(LOAD_REGS_5, LOAD_REGS_6): New macros to actually load the
syscall argument registers.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (INTERNAL_SYSCALL): Add
LOAD_REGS_##nr.
(LOAD_ARGS_0, LOAD_ARGS_1, LOAD_ARGS_2, LOAD_ARGS_3, LOAD_ARGS_4)
(LOAD_ARGS_5, LOAD_ARGS_6): Load argument values into temporary
variables.
(LOAD_REGS_0, LOAD_REGS_1, LOAD_REGS_2, LOAD_REGS_3, LOAD_REGS_4)
(LOAD_REGS_5, LOAD_REGS_6): New macros to actually load the
syscall argument registers.
2004-04-13 00:27:59 +00:00
|
|
|
LOAD_REGS_0
|
2007-08-12 19:03:54 +00:00
|
|
|
# define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1)
|
2012-05-22 19:42:36 +00:00
|
|
|
# define LOAD_ARGS_1(a1) \
|
|
|
|
LOAD_ARGS_TYPES_1 (long int, a1)
|
|
|
|
# define LOAD_REGS_1 \
|
|
|
|
LOAD_REGS_TYPES_1 (long int, a1)
|
|
|
|
|
|
|
|
# define LOAD_ARGS_TYPES_2(t1, a1, t2, a2) \
|
|
|
|
t2 __arg2 = (t2) (a2); \
|
|
|
|
LOAD_ARGS_TYPES_1 (t1, a1)
|
|
|
|
# define LOAD_REGS_TYPES_2(t1, a1, t2, a2) \
|
|
|
|
register t2 _a2 asm ("rsi") = __arg2; \
|
|
|
|
LOAD_REGS_TYPES_1(t1, a1)
|
2007-08-12 19:03:54 +00:00
|
|
|
# define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2)
|
2012-05-22 19:42:36 +00:00
|
|
|
# define LOAD_ARGS_2(a1, a2) \
|
|
|
|
LOAD_ARGS_TYPES_2 (long int, a1, long int, a2)
|
|
|
|
# define LOAD_REGS_2 \
|
|
|
|
LOAD_REGS_TYPES_2 (long int, a1, long int, a2)
|
|
|
|
|
|
|
|
# define LOAD_ARGS_TYPES_3(t1, a1, t2, a2, t3, a3) \
|
|
|
|
t3 __arg3 = (t3) (a3); \
|
|
|
|
LOAD_ARGS_TYPES_2 (t1, a1, t2, a2)
|
|
|
|
# define LOAD_REGS_TYPES_3(t1, a1, t2, a2, t3, a3) \
|
|
|
|
register t3 _a3 asm ("rdx") = __arg3; \
|
|
|
|
LOAD_REGS_TYPES_2(t1, a1, t2, a2)
|
2007-08-12 19:03:54 +00:00
|
|
|
# define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3)
|
2012-05-22 19:42:36 +00:00
|
|
|
# define LOAD_ARGS_3(a1, a2, a3) \
|
|
|
|
LOAD_ARGS_TYPES_3 (long int, a1, long int, a2, long int, a3)
|
|
|
|
# define LOAD_REGS_3 \
|
|
|
|
LOAD_REGS_TYPES_3 (long int, a1, long int, a2, long int, a3)
|
|
|
|
|
|
|
|
# define LOAD_ARGS_TYPES_4(t1, a1, t2, a2, t3, a3, t4, a4) \
|
|
|
|
t4 __arg4 = (t4) (a4); \
|
|
|
|
LOAD_ARGS_TYPES_3 (t1, a1, t2, a2, t3, a3)
|
|
|
|
# define LOAD_REGS_TYPES_4(t1, a1, t2, a2, t3, a3, t4, a4) \
|
|
|
|
register t4 _a4 asm ("r10") = __arg4; \
|
|
|
|
LOAD_REGS_TYPES_3(t1, a2, t2, a2, t3, a3)
|
2007-08-12 19:03:54 +00:00
|
|
|
# define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4)
|
2012-05-22 19:42:36 +00:00
|
|
|
# define LOAD_ARGS_4(a1, a2, a3, a4) \
|
|
|
|
LOAD_ARGS_TYPES_4 (long int, a1, long int, a2, long int, a3, \
|
|
|
|
long int, a4)
|
|
|
|
# define LOAD_REGS_4 \
|
|
|
|
LOAD_REGS_TYPES_4 (long int, a1, long int, a2, long int, a3, \
|
|
|
|
long int, a4)
|
|
|
|
|
|
|
|
# define LOAD_ARGS_TYPES_5(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5) \
|
|
|
|
t5 __arg5 = (t5) (a5); \
|
|
|
|
LOAD_ARGS_TYPES_4 (t1, a1, t2, a2, t3, a3, t4, a4)
|
|
|
|
# define LOAD_REGS_TYPES_5(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5) \
|
|
|
|
register t5 _a5 asm ("r8") = __arg5; \
|
|
|
|
LOAD_REGS_TYPES_4 (t1, a1, t2, a2, t3, a3, t4, a4)
|
2007-08-12 19:03:54 +00:00
|
|
|
# define ASM_ARGS_5 ASM_ARGS_4, "r" (_a5)
|
2012-05-22 19:42:36 +00:00
|
|
|
# define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
|
|
|
|
LOAD_ARGS_TYPES_5 (long int, a1, long int, a2, long int, a3, \
|
|
|
|
long int, a4, long int, a5)
|
|
|
|
# define LOAD_REGS_5 \
|
|
|
|
LOAD_REGS_TYPES_5 (long int, a1, long int, a2, long int, a3, \
|
|
|
|
long int, a4, long int, a5)
|
|
|
|
|
|
|
|
# define LOAD_ARGS_TYPES_6(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5, t6, a6) \
|
|
|
|
t6 __arg6 = (t6) (a6); \
|
|
|
|
LOAD_ARGS_TYPES_5 (t1, a1, t2, a2, t3, a3, t4, a4, t5, a5)
|
|
|
|
# define LOAD_REGS_TYPES_6(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5, t6, a6) \
|
|
|
|
register t6 _a6 asm ("r9") = __arg6; \
|
|
|
|
LOAD_REGS_TYPES_5 (t1, a1, t2, a2, t3, a3, t4, a4, t5, a5)
|
2007-08-12 19:03:54 +00:00
|
|
|
# define ASM_ARGS_6 ASM_ARGS_5, "r" (_a6)
|
2012-05-22 19:42:36 +00:00
|
|
|
# define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
|
|
|
|
LOAD_ARGS_TYPES_6 (long int, a1, long int, a2, long int, a3, \
|
|
|
|
long int, a4, long int, a5, long int, a6)
|
|
|
|
# define LOAD_REGS_6 \
|
|
|
|
LOAD_REGS_TYPES_6 (long int, a1, long int, a2, long int, a3, \
|
|
|
|
long int, a4, long int, a5, long int, a6)
|
2001-09-19 10:37:31 +00:00
|
|
|
|
|
|
|
#endif /* __ASSEMBLER__ */
|
|
|
|
|
2005-12-18 06:58:22 +00:00
|
|
|
|
|
|
|
/* Pointer mangling support. */
|
2014-11-20 15:39:43 +00:00
|
|
|
#if IS_IN (rtld)
|
2005-12-18 06:58:22 +00:00
|
|
|
/* We cannot use the thread descriptor because in ld.so we use setjmp
|
|
|
|
earlier than the descriptor is initialized. */
|
2005-12-18 16:59:55 +00:00
|
|
|
# ifdef __ASSEMBLER__
|
2012-05-14 22:16:27 +00:00
|
|
|
# define PTR_MANGLE(reg) xor __pointer_chk_guard_local(%rip), reg; \
|
|
|
|
rol $2*LP_SIZE+1, reg
|
|
|
|
# define PTR_DEMANGLE(reg) ror $2*LP_SIZE+1, reg; \
|
|
|
|
xor __pointer_chk_guard_local(%rip), reg
|
2005-12-18 16:59:55 +00:00
|
|
|
# else
|
2012-05-14 22:16:27 +00:00
|
|
|
# define PTR_MANGLE(reg) asm ("xor __pointer_chk_guard_local(%%rip), %0\n" \
|
|
|
|
"rol $2*" LP_SIZE "+1, %0" \
|
2007-02-01 16:14:15 +00:00
|
|
|
: "=r" (reg) : "0" (reg))
|
2012-05-14 22:16:27 +00:00
|
|
|
# define PTR_DEMANGLE(reg) asm ("ror $2*" LP_SIZE "+1, %0\n" \
|
|
|
|
"xor __pointer_chk_guard_local(%%rip), %0" \
|
2005-12-18 21:09:20 +00:00
|
|
|
: "=r" (reg) : "0" (reg))
|
2005-12-18 16:59:55 +00:00
|
|
|
# endif
|
2005-12-18 06:58:22 +00:00
|
|
|
#else
|
2005-12-18 16:59:55 +00:00
|
|
|
# ifdef __ASSEMBLER__
|
2012-05-14 22:16:27 +00:00
|
|
|
# define PTR_MANGLE(reg) xor %fs:POINTER_GUARD, reg; \
|
|
|
|
rol $2*LP_SIZE+1, reg
|
|
|
|
# define PTR_DEMANGLE(reg) ror $2*LP_SIZE+1, reg; \
|
|
|
|
xor %fs:POINTER_GUARD, reg
|
2005-12-18 16:59:55 +00:00
|
|
|
# else
|
2012-05-14 22:16:27 +00:00
|
|
|
# define PTR_MANGLE(var) asm ("xor %%fs:%c2, %0\n" \
|
|
|
|
"rol $2*" LP_SIZE "+1, %0" \
|
2007-02-01 16:14:15 +00:00
|
|
|
: "=r" (var) \
|
|
|
|
: "0" (var), \
|
|
|
|
"i" (offsetof (tcbhead_t, \
|
|
|
|
pointer_guard)))
|
2012-05-14 22:16:27 +00:00
|
|
|
# define PTR_DEMANGLE(var) asm ("ror $2*" LP_SIZE "+1, %0\n" \
|
|
|
|
"xor %%fs:%c2, %0" \
|
2005-12-18 16:59:55 +00:00
|
|
|
: "=r" (var) \
|
|
|
|
: "0" (var), \
|
|
|
|
"i" (offsetof (tcbhead_t, \
|
|
|
|
pointer_guard)))
|
|
|
|
# endif
|
2005-12-18 06:58:22 +00:00
|
|
|
#endif
|
|
|
|
|
2016-07-11 22:32:10 +00:00
|
|
|
/* How to pass the off{64}_t argument on p{readv,writev}{64}. */
|
|
|
|
#undef LO_HI_LONG
|
x86-64: Update LO_HI_LONG for p{readv,writev}{64}v2
The kernel interface for p{readv,writev}{64}v is
(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
unsigned long pos_l, unsigned long pos_h)
Except for targets which define __ARCH_WANT_COMPAT_SYS_PREADV64 and
__ARCH_WANT_COMPAT_SYS_PWRITEV64,
(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
off64_t pos)
is used for p{readv,writev}{64}v. X32 is the only such target. The
LO_HI_LONG macro is used to pass offset to the pos_l and pos_h pair.
Since pos_h is ignored when size of offset == sizeof of pos_l, x86-64
has
#define LO_HI_LONG(val) (val)
But the kernel interface for p{readv,writev}{64}v2 is
(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
unsigned long pos_l, unsigned long pos_h, int flags)
Except for targets which define __ARCH_WANT_COMPAT_SYS_PREADV64V2 and
__ARCH_WANT_COMPAT_SYS_PWRITEV64V2,
(unsigned long fd, {const }struct iovec *iov, unsigned long vlen,
off64_t pos, int flags)
is used for p{readv,writev}{64}v2. X32 is the only such target. Update
x86-64 LO_HI_LONG to pass 0 as the high part of the offset argument for
p{readv,writev}{64}v2 and define a different LO_HI_LONG for x32 to only
pass one argument for offset.
Tested on x32 and x86-64.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h (LO_HI_LONG): Pass
0 as the high part of offset.
* sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h (LO_HI_LONG): New.
2017-06-05 14:21:44 +00:00
|
|
|
#define LO_HI_LONG(val) (val), 0
|
2016-07-11 22:32:10 +00:00
|
|
|
|
2001-09-19 10:37:31 +00:00
|
|
|
#endif /* linux/x86_64/sysdep.h */
|