From 3d8eb8099425ae4f474e97082e04784c2984ec48 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Fri, 23 Mar 2018 16:17:26 -0400 Subject: WIP no duplicate function definitions in pthread --- debug/pread64_chk.c | 2 +- include/sys/socket.h | 4 +- include/unistd.h | 4 +- io/Versions | 10 ++ io/copy_file_range-compat.c | 6 +- misc/Versions | 1 + misc/fsync.c | 6 +- misc/msync.c | 5 +- nptl/Makefile | 53 +------ nptl/pt-fork.c | 49 ------ nptl/pt-longjmp.c | 49 ------ nptl/pt-system.c | 45 ------ posix/Versions | 8 +- posix/nanosleep.c | 1 + posix/waitpid.c | 1 + signal/Versions | 4 + socket/Versions | 4 + socket/accept.c | 6 +- sysdeps/generic/pt-compat-stubs.S | 172 +++++++++++++++++++++- sysdeps/mach/hurd/accept.c | 7 +- sysdeps/mach/hurd/fsync.c | 3 +- sysdeps/mach/hurd/pread.c | 2 +- sysdeps/mach/hurd/pwrite.c | 2 +- sysdeps/mach/msync.c | 3 +- sysdeps/posix/posix_fallocate64.c | 4 +- sysdeps/unix/bsd/waitpid.c | 1 + sysdeps/unix/sysv/linux/fsync.c | 3 +- sysdeps/unix/sysv/linux/hppa/localplt.data | 1 - sysdeps/unix/sysv/linux/msync.c | 3 +- sysdeps/unix/sysv/linux/nanosleep.c | 1 + sysdeps/unix/sysv/linux/not-cancel.h | 2 +- sysdeps/unix/sysv/linux/open64.c | 1 + sysdeps/unix/sysv/linux/powerpc/pt-compat-stubs.S | 32 ++++ sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c | 61 -------- sysdeps/unix/sysv/linux/s390/pt-compat-stubs.S | 28 ++++ sysdeps/unix/sysv/linux/s390/pt-longjmp.c | 33 ----- sysdeps/unix/sysv/linux/waitpid.c | 1 + termios/Versions | 4 + 38 files changed, 303 insertions(+), 319 deletions(-) delete mode 100644 nptl/pt-fork.c delete mode 100644 nptl/pt-longjmp.c delete mode 100644 nptl/pt-system.c create mode 100644 sysdeps/unix/sysv/linux/powerpc/pt-compat-stubs.S delete mode 100644 sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c create mode 100644 sysdeps/unix/sysv/linux/s390/pt-compat-stubs.S delete mode 100644 sysdeps/unix/sysv/linux/s390/pt-longjmp.c diff --git a/debug/pread64_chk.c b/debug/pread64_chk.c index cc22b51f49..654e126c9c 100644 --- a/debug/pread64_chk.c +++ b/debug/pread64_chk.c @@ -25,5 +25,5 @@ __pread64_chk (int fd, void *buf, size_t nbytes, off64_t offset, size_t buflen) if (nbytes > buflen) __chk_fail (); - return __libc_pread64 (fd, buf, nbytes, offset); + return __pread64 (fd, buf, nbytes, offset); } diff --git a/include/sys/socket.h b/include/sys/socket.h index 26db0e0d77..6e6420343f 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -139,11 +139,11 @@ extern int __listen (int __fd, int __n) attribute_hidden; new socket's descriptor, or -1 for errors. */ extern int __libc_accept (int __fd, __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len) - __THROW attribute_hidden; + __THROW; libc_hidden_proto (accept) extern int __libc_accept4 (int __fd, __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len, int __flags) - __THROW attribute_hidden; + __THROW; /* Return the length of a `sockaddr' structure. */ #ifdef _HAVE_SA_LEN diff --git a/include/unistd.h b/include/unistd.h index 0f91b8babc..09860c63bc 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -43,7 +43,7 @@ extern ssize_t __pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset); libc_hidden_proto (__pread64); extern ssize_t __libc_pread64 (int __fd, void *__buf, size_t __nbytes, - __off64_t __offset) attribute_hidden; + __off64_t __offset); extern ssize_t __pwrite (int __fd, const void *__buf, size_t __n, __off_t __offset); libc_hidden_proto (__pwrite) @@ -53,7 +53,7 @@ extern ssize_t __pwrite64 (int __fd, const void *__buf, size_t __n, __off64_t __offset); libc_hidden_proto (__pwrite64) extern ssize_t __libc_pwrite64 (int __fd, const void *__buf, size_t __n, - __off64_t __offset) attribute_hidden; + __off64_t __offset); extern ssize_t __libc_read (int __fd, void *__buf, size_t __n); libc_hidden_proto (__libc_read) libc_hidden_proto (read) diff --git a/io/Versions b/io/Versions index 98898cb9d5..b168d3eb4c 100644 --- a/io/Versions +++ b/io/Versions @@ -128,4 +128,14 @@ libc { GLIBC_2.27 { copy_file_range; } + GLIBC_PRIVATE { + # called from libpthread + __libc_close; + __libc_fcntl; + __libc_lseek; __libc_lseek64; + __libc_open; __libc_open64; + __libc_read; + __libc_write; + __write_nocancel; + } } diff --git a/io/copy_file_range-compat.c b/io/copy_file_range-compat.c index 4ab22cad19..5d6ce34de9 100644 --- a/io/copy_file_range-compat.c +++ b/io/copy_file_range-compat.c @@ -97,7 +97,7 @@ COPY_FILE_RANGE (int infd, __off64_t *pinoff, if (pinoff == NULL) read_count = read (infd, buf, to_read); else - read_count = __libc_pread64 (infd, buf, to_read, *pinoff); + read_count = __pread64 (infd, buf, to_read, *pinoff); if (read_count == 0) /* End of file reached prematurely. */ return copied; @@ -119,7 +119,7 @@ COPY_FILE_RANGE (int infd, __off64_t *pinoff, if (poutoff == NULL) write_count = write (outfd, p, end - p); else - write_count = __libc_pwrite64 (outfd, p, end - p, *poutoff); + write_count = __pwrite64 (outfd, p, end - p, *poutoff); if (write_count < 0) { /* Adjust the input read position to match what we have @@ -136,7 +136,7 @@ COPY_FILE_RANGE (int infd, __off64_t *pinoff, /* We are on an error recovery path, so we cannot deal with failure here. */ int save_errno = errno; - (void) __libc_lseek64 (infd, -overread, SEEK_CUR); + (void) __lseek64 (infd, -overread, SEEK_CUR); __set_errno (save_errno); } } diff --git a/misc/Versions b/misc/Versions index bfbda505e4..065a7d9ed0 100644 --- a/misc/Versions +++ b/misc/Versions @@ -162,6 +162,7 @@ libc { __madvise; __mktemp; __libc_ifunc_impl_list; + __libc_fsync; __libc_msync; __tdelete; __tfind; __tsearch; __twalk; __mmap; __munmap; __mprotect; __sched_get_priority_min; __sched_get_priority_max; diff --git a/misc/fsync.c b/misc/fsync.c index e52be4cc6a..8eada612ef 100644 --- a/misc/fsync.c +++ b/misc/fsync.c @@ -20,11 +20,11 @@ /* Make all changes done to FD actually appear on disk. */ int -fsync (int fd) +__libc_fsync (int fd) { __set_errno (ENOSYS); return -1; } - - +weak_alias (__libc_fsync, fsync) +libc_hidden_weak (fsync) stub_warning (fsync) diff --git a/misc/msync.c b/misc/msync.c index 9785068444..72c876b63d 100644 --- a/misc/msync.c +++ b/misc/msync.c @@ -24,10 +24,11 @@ unpredictable before this is done. */ int -msync (void *addr, size_t len, int flags) +__libc_msync (void *addr, size_t len, int flags) { __set_errno (ENOSYS); return -1; } - +weak_alias (__libc_msync, msync) +libc_hidden_weak (msync) stub_warning (msync) diff --git a/nptl/Makefile b/nptl/Makefile index 18fbdfbee7..167f2cc24b 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -33,18 +33,6 @@ routines = alloca_cutoff forward libc-lowlevellock libc-cancellation \ shared-only-routines = forward static-only-routines = pthread_atfork -# We need to provide certain routines for compatibility with existing -# binaries. -pthread-compat-wrappers = \ - write read close fcntl accept \ - connect recv recvfrom send \ - sendto fsync lseek lseek64 \ - msync nanosleep open open64 pause \ - pread pread64 pwrite pwrite64 \ - tcdrain wait waitpid msgrcv msgsnd \ - sigwait sigsuspend \ - recvmsg sendmsg - libpthread-routines = nptl-init vars events version pt-interp \ pthread_create pthread_exit pthread_detach \ pthread_join pthread_tryjoin pthread_timedjoin \ @@ -116,13 +104,11 @@ libpthread-routines = nptl-init vars events version pt-interp \ sem_wait sem_timedwait sem_post \ cleanup cleanup_defer cleanup_compat \ cleanup_defer_compat unwind \ - pt-longjmp pt-cleanup\ + pt-cleanup \ cancellation \ lowlevellock \ lll_timedlock_wait lll_timedwait_tid \ - pt-fork \ - $(pthread-compat-wrappers) \ - pt-raise pt-system \ + pt-raise \ pt-compat-stubs \ flockfile ftrylockfile funlockfile \ sigaction \ @@ -190,41 +176,6 @@ CFLAGS-pthread_cond_wait.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-sem_wait.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-sem_timedwait.c += -fexceptions -fasynchronous-unwind-tables -# These are the function wrappers we have to duplicate here. -CFLAGS-fcntl.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-lockf.c += -fexceptions -CFLAGS-pread.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-pread64.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-pwrite.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-pwrite64.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-wait.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-waitpid.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-sigwait.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-msgrcv.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-msgsnd.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-tcdrain.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-open.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-open64.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-pause.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-recv.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-send.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-accept.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-sendto.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-connect.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-recvfrom.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-recvmsg.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-sendmsg.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-close.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-read.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-write.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-nanosleep.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-sigsuspend.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-msync.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-fdatasync.c += -fexceptions -fasynchronous-unwind-tables -CFLAGS-fsync.c += -fexceptions -fasynchronous-unwind-tables - -CFLAGS-pt-system.c += -fexceptions - LDLIBS-tst-once5 = -lstdc++ CFLAGS-tst-thread_local1.o = -std=gnu++11 LDLIBS-tst-thread_local1 = -lstdc++ diff --git a/nptl/pt-fork.c b/nptl/pt-fork.c deleted file mode 100644 index 891befbcda..0000000000 --- a/nptl/pt-fork.c +++ /dev/null @@ -1,49 +0,0 @@ -/* ABI compatibility for 'fork' symbol in libpthread ABI. - Copyright (C) 2002-2018 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2002. - - 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 - . */ - -#include -#include - -/* libpthread once had its own fork, though there was no apparent reason - for it. There is no use in having a separate symbol in libpthread, but - the historical ABI requires it. For static linking, there is no need to - provide anything here--the libc version will be linked in. For shared - library ABI compatibility, there must be __fork and fork symbols in - libpthread.so. - - With an IFUNC resolver, it would be possible to avoid the - indirection, but the IFUNC resolver might run before the - __libc_fork symbol has been relocated, in which case the IFUNC - resolver would not be able to provide the correct address. */ - -#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22) - -static pid_t __attribute__ ((used)) -fork_compat (void) -{ - return __libc_fork (); -} - -strong_alias (fork_compat, fork_alias) -compat_symbol (libpthread, fork_alias, fork, GLIBC_2_0); - -strong_alias (fork_compat, __fork_alias) -compat_symbol (libpthread, __fork_alias, __fork, GLIBC_2_0); - -#endif diff --git a/nptl/pt-longjmp.c b/nptl/pt-longjmp.c deleted file mode 100644 index 57808874a8..0000000000 --- a/nptl/pt-longjmp.c +++ /dev/null @@ -1,49 +0,0 @@ -/* ABI compatibility for 'longjmp' and 'siglongjmp' symbols in libpthread ABI. - Copyright (C) 2002-2018 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2002. - - 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 - . */ - -#include -#include - -/* libpthread once had its own longjmp (and siglongjmp alias), though there - was no apparent reason for it. There is no use in having a separate - symbol in libpthread, but the historical ABI requires it. For static - linking, there is no need to provide anything here--the libc version - will be linked in. For shared library ABI compatibility, there must be - longjmp and siglongjmp symbols in libpthread.so. - - With an IFUNC resolver, it would be possible to avoid the indirection, - but the IFUNC resolver might run before the __libc_longjmp symbol has - been relocated, in which case the IFUNC resolver would not be able to - provide the correct address. */ - -#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22) - -static void __attribute__ ((noreturn, used)) -longjmp_compat (jmp_buf env, int val) -{ - __libc_longjmp (env, val); -} - -strong_alias (longjmp_compat, longjmp_alias) -compat_symbol (libpthread, longjmp_alias, longjmp, GLIBC_2_0); - -strong_alias (longjmp_alias, siglongjmp_alias) -compat_symbol (libpthread, siglongjmp_alias, siglongjmp, GLIBC_2_0); - -#endif diff --git a/nptl/pt-system.c b/nptl/pt-system.c deleted file mode 100644 index 3d73b55c69..0000000000 --- a/nptl/pt-system.c +++ /dev/null @@ -1,45 +0,0 @@ -/* ABI compatibility for 'system' symbol in libpthread ABI. - Copyright (C) 2002-2018 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2002. - - 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 - . */ - -#include -#include - -/* libpthread once had its own 'system', though there was no apparent - reason for it. There is no use in having a separate symbol in - libpthread, but the historical ABI requires it. For static linking, - there is no need to provide anything here--the libc version will be - linked in. For shared library ABI compatibility, there must be a - 'system' symbol in libpthread.so. - - With an IFUNC resolver, it would be possible to avoid the indirection, - but the IFUNC resolver might run before the __libc_system symbol has - been relocated, in which case the IFUNC resolver would not be able to - provide the correct address. */ - -#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22) - -static int __attribute__ ((used)) -system_compat (const char *line) -{ - return __libc_system (line); -} -strong_alias (system_compat, system_alias) -compat_symbol (libpthread, system_alias, system, GLIBC_2_0); - -#endif diff --git a/posix/Versions b/posix/Versions index 65e96870e1..5b34eba1f6 100644 --- a/posix/Versions +++ b/posix/Versions @@ -138,6 +138,12 @@ libc { glob; glob64; } GLIBC_PRIVATE { - __libc_fork; __libc_pread; __libc_pwrite; + __libc_fork; + __libc_nanosleep; + __libc_pause; + __libc_pread; __libc_pread64; + __libc_pwrite; __libc_pwrite64; + __libc_wait; __libc_waitpid; + __pause_nocancel; __nanosleep_nocancel; } } diff --git a/posix/nanosleep.c b/posix/nanosleep.c index 3f13a1db48..9939aa1507 100644 --- a/posix/nanosleep.c +++ b/posix/nanosleep.c @@ -30,4 +30,5 @@ __nanosleep (const struct timespec *requested_time, stub_warning (nanosleep) hidden_def (__nanosleep) +strong_alias (__nanosleep, __libc_nanosleep) weak_alias (__nanosleep, nanosleep) diff --git a/posix/waitpid.c b/posix/waitpid.c index 9a31175699..9cb6d748f3 100644 --- a/posix/waitpid.c +++ b/posix/waitpid.c @@ -45,6 +45,7 @@ __waitpid (pid_t pid, int *stat_loc, int options) return (pid_t) -1; } libc_hidden_def (__waitpid) +strong_alias (__waitpid, __libc_waitpid) weak_alias (__waitpid, waitpid) stub_warning (waitpid) diff --git a/signal/Versions b/signal/Versions index a915ef400f..9042703c01 100644 --- a/signal/Versions +++ b/signal/Versions @@ -51,4 +51,8 @@ libc { } GLIBC_2.21 { } + GLIBC_PRIVATE { + # called from libpthread + __libc_sigwait; + } } diff --git a/socket/Versions b/socket/Versions index 7ce6f43841..c603dfc686 100644 --- a/socket/Versions +++ b/socket/Versions @@ -40,5 +40,9 @@ libc { GLIBC_PRIVATE { __sendmmsg; __recv; __socket; + __libc_accept; + __libc_connect; + __libc_recv; __libc_recvfrom; __libc_recvmsg; + __libc_send; __libc_sendto; __libc_sendmsg; } } diff --git a/socket/accept.c b/socket/accept.c index 84894a97d6..767bd5c8fd 100644 --- a/socket/accept.c +++ b/socket/accept.c @@ -24,12 +24,12 @@ peer and *ADDR_LEN to the address's actual length, and return the new socket's descriptor, or -1 for errors. */ int -accept (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len) +__libc_accept (int fd, __SOCKADDR_ARG addr, socklen_t *addr_len) { __set_errno (ENOSYS); return -1; } -libc_hidden_def (accept) - +weak_alias (__libc_accept, accept) +libc_hidden_weak (accept) stub_warning (accept) diff --git a/sysdeps/generic/pt-compat-stubs.S b/sysdeps/generic/pt-compat-stubs.S index 3055cfe3ca..426689a18d 100644 --- a/sysdeps/generic/pt-compat-stubs.S +++ b/sysdeps/generic/pt-compat-stubs.S @@ -1,4 +1,4 @@ -/* Compatibility stubs for functions formerly exposed by libpthread. +/* ABI compatibility stubs for libpthread. Copyright (C) 2018 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -31,14 +31,27 @@ #include #include +/* We need __OFF_T_MATCHES_OFF64_T, but sys/types.h cannot be included + from assembly language. */ +#define _BITS_TYPES_H 1 +#include + compat_text_section #ifndef SIBCALL_ENTRY # define SIBCALL_ENTRY(name) ENTRY(name) #endif +#ifndef LONGJMP_2_0_DEST +# define LONGJMP_2_0_DEST __libc_longjmp +#endif +#ifndef LONGJMP_2_0_UNTIL_VER +# define LONGJMP_2_0_UNTIL_VER GLIBC_2_22 +#endif #define define_stub(name) \ define_stub_1(__pstub_##name, __libc_##name) +#define define_stub_with_dest(name, dest) \ + define_stub_1(__pstub_##name, dest) #define define_stub_1(pstub_name, libc_name) \ SIBCALL_ENTRY(pstub_name) ASM_LINE_SEP \ SIBCALL(libc_name) ASM_LINE_SEP \ @@ -64,5 +77,162 @@ # if SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20) compat_stub(vfork, __vfork, GLIBC_2_1_2) # endif +#endif + +#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22) + + define_stub(fork) + compat_stub(fork, fork, GLIBC_2_0) + compat_stub(fork, __fork, GLIBC_2_0) + + define_stub(system) + compat_stub(system, system, GLIBC_2_0) + +#endif + +/* Some architectures need special treatment for longjmp. */ +#if SHLIB_COMPAT (libpthread, GLIBC_2_0, LONGJMP_2_0_UNTIL_VER) + + define_stub_with_dest(longjmp, LONGJMP_2_0_DEST) + compat_stub(longjmp, longjmp, GLIBC_2_0) + compat_stub(longjmp, siglongjmp, GLIBC_2_0) + +#endif + +#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_28) + + define_stub(accept) + compat_stub(accept, accept, GLIBC_2_0) + + define_stub(close) + compat_stub(close, close, GLIBC_2_0) + compat_stub(close, __close, GLIBC_2_0) + + define_stub(connect) + compat_stub(connect, connect, GLIBC_2_0) + compat_stub(connect, __connect, GLIBC_2_0) + + define_stub(fcntl) + compat_stub(fcntl, fcntl, GLIBC_2_0) + compat_stub(fcntl, __fcntl, GLIBC_2_0) + + define_stub(fsync) + compat_stub(fsync, fsync, GLIBC_2_0) + + define_stub(msync) + compat_stub(msync, msync, GLIBC_2_0) + + define_stub(nanosleep) + compat_stub(nanosleep, nanosleep, GLIBC_2_0) +#if SHLIB_COMPAT (libpthread, GLIBC_2_2_6, GLIBC_2_28) + compat_stub(nanosleep, __nanosleep, GLIBC_2_2_6) +#endif + + define_stub(pause) + compat_stub(pause, pause, GLIBC_2_0) + + define_stub(read) + compat_stub(read, read, GLIBC_2_0) + compat_stub(read, __read, GLIBC_2_0) + + define_stub(recv) + compat_stub(recv, recv, GLIBC_2_0) + + define_stub(recvfrom) + compat_stub(recvfrom, recvfrom, GLIBC_2_0) + + define_stub(recvmsg) + compat_stub(recvmsg, recvmsg, GLIBC_2_0) + + define_stub(send) + compat_stub(send, send, GLIBC_2_0) + compat_stub(send, __send, GLIBC_2_0) + + define_stub(sendmsg) + compat_stub(sendmsg, sendmsg, GLIBC_2_0) + + define_stub(sendto) + compat_stub(sendto, sendto, GLIBC_2_0) + + define_stub(sigwait) + compat_stub(sigwait, sigwait, GLIBC_2_0) + + define_stub(tcdrain) + compat_stub(tcdrain, tcdrain, GLIBC_2_0) + + define_stub(wait) + compat_stub(wait, wait, GLIBC_2_0) + compat_stub(wait, __wait, GLIBC_2_0) + + define_stub(waitpid) + compat_stub(waitpid, waitpid, GLIBC_2_0) + + define_stub(write) + compat_stub(write, write, GLIBC_2_0) + compat_stub(write, __write, GLIBC_2_0) + +#endif + +/* The off64_t functions were added in glibc 2.2, but some architectures + had 64-bit off_t before that. On those architectures, the unsuffixed + lseek, open, etc should be additional aliases for the suffixed ones. */ + +#if SHLIB_COMPAT (libpthread, GLIBC_2_2, GLIBC_2_28) \ + || (SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_28) \ + && defined __OFF_T_MATCHES_OFF64_T) + +#ifndef __OFF_T_MATCHES_OFF64_T + define_stub(lseek) + compat_stub(lseek, lseek, GLIBC_2_0) + compat_stub(lseek, __lseek, GLIBC_2_0) + + define_stub(open) + compat_stub(open, open, GLIBC_2_0) + compat_stub(open, __open, GLIBC_2_0) +#endif + + define_stub(lseek64) + compat_stub(lseek64, lseek64, GLIBC_2_2) +# ifdef __OFF_T_MATCHES_OFF64_T + compat_stub(lseek64, lseek, GLIBC_2_0) + compat_stub(lseek64, __lseek, GLIBC_2_0) +# endif + + define_stub(open64) + compat_stub(open64, open64, GLIBC_2_2) + compat_stub(open64, __open64, GLIBC_2_2) +# ifdef __OFF_T_MATCHES_OFF64_T + compat_stub(open64, open, GLIBC_2_0) + compat_stub(open64, __open, GLIBC_2_0) +# endif + +#endif + +/* pread and pwrite were added in the same release as pread64 and pwrite64, + and do not have exposed __ variants. */ + +#if SHLIB_COMPAT (libpthread, GLIBC_2_2, GLIBC_2_28) + +# ifndef __OFF_T_MATCHES_OFF64_T + define_stub(pread) + compat_stub(pread, pread, GLIBC_2_2) + + define_stub(pwrite) + compat_stub(pwrite, pwrite, GLIBC_2_2) +# endif + + define_stub(pread64) + compat_stub(pread64, pread64, GLIBC_2_2) + compat_stub(pread64, __pread64, GLIBC_2_2) +#ifdef __OFF_T_MATCHES_OFF64_T + compat_stub(pread64, pread, GLIBC_2_2) +#endif + + define_stub(pwrite64) + compat_stub(pwrite64, pwrite64, GLIBC_2_2) + compat_stub(pwrite64, __pwrite64, GLIBC_2_2) +#ifdef __OFF_T_MATCHES_OFF64_T + compat_stub(pwrite64, pwrite, GLIBC_2_2) +#endif #endif diff --git a/sysdeps/mach/hurd/accept.c b/sysdeps/mach/hurd/accept.c index a6a3a9a0a0..602d2663b6 100644 --- a/sysdeps/mach/hurd/accept.c +++ b/sysdeps/mach/hurd/accept.c @@ -24,8 +24,9 @@ peer and *ADDR_LEN to the address's actual length, and return the new socket's descriptor, or -1 for errors. */ int -accept (int fd, __SOCKADDR_ARG addrarg, socklen_t *addr_len) +__libc_accept (int fd, __SOCKADDR_ARG addrarg, socklen_t *addr_len) { - return __libc_accept4 (fd, addrarg, addr_len, 0); + return __accept4 (fd, addrarg, addr_len, 0); } -libc_hidden_def (accept) +weak_alias (__libc_accept, accept) +libc_hidden_weak (accept) diff --git a/sysdeps/mach/hurd/fsync.c b/sysdeps/mach/hurd/fsync.c index d8ae6e0358..c9cf7c2693 100644 --- a/sysdeps/mach/hurd/fsync.c +++ b/sysdeps/mach/hurd/fsync.c @@ -22,7 +22,7 @@ /* Make all changes done to FD actually appear on disk. */ int -fsync (int fd) +__libc_fsync (int fd) { error_t err = HURD_DPORT_USE (fd, __file_sync (port, 1, 0)); if (err) @@ -35,3 +35,4 @@ fsync (int fd) } return 0; } +weak_alias (__libc_fsync, fsync) diff --git a/sysdeps/mach/hurd/pread.c b/sysdeps/mach/hurd/pread.c index 63a90aa4df..c4e005e463 100644 --- a/sysdeps/mach/hurd/pread.c +++ b/sysdeps/mach/hurd/pread.c @@ -23,7 +23,7 @@ ssize_t __libc_pread (int fd, void *buf, size_t nbytes, off_t offset) { - return __libc_pread64 (fd, buf, nbytes, (off64_t) offset); + return __pread64 (fd, buf, nbytes, (off64_t) offset); } #ifndef __libc_pread diff --git a/sysdeps/mach/hurd/pwrite.c b/sysdeps/mach/hurd/pwrite.c index 80be158489..626ec7ef87 100644 --- a/sysdeps/mach/hurd/pwrite.c +++ b/sysdeps/mach/hurd/pwrite.c @@ -25,7 +25,7 @@ ssize_t __libc_pwrite (int fd, const void *buf, size_t nbytes, off_t offset) { - return __libc_pwrite64 (fd, buf, nbytes, (off64_t) offset); + return __pwrite64 (fd, buf, nbytes, (off64_t) offset); } #ifndef __libc_pwrite diff --git a/sysdeps/mach/msync.c b/sysdeps/mach/msync.c index 92ce15e639..02651b6d6e 100644 --- a/sysdeps/mach/msync.c +++ b/sysdeps/mach/msync.c @@ -33,7 +33,7 @@ unpredictable before this is done. */ int -msync (void *addr, size_t len, int flags) +__libc_msync (void *addr, size_t len, int flags) { vm_sync_t sync_flags = 0; kern_return_t err; @@ -53,4 +53,5 @@ msync (void *addr, size_t len, int flags) } return 0; } +weak_alias (__libc_msync, msync) #endif diff --git a/sysdeps/posix/posix_fallocate64.c b/sysdeps/posix/posix_fallocate64.c index 2eaeab2a6f..8f536e3bd4 100644 --- a/sysdeps/posix/posix_fallocate64.c +++ b/sysdeps/posix/posix_fallocate64.c @@ -104,7 +104,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) if (offset < st.st_size) { unsigned char c; - ssize_t rsize = __libc_pread64 (fd, &c, 1, offset); + ssize_t rsize = __pread64 (fd, &c, 1, offset); if (rsize < 0) return errno; @@ -114,7 +114,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) continue; } - if (__libc_pwrite64 (fd, "", 1, offset) != 1) + if (__pwrite64 (fd, "", 1, offset) != 1) return errno; } diff --git a/sysdeps/unix/bsd/waitpid.c b/sysdeps/unix/bsd/waitpid.c index 543b94fc9f..85245e64af 100644 --- a/sysdeps/unix/bsd/waitpid.c +++ b/sysdeps/unix/bsd/waitpid.c @@ -39,4 +39,5 @@ __waitpid (pid_t pid, int *stat_loc, int options) } libc_hidden_def (__waitpid) +strong_alias (__waitpid, __libc_waitpid) weak_alias (__waitpid, waitpid) diff --git a/sysdeps/unix/sysv/linux/fsync.c b/sysdeps/unix/sysv/linux/fsync.c index db101a219d..3c47534679 100644 --- a/sysdeps/unix/sysv/linux/fsync.c +++ b/sysdeps/unix/sysv/linux/fsync.c @@ -22,7 +22,8 @@ /* Make all changes done to FD actually appear on disk. */ int -fsync (int fd) +__libc_fsync (int fd) { return SYSCALL_CANCEL (fsync, fd); } +weak_alias (__libc_fsync, fsync) diff --git a/sysdeps/unix/sysv/linux/hppa/localplt.data b/sysdeps/unix/sysv/linux/hppa/localplt.data index 5f3475de19..867413f0c5 100644 --- a/sysdeps/unix/sysv/linux/hppa/localplt.data +++ b/sysdeps/unix/sysv/linux/hppa/localplt.data @@ -10,7 +10,6 @@ libc.so: __sigsetjmp libc.so: _IO_funlockfile libc.so: __errno_location libm.so: matherr -libpthread.so: __errno_location # The main malloc is interposed into the dynamic linker, for # allocations after the initial link (when dlopen is used). ld.so: malloc diff --git a/sysdeps/unix/sysv/linux/msync.c b/sysdeps/unix/sysv/linux/msync.c index fa443e73de..ea9c9f1274 100644 --- a/sysdeps/unix/sysv/linux/msync.c +++ b/sysdeps/unix/sysv/linux/msync.c @@ -20,7 +20,8 @@ #include int -msync (void *addr, size_t length, int flags) +__libc_msync (void *addr, size_t length, int flags) { return SYSCALL_CANCEL (msync, addr, length, flags); } +weak_alias (__libc_msync, msync) diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c index 8945837407..cbd9ba4c15 100644 --- a/sysdeps/unix/sysv/linux/nanosleep.c +++ b/sysdeps/unix/sysv/linux/nanosleep.c @@ -28,6 +28,7 @@ __nanosleep (const struct timespec *requested_time, return SYSCALL_CANCEL (nanosleep, requested_time, remaining); } hidden_def (__nanosleep) +strong_alias (__nanosleep, __libc_nanosleep) weak_alias (__nanosleep, nanosleep) int diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index e6cdd144c2..e532b19042 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -83,7 +83,7 @@ libc_hidden_proto (__pause_nocancel) /* Uncancelable nanosleep. */ __typeof (__nanosleep) __nanosleep_nocancel; -hidden_proto (__nanosleep_nocancel) +libc_hidden_proto (__nanosleep_nocancel) /* Uncancelable fcntl. */ __typeof (__fcntl) __fcntl_nocancel; diff --git a/sysdeps/unix/sysv/linux/open64.c b/sysdeps/unix/sysv/linux/open64.c index 4af5ee2466..f79c5e86c9 100644 --- a/sysdeps/unix/sysv/linux/open64.c +++ b/sysdeps/unix/sysv/linux/open64.c @@ -76,6 +76,7 @@ libc_hidden_def (__open64_nocancel) #ifdef __OFF_T_MATCHES_OFF64_T strong_alias (__libc_open64, __libc_open) +libc_hidden_def (__libc_open) strong_alias (__libc_open64, __open) libc_hidden_weak (__open) weak_alias (__libc_open64, open) diff --git a/sysdeps/unix/sysv/linux/powerpc/pt-compat-stubs.S b/sysdeps/unix/sysv/linux/powerpc/pt-compat-stubs.S new file mode 100644 index 0000000000..077c2c5c78 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/pt-compat-stubs.S @@ -0,0 +1,32 @@ +/* ABI compatibility stubs for libpthread. PowerPC/Linux version. + Copyright (C) 2018 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 + . */ + +/* AltiVec support was added to setjmp/longjmp in 2.3.4, + requiring a new symbol version. */ +#define LONGJMP_2_0_DEST __novmx__libc_siglongjmp +#define LONGJMP_2_0_UNTIL_VER GLIBC_2_3_4 + +#include + +#if SHLIB_COMPAT (libpthread, GLIBC_2_3_4, GLIBC_2_28) + + define_stub_with_dest(vmx_longjmp, __libc_longjmp) + compat_stub(vmx_longjmp, longjmp, GLIBC_2_3_4) + compat_stub(vmx_longjmp, siglongjmp, GLIBC_2_3_4) + +#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c b/sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c deleted file mode 100644 index 5b3546143b..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/pt-longjmp.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2002-2018 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2002. - - 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 - . */ - -#include -#include -#include -#include "pthreadP.h" -#include -#if defined SHARED && SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_3_4) - -/* These functions are not declared anywhere since they shouldn't be - used at another place but here. */ -extern void __novmx__libc_siglongjmp (sigjmp_buf env, int val) - __attribute__ ((noreturn)); -extern void __novmx__libc_longjmp (sigjmp_buf env, int val) - __attribute__ ((noreturn)); - - -void __novmx_siglongjmp (sigjmp_buf env, int val) -{ - __novmx__libc_siglongjmp (env, val); -} - -void __novmx_longjmp (jmp_buf env, int val) -{ - __novmx__libc_longjmp (env, val); -} - -compat_symbol (libpthread, __novmx_longjmp, longjmp, GLIBC_2_0); -compat_symbol (libpthread, __novmx_siglongjmp, siglongjmp, GLIBC_2_0); -#endif /* defined SHARED && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)) */ - -void -__vmx_longjmp (jmp_buf env, int val) -{ - __libc_longjmp (env, val); -} - -void -__vmx_siglongjmp (jmp_buf env, int val) -{ - __libc_siglongjmp (env, val); -} - -versioned_symbol (libpthread, __vmx_longjmp, longjmp, GLIBC_2_3_4); -versioned_symbol (libpthread, __vmx_siglongjmp, siglongjmp, GLIBC_2_3_4); diff --git a/sysdeps/unix/sysv/linux/s390/pt-compat-stubs.S b/sysdeps/unix/sysv/linux/s390/pt-compat-stubs.S new file mode 100644 index 0000000000..7204aba0fa --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/pt-compat-stubs.S @@ -0,0 +1,28 @@ +/* ABI compatibility stubs for libpthread. S/390/Linux version. + Copyright (C) 2018 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 + . */ + +#include + +#if SHLIB_COMPAT (libpthread, GLIBC_2_19, GLIBC_2_20) +/* In glibc release 2.19 new versions of longjmp-functions were introduced, + but were reverted before 2.20. Thus both versions are the same function. */ + + compat_stub(longjmp, longjmp, GLIBC_2_19) + compat_stub(longjmp, siglongjmp, GLIBC_2_19) + +#endif diff --git a/sysdeps/unix/sysv/linux/s390/pt-longjmp.c b/sysdeps/unix/sysv/linux/s390/pt-longjmp.c deleted file mode 100644 index bd41a84a18..0000000000 --- a/sysdeps/unix/sysv/linux/s390/pt-longjmp.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2014-2018 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 - . - - Versioned copy of nptl/pt-longjmp.c modified for versioning - the reverted jmpbuf extension. */ - -#include - -#include - -#if SHLIB_COMPAT (libpthread, GLIBC_2_19, GLIBC_2_20) -/* In glibc release 2.19 new versions of longjmp-functions were introduced, - but were reverted before 2.20. Thus both versions are the same function. */ - -strong_alias (longjmp_alias, __v2longjmp) -compat_symbol (libpthread, __v2longjmp, longjmp, GLIBC_2_19); -strong_alias (siglongjmp_alias, __v2siglongjmp) -compat_symbol (libpthread, __v2siglongjmp, siglongjmp, GLIBC_2_19); -#endif /* SHLIB_COMPAT (libpthread, GLIBC_2_19, GLIBC_2_20)) */ diff --git a/sysdeps/unix/sysv/linux/waitpid.c b/sysdeps/unix/sysv/linux/waitpid.c index d1d30fd431..3b7ddc6059 100644 --- a/sysdeps/unix/sysv/linux/waitpid.c +++ b/sysdeps/unix/sysv/linux/waitpid.c @@ -31,6 +31,7 @@ __waitpid (__pid_t pid, int *stat_loc, int options) #endif } libc_hidden_def (__waitpid) +strong_alias (__waitpid, __libc_waitpid) weak_alias (__waitpid, waitpid) __pid_t diff --git a/termios/Versions b/termios/Versions index 711ed0334b..54eaf2f2ad 100644 --- a/termios/Versions +++ b/termios/Versions @@ -11,4 +11,8 @@ libc { # t* tcgetsid; } + GLIBC_PRIVATE { + # called from libpthread + __libc_tcdrain; + } } -- cgit 1.4.1