diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/generic/localplt.data | 12 | ||||
-rw-r--r-- | sysdeps/nptl/bits/libc-lockP.h | 65 | ||||
-rw-r--r-- | sysdeps/nptl/jmp-unwind.c | 14 | ||||
-rw-r--r-- | sysdeps/nptl/pthread-functions.h | 10 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/fatal-prepare.h | 19 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/libc.abilist | 1 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/localplt.data | 12 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/s390/jmp-unwind.c | 12 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 1 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/x86_64/cancellation.S | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist | 1 | ||||
-rw-r--r-- | sysdeps/x86_64/localplt.data | 12 |
14 files changed, 110 insertions, 63 deletions
diff --git a/sysdeps/generic/localplt.data b/sysdeps/generic/localplt.data index 1a40cf9841..5b1463f584 100644 --- a/sysdeps/generic/localplt.data +++ b/sysdeps/generic/localplt.data @@ -1,6 +1,18 @@ # See scripts/check-localplt.awk for how this file is processed. # PLT use is required for the malloc family and for matherr because # users can define their own functions and have library internals call them. +# pthread functions may be preempted by libpthread at run-time. +libc.so: __pthread_getspecific +libc.so: __pthread_key_create +libc.so: __pthread_once +libc.so: __pthread_rwlock_rdlock +libc.so: __pthread_rwlock_unlock +libc.so: __pthread_rwlock_wrlock +libc.so: __pthread_setcancelstate +libc.so: __pthread_setspecific +libc.so: __pthread_unwind +libc.so: _pthread_cleanup_pop_restore +libc.so: _pthread_cleanup_push_defer libc.so: calloc libc.so: free libc.so: malloc diff --git a/sysdeps/nptl/bits/libc-lockP.h b/sysdeps/nptl/bits/libc-lockP.h index f55f6212ec..f5753afb32 100644 --- a/sysdeps/nptl/bits/libc-lockP.h +++ b/sysdeps/nptl/bits/libc-lockP.h @@ -99,39 +99,51 @@ typedef pthread_key_t __libc_key_t; #define __rtld_lock_initialize(NAME) \ (void) ((NAME) = (__rtld_lock_recursive_t) _RTLD_LOCK_RECURSIVE_INITIALIZER) +#ifdef HAVE_ASM_SECONDARY_DIRECTIVE +/* All pthread functions are available. */ +# define PTFAVAIL(NAME) 1 + +/* When secondary symbols are used, FUNC is implemented to return ELSE so + that we can always call FUNC. */ +# define __libc_maybe_call(FUNC, ARGS, ELSE) FUNC ARGS +# define __libc_ptf_call(FUNC, ARGS, ELSE) FUNC ARGS +# define __libc_ptf_call_always(FUNC, ARGS) FUNC ARGS +#else /* If we check for a weakly referenced symbol and then perform a normal jump to it te code generated for some platforms in case of PIC is unnecessarily slow. What would happen is that the function is first referenced as data and then it is called indirectly through the PLT. We can make this a direct jump. */ -#ifdef __PIC__ -# define __libc_maybe_call(FUNC, ARGS, ELSE) \ - (__extension__ ({ __typeof (FUNC) *_fn = (FUNC); \ - _fn != NULL ? (*_fn) ARGS : ELSE; })) -#else -# define __libc_maybe_call(FUNC, ARGS, ELSE) \ - (FUNC != NULL ? FUNC ARGS : ELSE) -#endif +# ifdef __PIC__ +# define __libc_maybe_call(FUNC, ARGS, ELSE) \ + (__extension__ ({ __typeof (FUNC) *_fn = (FUNC); \ + _fn != NULL ? (*_fn) ARGS : ELSE; })) +# else +# define __libc_maybe_call(FUNC, ARGS, ELSE) \ + (FUNC != NULL ? FUNC ARGS : ELSE) +# endif /* Call thread functions through the function pointer table. */ -#if defined SHARED && IS_IN (libc) -# define PTFAVAIL(NAME) __libc_pthread_functions_init -# define __libc_ptf_call(FUNC, ARGS, ELSE) \ +# if defined SHARED && IS_IN (libc) \ + && !defined HAVE_ASM_SECONDARY_DIRECTIVE +# define PTFAVAIL(NAME) __libc_pthread_functions_init +# define __libc_ptf_call(FUNC, ARGS, ELSE) \ (__libc_pthread_functions_init ? PTHFCT_CALL (ptr_##FUNC, ARGS) : ELSE) -# define __libc_ptf_call_always(FUNC, ARGS) \ +# define __libc_ptf_call_always(FUNC, ARGS) \ PTHFCT_CALL (ptr_##FUNC, ARGS) -#elif IS_IN (libpthread) -# define PTFAVAIL(NAME) 1 -# define __libc_ptf_call(FUNC, ARGS, ELSE) \ +# elif IS_IN (libpthread) +# define PTFAVAIL(NAME) 1 +# define __libc_ptf_call(FUNC, ARGS, ELSE) \ FUNC ARGS -# define __libc_ptf_call_always(FUNC, ARGS) \ +# define __libc_ptf_call_always(FUNC, ARGS) \ FUNC ARGS -#else -# define PTFAVAIL(NAME) (NAME != NULL) -# define __libc_ptf_call(FUNC, ARGS, ELSE) \ - __libc_maybe_call (FUNC, ARGS, ELSE) -# define __libc_ptf_call_always(FUNC, ARGS) \ +# else +# define PTFAVAIL(NAME) (NAME != NULL) +# define __libc_ptf_call(FUNC, ARGS, ELSE) \ + __libc_maybe_call (FUNC, ARGS, ELSE) +# define __libc_ptf_call_always(FUNC, ARGS) \ FUNC ARGS +# endif #endif @@ -364,6 +376,8 @@ extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock); extern int __pthread_key_create (pthread_key_t *__key, void (*__destr_function) (void *)); +extern int __pthread_setcancelstate (int state, int *oldstate); + extern int __pthread_setspecific (pthread_key_t __key, const void *__pointer); @@ -379,8 +393,9 @@ extern int __pthread_atfork (void (*__prepare) (void), /* Make the pthread functions weak so that we can elide them from - single-threaded processes. */ -#ifndef __NO_WEAK_PTHREAD_ALIASES + single-threaded processes unless secondary symbols are used. */ +#if !defined __NO_WEAK_PTHREAD_ALIASES \ + && !defined HAVE_ASM_SECONDARY_DIRECTIVE # ifdef weak_extern weak_extern (__pthread_mutex_init) weak_extern (__pthread_mutex_destroy) @@ -405,7 +420,7 @@ weak_extern (__pthread_initialize) weak_extern (__pthread_atfork) weak_extern (_pthread_cleanup_push_defer) weak_extern (_pthread_cleanup_pop_restore) -weak_extern (pthread_setcancelstate) +weak_extern (__pthread_setcancelstate) # else # pragma weak __pthread_mutex_init # pragma weak __pthread_mutex_destroy @@ -429,7 +444,7 @@ weak_extern (pthread_setcancelstate) # pragma weak __pthread_atfork # pragma weak _pthread_cleanup_push_defer # pragma weak _pthread_cleanup_pop_restore -# pragma weak pthread_setcancelstate +# pragma weak __pthread_setcancelstate # endif #endif diff --git a/sysdeps/nptl/jmp-unwind.c b/sysdeps/nptl/jmp-unwind.c index 8e019867a7..6f19c6215d 100644 --- a/sysdeps/nptl/jmp-unwind.c +++ b/sysdeps/nptl/jmp-unwind.c @@ -18,21 +18,17 @@ #include <setjmp.h> #include <stddef.h> -#include <nptl/pthreadP.h> +#include <bits/libc-lock.h> extern void __pthread_cleanup_upto (__jmp_buf env, char *targetframe); +#ifndef HAVE_ASM_SECONDARY_DIRECTIVE #pragma weak __pthread_cleanup_upto +#endif void _longjmp_unwind (jmp_buf env, int val) { -#ifdef SHARED - if (__libc_pthread_functions_init) - PTHFCT_CALL (ptr___pthread_cleanup_upto, (env->__jmpbuf, - CURRENT_STACK_FRAME)); -#else - if (__pthread_cleanup_upto != NULL) - __pthread_cleanup_upto (env->__jmpbuf, CURRENT_STACK_FRAME); -#endif + __libc_ptf_call (__pthread_cleanup_upto, (env->__jmpbuf, + CURRENT_STACK_FRAME), 0); } diff --git a/sysdeps/nptl/pthread-functions.h b/sysdeps/nptl/pthread-functions.h index 0784c59cab..f6238ab663 100644 --- a/sysdeps/nptl/pthread-functions.h +++ b/sysdeps/nptl/pthread-functions.h @@ -30,6 +30,7 @@ struct xid_command; the thread functions. */ struct pthread_functions { +#ifndef HAVE_ASM_SECONDARY_DIRECTIVE int (*ptr_pthread_attr_destroy) (pthread_attr_t *); int (*ptr___pthread_attr_init_2_0) (pthread_attr_t *); int (*ptr___pthread_attr_init_2_1) (pthread_attr_t *); @@ -75,9 +76,8 @@ struct pthread_functions int (*ptr_pthread_mutex_lock) (pthread_mutex_t *); int (*ptr_pthread_mutex_unlock) (pthread_mutex_t *); pthread_t (*ptr_pthread_self) (void); - int (*ptr_pthread_setcancelstate) (int, int *); + int (*ptr___pthread_setcancelstate) (int, int *); int (*ptr_pthread_setcanceltype) (int, int *); - void (*ptr___pthread_cleanup_upto) (__jmp_buf, char *); int (*ptr___pthread_once) (pthread_once_t *, void (*) (void)); int (*ptr___pthread_rwlock_rdlock) (pthread_rwlock_t *); int (*ptr___pthread_rwlock_wrlock) (pthread_rwlock_t *); @@ -89,10 +89,12 @@ struct pthread_functions void (*) (void *), void *); void (*ptr__pthread_cleanup_pop_restore) (struct _pthread_cleanup_buffer *, int); -#define HAVE_PTR_NTHREADS - unsigned int *ptr_nthreads; void (*ptr___pthread_unwind) (__pthread_unwind_buf_t *) __attribute ((noreturn)) __cleanup_fct_attribute; +#endif + void (*ptr___pthread_cleanup_upto) (__jmp_buf, char *); +#define HAVE_PTR_NTHREADS + unsigned int *ptr_nthreads; void (*ptr__nptl_deallocate_tsd) (void); int (*ptr__nptl_setxid) (struct xid_command *); void (*ptr_freeres) (void); diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/sysdeps/unix/sysv/linux/fatal-prepare.h index 45d88ce911..2a89567299 100644 --- a/sysdeps/unix/sysv/linux/fatal-prepare.h +++ b/sysdeps/unix/sysv/linux/fatal-prepare.h @@ -19,19 +19,6 @@ /* We have to completely disable cancellation. assert() must not be a cancellation point but the implementation uses write() etc. */ -#ifdef SHARED -# include <pthread-functions.h> -# define FATAL_PREPARE \ - { \ - if (__libc_pthread_functions_init) \ - PTHFCT_CALL (ptr_pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, \ - NULL)); \ - } -#else -# pragma weak pthread_setcancelstate -# define FATAL_PREPARE \ - { \ - if (pthread_setcancelstate != NULL) \ - pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL); \ - } -#endif +#define FATAL_PREPARE \ + __libc_ptf_call (__pthread_setcancelstate, \ + (PTHREAD_CANCEL_DISABLE, NULL), 0) diff --git a/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S b/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S index 111e9c88ed..cf3f206445 100644 --- a/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S +++ b/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S @@ -16,4 +16,10 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#if IS_IN (libc) && !defined SHARED +/* Allow libpthread.a to override the ones in libc.a. */ + weak_extern (__lll_lock_wait_private) + weak_extern (__lll_unlock_wake_private) +#endif + #include "lowlevellock.S" diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index fcf1b72ab5..fe41fbd6ac 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -868,6 +868,7 @@ GLIBC_2.0 pthread_mutex_init F pthread_mutex_lock F pthread_mutex_unlock F + pthread_once F pthread_self F pthread_setcancelstate F pthread_setcanceltype F diff --git a/sysdeps/unix/sysv/linux/i386/localplt.data b/sysdeps/unix/sysv/linux/i386/localplt.data index 2e03821dfd..f9efb05c41 100644 --- a/sysdeps/unix/sysv/linux/i386/localplt.data +++ b/sysdeps/unix/sysv/linux/i386/localplt.data @@ -6,6 +6,18 @@ libc.so: free + REL R_386_GLOB_DAT libc.so: malloc + REL R_386_GLOB_DAT libc.so: memalign libc.so: realloc +# pthread functions may be preempted by libpthread at run-time. +libc.so: __pthread_getspecific +libc.so: __pthread_key_create +libc.so: __pthread_once +libc.so: __pthread_rwlock_rdlock +libc.so: __pthread_rwlock_unlock +libc.so: __pthread_rwlock_wrlock +libc.so: __pthread_setcancelstate +libc.so: __pthread_setspecific +libc.so: __pthread_unwind +libc.so: _pthread_cleanup_pop_restore +libc.so: _pthread_cleanup_push_defer libm.so: matherr # The dynamic loader uses __libc_memalign internally to allocate aligned # TLS storage. The other malloc family of functions are expected to allow diff --git a/sysdeps/unix/sysv/linux/s390/jmp-unwind.c b/sysdeps/unix/sysv/linux/s390/jmp-unwind.c index 52fe1019f2..b7f9080e5a 100644 --- a/sysdeps/unix/sysv/linux/s390/jmp-unwind.c +++ b/sysdeps/unix/sysv/linux/s390/jmp-unwind.c @@ -18,10 +18,12 @@ #include <setjmp.h> #include <stddef.h> -#include <nptl/pthreadP.h> +#include <bits/libc-lock.h> extern void __pthread_cleanup_upto (__jmp_buf env, char *targetframe); +#ifndef HAVE_ASM_SECONDARY_DIRECTIVE #pragma weak __pthread_cleanup_upto +#endif void @@ -29,11 +31,5 @@ _longjmp_unwind (jmp_buf env, int val) { char local_var; -#ifdef SHARED - if (__libc_pthread_functions_init) - PTHFCT_CALL (ptr___pthread_cleanup_upto, (env->__jmpbuf, &local_var)); -#else - if (__pthread_cleanup_upto != NULL) - __pthread_cleanup_upto (env->__jmpbuf, &local_var); -#endif + __libc_ptf_call (__pthread_cleanup_upto, (env->__jmpbuf, &local_var), 0); } diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index b377b04e48..5be5d5ad05 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -1299,6 +1299,7 @@ GLIBC_2.2.5 pthread_mutex_init F pthread_mutex_lock F pthread_mutex_unlock F + pthread_once F pthread_self F pthread_setcancelstate F pthread_setcanceltype F diff --git a/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/sysdeps/unix/sysv/linux/x86_64/cancellation.S index 4c34bebc42..52a27dcc5e 100644 --- a/sysdeps/unix/sysv/linux/x86_64/cancellation.S +++ b/sysdeps/unix/sysv/linux/x86_64/cancellation.S @@ -26,7 +26,7 @@ # define __pthread_unwind __GI___pthread_unwind # endif #else -# ifndef SHARED +# if !defined SHARED && !defined HAVE_ASM_SECONDARY_DIRECTIVE .weak __pthread_unwind # endif #endif diff --git a/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S b/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S index 111e9c88ed..cf3f206445 100644 --- a/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S +++ b/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S @@ -16,4 +16,10 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#if IS_IN (libc) && !defined SHARED +/* Allow libpthread.a to override the ones in libc.a. */ + weak_extern (__lll_lock_wait_private) + weak_extern (__lll_unlock_wake_private) +#endif + #include "lowlevellock.S" diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index 5f7032980b..ac95bfa196 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -1448,6 +1448,7 @@ GLIBC_2.16 pthread_mutex_init F pthread_mutex_lock F pthread_mutex_unlock F + pthread_once F pthread_self F pthread_setcancelstate F pthread_setcanceltype F diff --git a/sysdeps/x86_64/localplt.data b/sysdeps/x86_64/localplt.data index d140476dfe..6ca015229d 100644 --- a/sysdeps/x86_64/localplt.data +++ b/sysdeps/x86_64/localplt.data @@ -3,6 +3,18 @@ # users can define their own functions and have library internals call them. # Linker in binutils 2.26 and newer consolidates R_X86_64_JUMP_SLOT # relocation with R_X86_64_GLOB_DAT relocation against the same symbol. +# pthread functions may be preempted by libpthread at run-time. +libc.so: __pthread_getspecific +libc.so: __pthread_key_create +libc.so: __pthread_once +libc.so: __pthread_rwlock_rdlock +libc.so: __pthread_rwlock_unlock +libc.so: __pthread_rwlock_wrlock +libc.so: __pthread_setcancelstate +libc.so: __pthread_setspecific +libc.so: __pthread_unwind +libc.so: _pthread_cleanup_pop_restore +libc.so: _pthread_cleanup_push_defer libc.so: calloc libc.so: free + RELA R_X86_64_GLOB_DAT libc.so: malloc + RELA R_X86_64_GLOB_DAT |