diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-10-18 02:10:41 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-10-18 02:10:41 +0200 |
commit | 05babf965ec39be7e1c8a7306ec1c60b1e614654 (patch) | |
tree | af7f7494e805da3f58312ef3f5a6413a1a907374 | |
parent | f35e6b70ea79b5dc7f5c30dd181b3e7279262bdf (diff) |
Fix unregistering atfork handlers on library unload
* sysdeps/generic/old_pt-atfork.c: New file.
* Makefile (libpthread-routines): Add old_pt-atfork.
(libpthread-static-only-routines): Add pt-atfork.
[build-shared=yes] (install): Explicit $(inst_libdir)/libpthread.so
[build-shared=yes] $(inst_libdir)/libpthread.so: Replace with script to
link libpthread_nonshared.a in.
[build-shared=yes] (tests): Link libpthread_nonshared.a in addition to
libpthread.so.
(generated): Add libpthread_nonshared.a.
-rw-r--r-- | Makeconfig | 3 | ||||
-rw-r--r-- | Makefile | 36 | ||||
-rw-r--r-- | sysdeps/generic/old_pt-atfork.c | 27 |
3 files changed, 65 insertions, 1 deletions
@@ -3,7 +3,8 @@ have-thread-library = yes -shared-thread-library = $(common-objpfx)libpthread/libpthread.so +shared-thread-library = $(common-objpfx)libpthread/libpthread_nonshared.a \ + $(common-objpfx)libpthread/libpthread.so static-thread-library = $(common-objpfx)libpthread/libpthread.a bounded-thread-library = $(static-thread-library) @@ -139,6 +139,7 @@ libpthread-routines := pt-attr pt-attr-destroy pt-attr-getdetachstate \ pt-sigstate \ \ pt-atfork \ + old_pt-atfork \ pt-kill \ pt-getcpuclockid \ \ @@ -154,6 +155,8 @@ libpthread-routines := pt-attr pt-attr-destroy pt-attr-getdetachstate \ cthreads-compat \ $(SYSDEPS) +libpthread-static-only-routines = pt-atfork + ifeq ($(IN_GLIBC),no) SRCS := $(addsuffix .c,$(libpthread-routines)) OBJS = $(addsuffix .o,$(basename $(notdir $(SRCS)))) @@ -281,6 +284,39 @@ extra-B-pthread.so = -B$(common-objpfx)libpthread/ include ../Rules +ifeq (yes,$(build-shared)) +# What we install as libpthread.so for programs to link against is in fact a +# link script. It contains references for the various libraries we need. +# The libpthread.so object is not complete since some functions are only +# defined in libpthread_nonshared.a. +# We need to use absolute paths since otherwise local copies (if they exist) +# of the files are taken by the linker. +install: $(inst_libdir)/libpthread.so + +$(inst_libdir)/libpthread.so: $(common-objpfx)format.lds \ + $(objpfx)libpthread.so$(libpthread.so-version) \ + $(inst_libdir)/$(patsubst %,$(libtype.oS),\ + $(libprefix)pthread) \ + $(+force) + (echo '/* GNU ld script';\ + echo ' Use the shared library, but some functions are only in';\ + echo ' the static library, so try that secondarily. */';\ + cat $<; \ + echo 'GROUP ( $(slibdir)/libpthread.so$(libpthread.so-version)' \ + '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)pthread)'\ + ')' \ + ) > $@.new + mv -f $@.new $@ + +$(addprefix $(objpfx), \ + $(filter-out $(tests-static) $(xtests-static) $(tests-reverse) \ + $(tests-nolibpthread), \ + $(tests) $(xtests) $(test-srcs))): $(objpfx)libpthread.so \ + $(objpfx)libpthread_nonshared.a +endif + +generated += libpthread_nonshared.a + # Depend on libc.so so a DT_NEEDED is generated in the shared objects. # This ensures they will load libc.so for needed symbols if loaded by # a statically-linked program that hasn't already loaded it. diff --git a/sysdeps/generic/old_pt-atfork.c b/sysdeps/generic/old_pt-atfork.c new file mode 100644 index 0000000..5366eaa --- /dev/null +++ b/sysdeps/generic/old_pt-atfork.c @@ -0,0 +1,27 @@ +/* Register fork handlers. Generic version. + Copyright (C) 2002 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <shlib-compat.h> + +#if SHLIB_COMPAT(libpthread, GLIBC_2_12, GLIBC_2_23) +# define pthread_atfork __dyn_pthread_atfork +# include "pt-atfork.c" +# undef pthread_atfork +compat_symbol (libpthread, __dyn_pthread_atfork, pthread_atfork, GLIBC_2_12); +#endif |