]> dgit.raspbian.org Git - glibc.git/commitdiff
cvs-pthread-atfork
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Tue, 18 Oct 2016 21:10:46 +0000 (21:10 +0000)
committerAurelien Jarno <aurel32@debian.org>
Tue, 18 Oct 2016 21:10:46 +0000 (21:10 +0000)
commit 05babf965ec39be7e1c8a7306ec1c60b1e614654
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Tue Oct 18 02:10:41 2016 +0200

    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.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name cvs-pthread-atfork.diff

libpthread/Makeconfig
libpthread/Makefile
libpthread/sysdeps/generic/old_pt-atfork.c [new file with mode: 0644]
libpthread/sysdeps/generic/pt-atfork.c

index 9ce18d38f269e2821bd78b547349c23cae26c8a6..e90f5f7105298c84519ab7543440eb1c62b3e060 100644 (file)
@@ -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)
 
index 21c9b94956ce2d77b92dbba6ea9c47109e2fcd0c..9707f578ad9cc2c19dae1700059552f7de201fb8 100644 (file)
@@ -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/libpthread/sysdeps/generic/old_pt-atfork.c b/libpthread/sysdeps/generic/old_pt-atfork.c
new file mode 100644 (file)
index 0000000..5366eaa
--- /dev/null
@@ -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
index 304d7ef8a89dc55b19c8be9abd862427441ff4c6..df12fc8e86aa24e06a6525b1ce4b0cba269b5f44 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <pthread.h>
 #include <pt-internal.h>
+#include <fork.h>
 
 /* This is defined by newer gcc version unique for each module.  */
 extern void *__dso_handle __attribute__ ((__weak__,