This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch hjl/pthread created. glibc-2.16-ports-merge-340-g79b611a


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, hjl/pthread has been created
        at  79b611a8768151926582b68093086845e1860ddf (commit)

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=79b611a8768151926582b68093086845e1860ddf

commit 79b611a8768151926582b68093086845e1860ddf
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 12 14:30:49 2012 -0700

    Add secondary pthread function to i386 localplt.data

diff --git a/ChangeLog.pthread b/ChangeLog.pthread
index 6de61cd..60c3b79 100644
--- a/ChangeLog.pthread
+++ b/ChangeLog.pthread
@@ -2,6 +2,7 @@
 
 	* scripts/abilist.awk: Support secondary symbols.
 	* sysdeps/generic/localplt.data: Allow pthread functions.
+	* sysdeps/unix/sysv/linux/i386/nptl/localplt.data: Likewise.
 	* sysdeps/unix/sysv/linux/fatal-prepare.h (FATAL_PREPARE): Always
 	call pthread_setcancelstate if HAVE_ASM_SECONDARY_DIRECTIVE is
 	defined.
diff --git a/sysdeps/unix/sysv/linux/i386/nptl/localplt.data b/sysdeps/unix/sysv/linux/i386/nptl/localplt.data
index 8fb56b6..3cad35c 100644
--- a/sysdeps/unix/sysv/linux/i386/nptl/localplt.data
+++ b/sysdeps/unix/sysv/linux/i386/nptl/localplt.data
@@ -1,7 +1,18 @@
+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_setspecific
+libc.so: __pthread_unwind
+libc.so: _pthread_cleanup_pop_restore
+libc.so: _pthread_cleanup_push_defer
 libc.so: _Unwind_Find_FDE
 libc.so: calloc
 libc.so: free
 libc.so: malloc
 libc.so: memalign
+libc.so: pthread_setcancelstate
 libc.so: realloc
 libm.so: matherr

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=625bf7a621af391c29ed70c579415ef5ffc6eb0e

commit 625bf7a621af391c29ed70c579415ef5ffc6eb0e
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 12 14:29:43 2012 -0700

    Add secondary pthread function symbols to abilist

diff --git a/ChangeLog.pthread b/ChangeLog.pthread
index a4560f4..6de61cd 100644
--- a/ChangeLog.pthread
+++ b/ChangeLog.pthread
@@ -5,6 +5,10 @@
 	* sysdeps/unix/sysv/linux/fatal-prepare.h (FATAL_PREPARE): Always
 	call pthread_setcancelstate if HAVE_ASM_SECONDARY_DIRECTIVE is
 	defined.
+	* sysdeps/unix/sysv/linux/i386/nptl/libc.abilist: Add secondary
+	pthread function symbols.
+	* sysdeps/unix/sysv/linux/x86_64/64/nptl/libc.abilist: Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/x32/nptl/libc.abilist: Likewise.
 
 2012-09-11  H.J. Lu  <hongjiu.lu@intel.com>
 
diff --git a/sysdeps/unix/sysv/linux/i386/nptl/libc.abilist b/sysdeps/unix/sysv/linux/i386/nptl/libc.abilist
index 0e8576f..ffa2fec 100644
--- a/sysdeps/unix/sysv/linux/i386/nptl/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/nptl/libc.abilist
@@ -189,6 +189,12 @@ GLIBC_2.0
  __profile_frequency F
  __progname D 0x4
  __progname_full D 0x4
+ __pthread_getspecific F
+ __pthread_key_create F
+ __pthread_mutex_lock F
+ __pthread_mutex_unlock F
+ __pthread_once F
+ __pthread_setspecific F
  __rcmd_errstr D 0x4
  __read F
  __realloc_hook D 0x4
@@ -269,6 +275,8 @@ GLIBC_2.0
  _obstack_free F
  _obstack_memory_used F
  _obstack_newchunk F
+ _pthread_cleanup_pop_restore F
+ _pthread_cleanup_push_defer F
  _res D 0x200
  _rpc_dtablesize F
  _seterr_reply F
@@ -1874,6 +1882,11 @@ GLIBC_2.2
  __lxstat64 F
  __nl_langinfo_l F
  __open64 F
+ __pthread_rwlock_destroy F
+ __pthread_rwlock_init F
+ __pthread_rwlock_rdlock F
+ __pthread_rwlock_unlock F
+ __pthread_rwlock_wrlock F
  __res_init F
  __res_nclose F
  __res_ninit F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/nptl/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/nptl/libc.abilist
index d6ab153..01cdd15 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/nptl/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/nptl/libc.abilist
@@ -369,6 +369,17 @@ GLIBC_2.2.5
  __profile_frequency F
  __progname D 0x8
  __progname_full D 0x8
+ __pthread_getspecific F
+ __pthread_key_create F
+ __pthread_mutex_lock F
+ __pthread_mutex_unlock F
+ __pthread_once F
+ __pthread_rwlock_destroy F
+ __pthread_rwlock_init F
+ __pthread_rwlock_rdlock F
+ __pthread_rwlock_unlock F
+ __pthread_rwlock_wrlock F
+ __pthread_setspecific F
  __pwrite64 F
  __rawmemchr F
  __rcmd_errstr D 0x8
@@ -519,6 +530,8 @@ GLIBC_2.2.5
  _obstack_free F
  _obstack_memory_used F
  _obstack_newchunk F
+ _pthread_cleanup_pop_restore F
+ _pthread_cleanup_push_defer F
  _res D 0x238
  _res_hconf D 0x48
  _rpc_dtablesize F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/nptl/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/nptl/libc.abilist
index 65bcead..7835587 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/nptl/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/nptl/libc.abilist
@@ -341,6 +341,17 @@ GLIBC_2.16
  __profile_frequency F
  __progname D 0x4
  __progname_full D 0x4
+ __pthread_getspecific F
+ __pthread_key_create F
+ __pthread_mutex_lock F
+ __pthread_mutex_unlock F
+ __pthread_once F
+ __pthread_rwlock_destroy F
+ __pthread_rwlock_init F
+ __pthread_rwlock_rdlock F
+ __pthread_rwlock_unlock F
+ __pthread_rwlock_wrlock F
+ __pthread_setspecific F
  __ptsname_r_chk F
  __pwrite64 F
  __rawmemchr F
@@ -543,6 +554,8 @@ GLIBC_2.16
  _obstack_free F
  _obstack_memory_used F
  _obstack_newchunk F
+ _pthread_cleanup_pop_restore F
+ _pthread_cleanup_push_defer F
  _res D 0x200
  _res_hconf D 0x30
  _rpc_dtablesize F

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=850525552fd0768885a1f5075720e1004322b3a6

commit 850525552fd0768885a1f5075720e1004322b3a6
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 12 14:28:50 2012 -0700

    Add 2 tests for PR 14556

diff --git a/nptl/ChangeLog.pthread b/nptl/ChangeLog.pthread
index bc400e3..739f1df 100644
--- a/nptl/ChangeLog.pthread
+++ b/nptl/ChangeLog.pthread
@@ -149,9 +149,12 @@
 2012-09-11  H.J. Lu  <hongjiu.lu@intel.com>
 
 	[BZ #14556]
-	* Makefile (tests-static): Add tst-raise1-static.
+	* Makefile (tests-static): Add tst-cancelx7-static, tst-raise1-static
+	and tst-cancel7-static.
 	(tests): Likewise.
-	* tst-raise1-static.c: New file.
+	* tst-cancel7-static.c: New file.
+	* tst-cancelx7-static.c: Likewise.
+	* tst-raise1-static.c: Likewise.
 	* sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Make
 	__lll_lock_wait_private and __lll_unlock_wake_private weak in
 	libc.a.
diff --git a/nptl/Makefile b/nptl/Makefile
index 73b4434..7d48d3c 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -330,7 +330,8 @@ tests += tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx5 \
 	 tst-cancelx11 tst-cancelx12 tst-cancelx13 tst-cancelx14 tst-cancelx15 \
 	 tst-cancelx16 tst-cancelx17 tst-cancelx18 tst-cancelx20 tst-cancelx21 \
 	 tst-cleanupx0 tst-cleanupx1 tst-cleanupx2 tst-cleanupx3 tst-cleanupx4 \
-	 tst-oncex3 tst-oncex4
+	 tst-oncex3 tst-oncex4 tst-cancelx7-static
+tests-static += tst-cancelx7-static
 endif
 ifeq ($(build-shared),yes)
 tests += tst-atfork2 tst-tls3 tst-tls4 tst-tls5 tst-_res1 tst-fini1 \
@@ -396,8 +397,9 @@ link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
 		    $(common-objpfx)libc.a
 
 tests-static += tst-locale1 tst-locale2 tst-stackguard1-static \
-		tst-cancel21-static tst-raise1-static
-tests += tst-stackguard1-static tst-cancel21-static tst-raise1-static
+		tst-cancel21-static tst-raise1-static tst-cancel7-static
+tests += tst-stackguard1-static tst-cancel21-static tst-raise1-static \
+	 tst-cancel7-static
 xtests-static += tst-setuid1-static
 
 # These tests are linked with libc before libpthread
diff --git a/nptl/tst-cancel7-static.c b/nptl/tst-cancel7-static.c
new file mode 100644
index 0000000..4df1a58
--- /dev/null
+++ b/nptl/tst-cancel7-static.c
@@ -0,0 +1 @@
+#include "tst-cancel7.c"
diff --git a/nptl/tst-cancelx7-static.c b/nptl/tst-cancelx7-static.c
new file mode 100644
index 0000000..a15dfe2
--- /dev/null
+++ b/nptl/tst-cancelx7-static.c
@@ -0,0 +1 @@
+#include "tst-cancelx7.c"

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=dc85a724b597e8c7a51c8a8b8eaeaf2ca72a3ce5

commit dc85a724b597e8c7a51c8a8b8eaeaf2ca72a3ce5
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 12 14:06:12 2012 -0700

    Don't include secondary pthread functions in pthread_functions

diff --git a/nptl/ChangeLog.pthread b/nptl/ChangeLog.pthread
index 8e53a56..bc400e3 100644
--- a/nptl/ChangeLog.pthread
+++ b/nptl/ChangeLog.pthread
@@ -139,6 +139,10 @@
 	(__pthread_cond_signal_2_0): Likewise.
 	(__pthread_cond_timedwait_2_0): Likewise.
 	(__pthread_cond_wait_2_0): Likewise.
+	* sysdeps/pthread/pthread-functions.h (pthread_functions): Don't
+	include secondary pthread functions in libc if
+	HAVE_ASM_SECONDARY_DIRECTIVE is defined.
+	* nptl-init.c (pthread_functions): Likewise.
 	* sysdeps/unix/sysv/linux/x86_64/cancellation.S (__pthread_unwind):
 	Likewise.
 
diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c
index 6a18dbe..00521b9 100644
--- a/nptl/nptl-init.c
+++ b/nptl/nptl-init.c
@@ -80,10 +80,11 @@ static void nptl_freeres (void);
 
 static const struct pthread_functions pthread_functions =
   {
+# ifndef HAVE_ASM_SECONDARY_DIRECTIVE
     .ptr_pthread_attr_destroy = __pthread_attr_destroy,
-# if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)
+#  if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)
     .ptr___pthread_attr_init_2_0 = __pthread_attr_init_2_0,
-# endif
+#  endif
     .ptr___pthread_attr_init_2_1 = __pthread_attr_init_2_1,
     .ptr_pthread_attr_getdetachstate = __pthread_attr_getdetachstate,
     .ptr_pthread_attr_setdetachstate = __pthread_attr_setdetachstate,
@@ -122,7 +123,6 @@ static const struct pthread_functions pthread_functions =
     .ptr_pthread_self = __pthread_self,
     .ptr_pthread_setcancelstate = __pthread_setcancelstate,
     .ptr_pthread_setcanceltype = __pthread_setcanceltype,
-    .ptr___pthread_cleanup_upto = __pthread_cleanup_upto,
     .ptr___pthread_once = __pthread_once,
     .ptr___pthread_rwlock_rdlock = __pthread_rwlock_rdlock,
     .ptr___pthread_rwlock_wrlock = __pthread_rwlock_wrlock,
@@ -132,8 +132,10 @@ static const struct pthread_functions pthread_functions =
     .ptr___pthread_setspecific = __pthread_setspecific,
     .ptr__pthread_cleanup_push_defer = __pthread_cleanup_push_defer,
     .ptr__pthread_cleanup_pop_restore = __pthread_cleanup_pop_restore,
-    .ptr_nthreads = &__nptl_nthreads,
     .ptr___pthread_unwind = &__pthread_unwind,
+# endif
+    .ptr___pthread_cleanup_upto = __pthread_cleanup_upto,
+    .ptr_nthreads = &__nptl_nthreads,
     .ptr__nptl_deallocate_tsd = __nptl_deallocate_tsd,
     .ptr__nptl_setxid = __nptl_setxid,
     /* For now only the stack cache needs to be freed.  */
diff --git a/nptl/sysdeps/pthread/pthread-functions.h b/nptl/sysdeps/pthread/pthread-functions.h
index a1894f4..7651ab2 100644
--- a/nptl/sysdeps/pthread/pthread-functions.h
+++ b/nptl/sysdeps/pthread/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 *);
@@ -77,7 +78,6 @@ struct pthread_functions
   pthread_t (*ptr_pthread_self) (void);
   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);

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=a28e1f037b47d50d8bcec30ece8c70f8edd79517

commit a28e1f037b47d50d8bcec30ece8c70f8edd79517
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 12 13:59:06 2012 -0700

    Build libc-pthread_mutex_destroy/libc-pthread_mutex_init

diff --git a/nptl/Makefile b/nptl/Makefile
index 1c3519d..73b4434 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -58,6 +58,8 @@ libc-libpthread-routines = libc-cleanup_defer_compat \
 			   libc-pthread_getspecific \
 			   libc-pthread_key_create \
 			   libc-pthread_once \
+			   libc-pthread_mutex_destroy \
+			   libc-pthread_mutex_init \
 			   libc-pthread_mutex_lock \
 			   libc-pthread_mutex_unlock \
 			   libc-pthread_rwlock_destroy \

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=9445dea8039931aadcb7b231816b0b9eb5923e6a

commit 9445dea8039931aadcb7b231816b0b9eb5923e6a
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 12 13:58:26 2012 -0700

    Add secondary symbol support to abilist.awk

diff --git a/ChangeLog.pthread b/ChangeLog.pthread
index 0332514..a4560f4 100644
--- a/ChangeLog.pthread
+++ b/ChangeLog.pthread
@@ -1,5 +1,6 @@
 2012-09-12  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* scripts/abilist.awk: Support secondary symbols.
 	* sysdeps/generic/localplt.data: Allow pthread functions.
 	* sysdeps/unix/sysv/linux/fatal-prepare.h (FATAL_PREPARE): Always
 	call pthread_setcancelstate if HAVE_ASM_SECONDARY_DIRECTIVE is
diff --git a/scripts/abilist.awk b/scripts/abilist.awk
index 1c1d41d..a8e30f4 100644
--- a/scripts/abilist.awk
+++ b/scripts/abilist.awk
@@ -38,7 +38,7 @@ $4 == "*UND*" { next }
 $2 == "l" { next }
 
 # If the target uses ST_OTHER, it will be output before the symbol name.
-$2 == "g" || $2 == "w" && (NF == 7 || NF == 8) {
+$2 == "g" || $2 == "w" || $2 == "s" && (NF == 7 || NF == 8) {
   weak = $2;
   type = $3;
   size = $5;

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=68362405b5e008bf8029f0ebd80f1873347d15e3

commit 68362405b5e008bf8029f0ebd80f1873347d15e3
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 12 13:56:49 2012 -0700

    Add secondary pthread_mutex_destroy/pthread_mutex_init

diff --git a/nptl/ChangeLog.pthread b/nptl/ChangeLog.pthread
index f2c631b..8e53a56 100644
--- a/nptl/ChangeLog.pthread
+++ b/nptl/ChangeLog.pthread
@@ -62,6 +62,8 @@
 	* libc-pthread_getschedparam.c: Likewise.
 	* libc-pthread_getspecific.c: Likewise.
 	* libc-pthread_key_create.c: Likewise.
+	* libc-pthread_mutex_destroy.c: Likewise.
+	* libc-pthread_mutex_init.c: Likewise.
 	* libc-pthread_mutex_lock.c: Likewise.
 	* libc-pthread_mutex_unlock.c: Likewise.
 	* libc-pthread_once.c: Likewise.
diff --git a/nptl/libc-pthread_mutex_destroy.c b/nptl/libc-pthread_mutex_destroy.c
new file mode 100644
index 0000000..c19c873
--- /dev/null
+++ b/nptl/libc-pthread_mutex_destroy.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_mutex_destroy");
+
+int
+pthread_mutex_destroy (pthread_mutex_t *mutex)
+{
+  return 0;
+}
+#endif
diff --git a/nptl/libc-pthread_mutex_init.c b/nptl/libc-pthread_mutex_init.c
new file mode 100644
index 0000000..81bd4e6
--- /dev/null
+++ b/nptl/libc-pthread_mutex_init.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_mutex_init");
+
+int
+pthread_mutex_init (pthread_mutex_t *mutex,
+		    const pthread_mutexattr_t *mutexattr)
+{
+  return 0;
+}
+#endif

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=564685e31dbf7790caa4a748b44a7135d4272e50

commit 564685e31dbf7790caa4a748b44a7135d4272e50
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 12 13:06:20 2012 -0700

    Use strong alias for versioned secondary pthread functions

diff --git a/nptl/ChangeLog.pthread b/nptl/ChangeLog.pthread
index d4f61ac..f2c631b 100644
--- a/nptl/ChangeLog.pthread
+++ b/nptl/ChangeLog.pthread
@@ -130,6 +130,13 @@
 	(__pthread_unwind): Likewise.
 	* pthreadP.h (__pthread_unwind): Don't mark it weak if
 	HAVE_ASM_SECONDARY_DIRECTIVE is defined.
+	(__pthread_cond_broadcast_2_0): Declare only if NOT_IN_libc
+	is defined.
+	(__pthread_cond_destroy_2_0): Likewise.
+	(__pthread_cond_init_2_0): Likewise.
+	(__pthread_cond_signal_2_0): Likewise.
+	(__pthread_cond_timedwait_2_0): Likewise.
+	(__pthread_cond_wait_2_0): Likewise.
 	* sysdeps/unix/sysv/linux/x86_64/cancellation.S (__pthread_unwind):
 	Likewise.
 
diff --git a/nptl/Makefile b/nptl/Makefile
index 6d1f871..1c3519d 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -31,7 +31,8 @@ include ../Makeconfig
 routines = alloca_cutoff forward libc-lowlevellock libc-cancellation \
 	   libc-cleanup
 ifeq (yes,$(have-secondary))
-libc-libpthread-routines = libc-pthread_attr_destroy \
+libc-libpthread-routines = libc-cleanup_defer_compat \
+			   libc-pthread_attr_destroy \
 			   libc-pthread_attr_getdetachstate \
 			   libc-pthread_attr_getinheritsched \
 			   libc-pthread_attr_getschedparam \
@@ -51,7 +52,6 @@ libc-libpthread-routines = libc-pthread_attr_destroy \
 			   libc-pthread_cond_wait \
 			   libc-pthread_condattr_destroy \
 			   libc-pthread_condattr_init \
-			   libc-cleanup_defer_compat \
 			   libc-pthread_equal \
 			   libc-pthread_exit \
 			   libc-pthread_getschedparam \
diff --git a/nptl/libc-pthread_attr_init.c b/nptl/libc-pthread_attr_init.c
index cc146e2..382f9fa 100644
--- a/nptl/libc-pthread_attr_init.c
+++ b/nptl/libc-pthread_attr_init.c
@@ -19,21 +19,6 @@
 #include "pthreadP.h"
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_1)
-/* Make sure that it is used only when libpthread is not used  */
-asm (".secondary __pthread_attr_init_2_0");
-
-int
-attribute_compat_text_section
-__pthread_attr_init_2_0 (pthread_attr_t *attr)
-{
-  return 0;
-}
-
-compat_symbol (libc, __pthread_attr_init_2_0, pthread_attr_init,
-	       GLIBC_2_0);
-#endif
-
 /* Make sure that it is used only when libpthread is not used  */
 asm (".secondary __pthread_attr_init_2_1");
 
@@ -45,4 +30,13 @@ __pthread_attr_init_2_1 (pthread_attr_t *attr)
 
 versioned_symbol (libc, __pthread_attr_init_2_1, pthread_attr_init,
 		  GLIBC_2_1);
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_1)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_attr_init_2_0");
+
+strong_alias (__pthread_attr_init_2_1, __pthread_attr_init_2_0)
+compat_symbol (libc, __pthread_attr_init_2_0, pthread_attr_init,
+	       GLIBC_2_0);
+#endif
 #endif
diff --git a/nptl/libc-pthread_cond_broadcast.c b/nptl/libc-pthread_cond_broadcast.c
index 42d4c9c..704cef0 100644
--- a/nptl/libc-pthread_cond_broadcast.c
+++ b/nptl/libc-pthread_cond_broadcast.c
@@ -19,21 +19,6 @@
 #include "pthreadP.h"
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
-/* Make sure that it is used only when libpthread is not used  */
-asm (".secondary __pthread_cond_broadcast_2_0");
-
-int
-attribute_compat_text_section
-__pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond)
-{
-  return 0;
-}
-
-compat_symbol (libc, __pthread_cond_broadcast_2_0,
-	       pthread_cond_broadcast, GLIBC_2_0);
-#endif
-
 /* Make sure that it is used only when libpthread is not used  */
 asm (".secondary __pthread_cond_broadcast");
 
@@ -45,4 +30,13 @@ __pthread_cond_broadcast (pthread_cond_t *cond)
 
 versioned_symbol (libc, __pthread_cond_broadcast,
 		  pthread_cond_broadcast, GLIBC_2_3_2);
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_broadcast_2_0");
+
+strong_alias (__pthread_cond_broadcast, __pthread_cond_broadcast_2_0)
+compat_symbol (libc, __pthread_cond_broadcast_2_0,
+	       pthread_cond_broadcast, GLIBC_2_0);
+#endif
 #endif
diff --git a/nptl/libc-pthread_cond_destroy.c b/nptl/libc-pthread_cond_destroy.c
index 20ea92c..737507e 100644
--- a/nptl/libc-pthread_cond_destroy.c
+++ b/nptl/libc-pthread_cond_destroy.c
@@ -19,21 +19,6 @@
 #include "pthreadP.h"
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
-/* Make sure that it is used only when libpthread is not used  */
-asm (".secondary __pthread_cond_destroy_2_0");
-
-int
-attribute_compat_text_section
-__pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond)
-{
-  return 0;
-}
-
-compat_symbol (libc, __pthread_cond_destroy_2_0, pthread_cond_destroy,
-	       GLIBC_2_0);
-#endif
-
 /* Make sure that it is used only when libpthread is not used  */
 asm (".secondary __pthread_cond_destroy");
 
@@ -45,4 +30,13 @@ __pthread_cond_destroy (pthread_cond_t *cond)
 
 versioned_symbol (libc, __pthread_cond_destroy, pthread_cond_destroy,
 		  GLIBC_2_3_2);
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_destroy_2_0");
+
+strong_alias (__pthread_cond_destroy, __pthread_cond_destroy_2_0)
+compat_symbol (libc, __pthread_cond_destroy_2_0, pthread_cond_destroy,
+	       GLIBC_2_0);
+#endif
 #endif
diff --git a/nptl/libc-pthread_cond_init.c b/nptl/libc-pthread_cond_init.c
index 4684f31..b2f88d8 100644
--- a/nptl/libc-pthread_cond_init.c
+++ b/nptl/libc-pthread_cond_init.c
@@ -19,22 +19,6 @@
 #include "pthreadP.h"
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
-/* Make sure that it is used only when libpthread is not used  */
-asm (".secondary __pthread_cond_init_2_0");
-
-int
-attribute_compat_text_section
-__pthread_cond_init_2_0 (pthread_cond_2_0_t *cond,
-			  const pthread_condattr_t *cond_attr)
-{
-  return 0;
-}
-
-compat_symbol (libc, __pthread_cond_init_2_0, pthread_cond_init,
-	       GLIBC_2_0);
-#endif
-
 /* Make sure that it is used only when libpthread is not used  */
 asm (".secondary __pthread_cond_init");
 
@@ -47,4 +31,13 @@ __pthread_cond_init (pthread_cond_t *cond,
 
 versioned_symbol (libc, __pthread_cond_init, pthread_cond_init,
 		  GLIBC_2_3_2);
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_init_2_0");
+
+strong_alias (__pthread_cond_init, __pthread_cond_init_2_0)
+compat_symbol (libc, __pthread_cond_init_2_0, pthread_cond_init,
+	       GLIBC_2_0);
+#endif
 #endif
diff --git a/nptl/libc-pthread_cond_signal.c b/nptl/libc-pthread_cond_signal.c
index 7fbc840..6623e3b 100644
--- a/nptl/libc-pthread_cond_signal.c
+++ b/nptl/libc-pthread_cond_signal.c
@@ -19,21 +19,6 @@
 #include "pthreadP.h"
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
-/* Make sure that it is used only when libpthread is not used  */
-asm (".secondary __pthread_cond_signal_2_0");
-
-int
-attribute_compat_text_section
-__pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond)
-{
-  return 0;
-}
-
-compat_symbol (libc, __pthread_cond_signal_2_0, pthread_cond_signal,
-	       GLIBC_2_0);
-#endif
-
 /* Make sure that it is used only when libpthread is not used  */
 asm (".secondary __pthread_cond_signal");
 
@@ -45,4 +30,13 @@ __pthread_cond_signal (pthread_cond_t *cond)
 
 versioned_symbol (libc, __pthread_cond_signal, pthread_cond_signal,
 		  GLIBC_2_3_2);
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_signal_2_0");
+
+strong_alias (__pthread_cond_signal, __pthread_cond_signal_2_0)
+compat_symbol (libc, __pthread_cond_signal_2_0, pthread_cond_signal,
+	       GLIBC_2_0);
+#endif
 #endif
diff --git a/nptl/libc-pthread_cond_timedwait.c b/nptl/libc-pthread_cond_timedwait.c
index 3664a43..84baa69 100644
--- a/nptl/libc-pthread_cond_timedwait.c
+++ b/nptl/libc-pthread_cond_timedwait.c
@@ -19,23 +19,6 @@
 #include "pthreadP.h"
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
-/* Make sure that it is used only when libpthread is not used  */
-asm (".secondary __pthread_cond_timedwait_2_0");
-
-int
-attribute_compat_text_section
-__pthread_cond_timedwait_2_0 (pthread_cond_t *cond,
-			      pthread_mutex_t *mutex,
-			      const struct timespec *abstime)
-{
-  return 0;
-}
-
-compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait,
-	       GLIBC_2_0);
-#endif
-
 /* Make sure that it is used only when libpthread is not used  */
 asm (".secondary __pthread_cond_timedwait");
 
@@ -48,4 +31,13 @@ __pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
 
 versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait,
 		  GLIBC_2_3_2);
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_timedwait_2_0");
+
+strong_alias (__pthread_cond_timedwait, __pthread_cond_timedwait_2_0)
+compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait,
+	       GLIBC_2_0);
+#endif
 #endif
diff --git a/nptl/libc-pthread_cond_wait.c b/nptl/libc-pthread_cond_wait.c
index b555e74..f12d911 100644
--- a/nptl/libc-pthread_cond_wait.c
+++ b/nptl/libc-pthread_cond_wait.c
@@ -19,21 +19,6 @@
 #include "pthreadP.h"
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
-/* Make sure that it is used only when libpthread is not used  */
-asm (".secondary __pthread_cond_wait_2_0");
-
-int
-attribute_compat_text_section
-__pthread_cond_wait_2_0 (pthread_cond_t *cond, pthread_mutex_t *mutex)
-{
-  return 0;
-}
-
-compat_symbol (libc, __pthread_cond_wait_2_0, pthread_cond_wait,
-	       GLIBC_2_0);
-#endif
-
 /* Make sure that it is used only when libpthread is not used  */
 asm (".secondary __pthread_cond_wait");
 
@@ -45,4 +30,13 @@ __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex)
 
 versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait,
 		  GLIBC_2_3_2);
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_wait_2_0");
+
+strong_alias (__pthread_cond_wait, __pthread_cond_wait_2_0)
+compat_symbol (libc, __pthread_cond_wait_2_0, pthread_cond_wait,
+	       GLIBC_2_0);
+#endif
 #endif
diff --git a/nptl/libc-pthread_exit.c b/nptl/libc-pthread_exit.c
index c4df3d9..a3a47d7 100644
--- a/nptl/libc-pthread_exit.c
+++ b/nptl/libc-pthread_exit.c
@@ -29,5 +29,5 @@ __pthread_exit (void *retval)
   exit (EXIT_SUCCESS);
 }
 
-strong_alias (__pthread_exit, pthread_exit);
+strong_alias (__pthread_exit, pthread_exit)
 #endif
diff --git a/nptl/libc-pthread_mutex_lock.c b/nptl/libc-pthread_mutex_lock.c
index ece478e..4b0cd04 100644
--- a/nptl/libc-pthread_mutex_lock.c
+++ b/nptl/libc-pthread_mutex_lock.c
@@ -28,5 +28,5 @@ __pthread_mutex_lock (pthread_mutex_t *mutex)
   return 0;
 }
 
-strong_alias (__pthread_mutex_lock, pthread_mutex_lock);
+strong_alias (__pthread_mutex_lock, pthread_mutex_lock)
 #endif
diff --git a/nptl/libc-pthread_mutex_unlock.c b/nptl/libc-pthread_mutex_unlock.c
index 897a198..90ee29a 100644
--- a/nptl/libc-pthread_mutex_unlock.c
+++ b/nptl/libc-pthread_mutex_unlock.c
@@ -28,5 +28,5 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex)
   return 0;
 }
 
-strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock);
+strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock)
 #endif
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 59227f6..330ada4 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -504,6 +504,7 @@ hidden_proto (__pthread_setspecific)
 hidden_proto (__pthread_once)
 #endif
 
+#ifdef NOT_IN_libc
 extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);
 extern int __pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond);
 extern int __pthread_cond_init_2_0 (pthread_cond_2_0_t *cond,
@@ -514,6 +515,7 @@ extern int __pthread_cond_timedwait_2_0 (pthread_cond_2_0_t *cond,
 					 const struct timespec *abstime);
 extern int __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond,
 				    pthread_mutex_t *mutex);
+#endif
 
 extern int __pthread_getaffinity_np (pthread_t th, size_t cpusetsize,
 				     cpu_set_t *cpuset);

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7d4a83acbc59f5aa8341401c5df332ceb8ccae5d

commit 7d4a83acbc59f5aa8341401c5df332ceb8ccae5d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 12 11:31:54 2012 -0700

    Always call secondary pthread functions

diff --git a/ChangeLog.pthread b/ChangeLog.pthread
index 133614b..0332514 100644
--- a/ChangeLog.pthread
+++ b/ChangeLog.pthread
@@ -1,7 +1,6 @@
 2012-09-12  H.J. Lu  <hongjiu.lu@intel.com>
 
-	* sysdeps/generic/localplt.data: Allow __pthread_unwind and
-	pthread_setcancelstate.
+	* sysdeps/generic/localplt.data: Allow pthread functions.
 	* sysdeps/unix/sysv/linux/fatal-prepare.h (FATAL_PREPARE): Always
 	call pthread_setcancelstate if HAVE_ASM_SECONDARY_DIRECTIVE is
 	defined.
diff --git a/nptl/ChangeLog.pthread b/nptl/ChangeLog.pthread
index 2b5a9ab..d4f61ac 100644
--- a/nptl/ChangeLog.pthread
+++ b/nptl/ChangeLog.pthread
@@ -1,5 +1,41 @@
 2012-09-12  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* sysdeps/pthread/bits/libc-lockP.h (__pthread_get_minstack): Mark
+	it as weak if HAVE_ASM_SECONDARY_DIRECTIVE is defined.
+	(__libc_libpthread_is_used): New macro.
+	(PTFAVAIL): Defined as true if HAVE_ASM_SECONDARY_DIRECTIVE is
+	defined.
+	(__libc_maybe_call): Always call FUNC if HAVE_ASM_SECONDARY_DIRECTIVE
+	is defined.
+	(__libc_ptf_call): Likewise.
+	(__libc_ptf_call_always): Likewise.
+	(__rtld_lock_init_recursive): Replace __pthread_mutex_init with
+	__pthread_get_minstack.
+	(__pthread_mutex_init): Don't mark it weak if
+	HAVE_ASM_SECONDARY_DIRECTIVE is defined.
+	(__pthread_mutex_destroy): Likewise.
+	(__pthread_mutex_lock): Likewise.
+	(__pthread_mutex_trylock): Likewise.
+	(__pthread_mutex_unlock): Likewise.
+	(__pthread_mutexattr_init): Likewise.
+	(__pthread_mutexattr_destroy): Likewise.
+	(__pthread_mutexattr_settype): Likewise.
+	(__pthread_rwlock_destroy): Likewise.
+	(__pthread_rwlock_rdlock): Likewise.
+	(__pthread_rwlock_tryrdlock): Likewise.
+	(__pthread_rwlock_wrlock): Likewise.
+	(__pthread_rwlock_trywrlock): Likewise.
+	(__pthread_rwlock_unlock): Likewise.
+	(__pthread_key_create): Likewise.
+	(__pthread_setspecific): Likewise.
+	(__pthread_getspecific): Likewise.
+	(__pthread_once): Likewise.
+	(__pthread_initialize): Likewise.
+	(__pthread_atfork): Likewise.
+	(_pthread_cleanup_push_defer): Likewise.
+	(_pthread_cleanup_pop_restore): Likewise.
+	(pthread_setcancelstate): Likewise.
+
 	* libc-cleanup_defer_compat.c: New file.
 	* libc-pthread_attr_destroy.c: Likewise.
 	* libc-pthread_attr_getdetachstate.c: Likewise.
@@ -92,7 +128,7 @@
 	(pthread_setcancelstate): Likewise.
 	(pthread_setcanceltype): Likewise.
 	(__pthread_unwind): Likewise.
-	* pthreadP.h (__pthread_unwind): Don't mark if weak if
+	* pthreadP.h (__pthread_unwind): Don't mark it weak if
 	HAVE_ASM_SECONDARY_DIRECTIVE is defined.
 	* sysdeps/unix/sysv/linux/x86_64/cancellation.S (__pthread_unwind):
 	Likewise.
diff --git a/nptl/sysdeps/pthread/bits/libc-lockP.h b/nptl/sysdeps/pthread/bits/libc-lockP.h
index 7adaeb4..874fc87 100644
--- a/nptl/sysdeps/pthread/bits/libc-lockP.h
+++ b/nptl/sysdeps/pthread/bits/libc-lockP.h
@@ -98,33 +98,52 @@ 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
+/* Use __pthread_get_minstack to check if libpthread is used.  */
+extern size_t __pthread_get_minstack (const pthread_attr_t *)
+	 __attribute__ ((weak));
+# define __libc_libpthread_is_used __pthread_get_minstack
+
+/* All pthread functions are available.  */
+# define PTFAVAIL(NAME) (true)
+
+/* 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
+# define __libc_libpthread_is_used __pthread_mutex_init
+
 /* 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 && !defined NOT_IN_libc
-# 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) \
-  PTHFCT_CALL (ptr_##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) \
+# if defined SHARED && !defined NOT_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) \
+   PTHFCT_CALL (ptr_##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
 
 
@@ -148,7 +167,7 @@ typedef pthread_key_t __libc_key_t;
 
 #define __rtld_lock_init_recursive(NAME) \
   do {									      \
-    if (__pthread_mutex_init != NULL)					      \
+    if (__libc_libpthread_is_used != NULL)				      \
       {									      \
 	pthread_mutexattr_t __attr;					      \
 	__pthread_mutexattr_init (&__attr);				      \
@@ -384,8 +403,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
 #  include <bp-sym.h>
 weak_extern (BP_SYM (__pthread_mutex_init))
diff --git a/sysdeps/generic/localplt.data b/sysdeps/generic/localplt.data
index 64c8039..752ed89 100644
--- a/sysdeps/generic/localplt.data
+++ b/sysdeps/generic/localplt.data
@@ -1,9 +1,17 @@
 # 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_setcancelstate and __pthread_unwind may be preempted by
-# libpthread at run-time.
+# 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_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

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=6625c395df0bf9f93e5515b0f34297080f8a9dcb

commit 6625c395df0bf9f93e5515b0f34297080f8a9dcb
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 12 11:03:57 2012 -0700

    Execute cleanup rountine if needed

diff --git a/nptl/libc-cleanup_defer_compat.c b/nptl/libc-cleanup_defer_compat.c
index c05b499..ceb01cd 100644
--- a/nptl/libc-cleanup_defer_compat.c
+++ b/nptl/libc-cleanup_defer_compat.c
@@ -34,5 +34,7 @@ void
 _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
 			      int execute)
 {
+  if (execute)
+    buffer->__routine (buffer->__arg);
 }
 #endif

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=17372b7169594f80c57752d3560a5f7677df0e04

commit 17372b7169594f80c57752d3560a5f7677df0e04
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 12 09:04:44 2012 -0700

    Initial secondary pthread functions in libc

diff --git a/ChangeLog.pthread b/ChangeLog.pthread
index 1c78bdd..133614b 100644
--- a/ChangeLog.pthread
+++ b/ChangeLog.pthread
@@ -1,3 +1,11 @@
+2012-09-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* sysdeps/generic/localplt.data: Allow __pthread_unwind and
+	pthread_setcancelstate.
+	* sysdeps/unix/sysv/linux/fatal-prepare.h (FATAL_PREPARE): Always
+	call pthread_setcancelstate if HAVE_ASM_SECONDARY_DIRECTIVE is
+	defined.
+
 2012-09-11  H.J. Lu  <hongjiu.lu@intel.com>
 
 	[BZ #14556]
diff --git a/nptl/ChangeLog.pthread b/nptl/ChangeLog.pthread
index 7752efc..2b5a9ab 100644
--- a/nptl/ChangeLog.pthread
+++ b/nptl/ChangeLog.pthread
@@ -1,3 +1,102 @@
+2012-09-12  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* libc-cleanup_defer_compat.c: New file.
+	* libc-pthread_attr_destroy.c: Likewise.
+	* libc-pthread_attr_getdetachstate.c: Likewise.
+	* libc-pthread_attr_getinheritsched.c: Likewise.
+	* libc-pthread_attr_getschedparam.c: Likewise.
+	* libc-pthread_attr_getschedpolicy.c: Likewise.
+	* libc-pthread_attr_getscope.c: Likewise.
+	* libc-pthread_attr_init.c: Likewise.
+	* libc-pthread_attr_setdetachstate.c: Likewise.
+	* libc-pthread_attr_setinheritsched.c: Likewise.
+	* libc-pthread_attr_setschedparam.c: Likewise.
+	* libc-pthread_attr_setschedpolicy.c: Likewise.
+	* libc-pthread_attr_setscope.c: Likewise.
+	* libc-pthread_cond_broadcast.c: Likewise.
+	* libc-pthread_cond_destroy.c: Likewise.
+	* libc-pthread_cond_init.c: Likewise.
+	* libc-pthread_cond_signal.c: Likewise.
+	* libc-pthread_cond_timedwait.c: Likewise.
+	* libc-pthread_cond_wait.c: Likewise.
+	* libc-pthread_condattr_destroy.c: Likewise.
+	* libc-pthread_condattr_init.c: Likewise.
+	* libc-pthread_equal.c: Likewise.
+	* libc-pthread_exit.c: Likewise.
+	* libc-pthread_getschedparam.c: Likewise.
+	* libc-pthread_getspecific.c: Likewise.
+	* libc-pthread_key_create.c: Likewise.
+	* libc-pthread_mutex_lock.c: Likewise.
+	* libc-pthread_mutex_unlock.c: Likewise.
+	* libc-pthread_once.c: Likewise.
+	* libc-pthread_rwlock_destroy.c: Likewise.
+	* libc-pthread_rwlock_init.c: Likewise.
+	* libc-pthread_rwlock_rdlock.c: Likewise.
+	* libc-pthread_rwlock_unlock.c: Likewise.
+	* libc-pthread_rwlock_wrlock.c: Likewise.
+	* libc-pthread_self.c: Likewise.
+	* libc-pthread_setcancelstate.c: Likewise.
+	* libc-pthread_setcanceltype.c: Likewise.
+	* libc-pthread_setschedparam.c: Likewise.
+	* libc-pthread_setspecific.c: Likewise.
+	* libc-unwind.c: Likewise.
+	* Makefile: Include ../Makeconfig.
+	(libc-libpthread-routines): New.
+	(routines): Add $(libc-libpthread-routines) if $(have-secondary)
+	is yes.
+	* Versions (GLIBC_2.0): Add _pthread_cleanup_pop_restore,
+	_pthread_cleanup_push_defer, __pthread_getspecific,
+	__pthread_setspecific, __pthread_key_create, __pthread_once,
+	__pthread_mutex_lock and __pthread_mutex_unlock.
+	(GLIBC_2.2): Add __pthread_rwlock_init, __pthread_rwlock_destroy,
+	__pthread_rwlock_rdlock, __pthread_rwlock_wrlock and
+	__pthread_rwlock_unlock.
+	(GLIBC_PRIVATE): Add __pthread_unwind.
+	* forward.c (pthread_attr_destroy): Don't define if
+	HAVE_ASM_SECONDARY_DIRECTIVE is defined.
+	(__pthread_attr_init_2_0): Likewise.
+	(__pthread_attr_init_2_1): Likewise.
+	(pthread_attr_getdetachstate): Likewise.
+	(pthread_attr_setdetachstate): Likewise.
+	(pthread_attr_getinheritsched): Likewise.
+	(pthread_attr_setinheritsched): Likewise.
+	(pthread_attr_getschedparam): Likewise.
+	(pthread_attr_setschedparam): Likewise.
+	(pthread_attr_getschedpolicy): Likewise.
+	(pthread_attr_setschedpolicy): Likewise.
+	(pthread_attr_getscope): Likewise.
+	(pthread_attr_setscope): Likewise.
+	(pthread_condattr_destroy): Likewise.
+	(pthread_condattr_init): Likewise.
+	(__pthread_cond_broadcast_2_0): Likewise.
+	(__pthread_cond_broadcast): Likewise.
+	(__pthread_cond_destroy_2_0): Likewise.
+	(__pthread_cond_destroy): Likewise.
+	(__pthread_cond_init_2_0): Likewise.
+	(__pthread_cond_init): Likewise.
+	(__pthread_cond_signal_2_0): Likewise.
+	(__pthread_cond_signal): Likewise.
+	(__pthread_cond_wait_2_0): Likewise.
+	(__pthread_cond_wait): Likewise.
+	(__pthread_cond_timedwait_2_0): Likewise.
+	(__pthread_cond_timedwait): Likewise.
+	(pthread_equal): Likewise.
+	(__pthread_exit): Likewise.
+	(pthread_getschedparam): Likewise.
+	(pthread_setschedparam): Likewise.
+	(pthread_mutex_destroy): Likewise.
+	(pthread_mutex_init): Likewise.
+	(pthread_mutex_lock): Likewise.
+	(pthread_mutex_unlock): Likewise.
+	(pthread_self): Likewise.
+	(pthread_setcancelstate): Likewise.
+	(pthread_setcanceltype): Likewise.
+	(__pthread_unwind): Likewise.
+	* pthreadP.h (__pthread_unwind): Don't mark if weak if
+	HAVE_ASM_SECONDARY_DIRECTIVE is defined.
+	* sysdeps/unix/sysv/linux/x86_64/cancellation.S (__pthread_unwind):
+	Likewise.
+
 2012-09-11  H.J. Lu  <hongjiu.lu@intel.com>
 
 	[BZ #14556]
diff --git a/nptl/Makefile b/nptl/Makefile
index 86cb288..6d1f871 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -26,8 +26,53 @@ extra-libs := libpthread
 extra-libs-others := $(extra-libs)
 install-lib-ldscripts := libpthread.so
 
+include ../Makeconfig
+
 routines = alloca_cutoff forward libc-lowlevellock libc-cancellation \
 	   libc-cleanup
+ifeq (yes,$(have-secondary))
+libc-libpthread-routines = libc-pthread_attr_destroy \
+			   libc-pthread_attr_getdetachstate \
+			   libc-pthread_attr_getinheritsched \
+			   libc-pthread_attr_getschedparam \
+			   libc-pthread_attr_getschedpolicy \
+			   libc-pthread_attr_getscope \
+			   libc-pthread_attr_init \
+			   libc-pthread_attr_setdetachstate \
+			   libc-pthread_attr_setinheritsched \
+			   libc-pthread_attr_setschedparam \
+			   libc-pthread_attr_setschedpolicy \
+			   libc-pthread_attr_setscope \
+			   libc-pthread_cond_broadcast \
+			   libc-pthread_cond_destroy \
+			   libc-pthread_cond_init \
+			   libc-pthread_cond_signal \
+			   libc-pthread_cond_timedwait \
+			   libc-pthread_cond_wait \
+			   libc-pthread_condattr_destroy \
+			   libc-pthread_condattr_init \
+			   libc-cleanup_defer_compat \
+			   libc-pthread_equal \
+			   libc-pthread_exit \
+			   libc-pthread_getschedparam \
+			   libc-pthread_getspecific \
+			   libc-pthread_key_create \
+			   libc-pthread_once \
+			   libc-pthread_mutex_lock \
+			   libc-pthread_mutex_unlock \
+			   libc-pthread_rwlock_destroy \
+			   libc-pthread_rwlock_init \
+			   libc-pthread_rwlock_rdlock \
+			   libc-pthread_rwlock_unlock \
+			   libc-pthread_rwlock_wrlock \
+			   libc-pthread_self \
+			   libc-pthread_setcancelstate \
+			   libc-pthread_setcanceltype \
+			   libc-pthread_setschedparam \
+			   libc-pthread_setspecific \
+			   libc-unwind
+routines += $(libc-libpthread-routines)
+endif
 shared-only-routines = forward
 
 libpthread-routines = nptl-init vars events version \
diff --git a/nptl/Versions b/nptl/Versions
index 6a10375..c96d110 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -16,10 +16,20 @@ libc {
     pthread_mutex_lock; pthread_mutex_unlock;
     pthread_self;
     pthread_setcancelstate; pthread_setcanceltype;
+    _pthread_cleanup_pop_restore; _pthread_cleanup_push_defer;
+    __pthread_getspecific; __pthread_setspecific;
+    __pthread_key_create;
+    __pthread_once;
+    __pthread_mutex_lock; __pthread_mutex_unlock;
   }
   GLIBC_2.1 {
     pthread_attr_init;
   }
+  GLIBC_2.2 {
+    __pthread_rwlock_init; __pthread_rwlock_destroy;
+    __pthread_rwlock_rdlock; __pthread_rwlock_wrlock;
+    __pthread_rwlock_unlock;
+  }
   GLIBC_2.3.2 {
     # Changed pthread_cond_t.
     pthread_cond_init; pthread_cond_destroy;
@@ -30,6 +40,7 @@ libc {
     __libc_alloca_cutoff;
     # Internal libc interface to libpthread
     __libc_dl_error_tsd;
+    __pthread_unwind;
   }
 }
 
diff --git a/nptl/forward.c b/nptl/forward.c
index 67e1402..2d8375f 100644
--- a/nptl/forward.c
+++ b/nptl/forward.c
@@ -31,6 +31,7 @@ struct pthread_functions __libc_pthread_functions attribute_hidden;
 int __libc_pthread_functions_init attribute_hidden;
 
 
+#ifndef HAVE_ASM_SECONDARY_DIRECTIVE
 #define FORWARD2(name, rettype, decl, params, defaction) \
 rettype									      \
 name decl								      \
@@ -210,3 +211,4 @@ FORWARD_NORETURN(__pthread_unwind,
 		       INTERNAL_SYSCALL_DECL (err);
 		       INTERNAL_SYSCALL (kill, err, 1, SIGKILL);
 		     })
+#endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-cleanup_defer_compat.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-cleanup_defer_compat.c
index 4a30822..c05b499 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-cleanup_defer_compat.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,24 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
-
-/* 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);		      \
-  }
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary _pthread_cleanup_push_defer");
+
+void
+_pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
+			     void (*routine) (void *), void *arg)
+{
+}
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary _pthread_cleanup_pop_restore");
+
+void
+_pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
+			      int execute)
+{
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_attr_destroy.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_attr_destroy.c
index 4a30822..21c134d 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_attr_destroy.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_attr_destroy");
+
+int
+pthread_attr_destroy (pthread_attr_t *attr)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_attr_getdetachstate.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_attr_getdetachstate.c
index 4a30822..2a85334 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_attr_getdetachstate.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_attr_getdetachstate");
+
+int
+pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_attr_getinheritsched.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_attr_getinheritsched.c
index 4a30822..03dfe83 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_attr_getinheritsched.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_attr_getinheritsched");
+
+int
+pthread_attr_getinheritsched (const pthread_attr_t *attr, int *inherit)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_attr_getschedparam.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_attr_getschedparam.c
index 4a30822..d3800b2 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_attr_getschedparam.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,16 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_attr_getschedparam");
+
+int
+pthread_attr_getschedparam (const pthread_attr_t *attr,
+			    struct sched_param *param)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_attr_getschedpolicy.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_attr_getschedpolicy.c
index 4a30822..59c1985 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_attr_getschedpolicy.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_attr_getschedpolicy");
+
+int
+pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_attr_getscope.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_attr_getscope.c
index 4a30822..33507bb 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_attr_getscope.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_attr_getscope");
+
+int
+pthread_attr_getscope (const pthread_attr_t *attr, int *scope)
+{
+  return 0;
+}
 #endif
diff --git a/nptl/libc-pthread_attr_init.c b/nptl/libc-pthread_attr_init.c
new file mode 100644
index 0000000..cc146e2
--- /dev/null
+++ b/nptl/libc-pthread_attr_init.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_1)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_attr_init_2_0");
+
+int
+attribute_compat_text_section
+__pthread_attr_init_2_0 (pthread_attr_t *attr)
+{
+  return 0;
+}
+
+compat_symbol (libc, __pthread_attr_init_2_0, pthread_attr_init,
+	       GLIBC_2_0);
+#endif
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_attr_init_2_1");
+
+int
+__pthread_attr_init_2_1 (pthread_attr_t *attr)
+{
+  return 0;
+}
+
+versioned_symbol (libc, __pthread_attr_init_2_1, pthread_attr_init,
+		  GLIBC_2_1);
+#endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_attr_setdetachstate.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_attr_setdetachstate.c
index 4a30822..5dd5dbd 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_attr_setdetachstate.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_attr_setdetachstate");
+
+int
+pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_attr_setinheritsched.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_attr_setinheritsched.c
index 4a30822..ce32a47 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_attr_setinheritsched.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_attr_setinheritsched");
+
+int
+pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_attr_setschedparam.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_attr_setschedparam.c
index 4a30822..c6a5486 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_attr_setschedparam.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,16 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_attr_setschedparam");
+
+int
+pthread_attr_setschedparam (pthread_attr_t *attr,
+			    const struct sched_param *param)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_attr_setschedpolicy.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_attr_setschedpolicy.c
index 4a30822..9311027 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_attr_setschedpolicy.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_attr_setschedpolicy");
+
+int
+pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_attr_setscope.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_attr_setscope.c
index 4a30822..5937dd2 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_attr_setscope.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_attr_setscope");
+
+int
+pthread_attr_setscope (pthread_attr_t *attr, int scope)
+{
+  return 0;
+}
 #endif
diff --git a/nptl/libc-pthread_cond_broadcast.c b/nptl/libc-pthread_cond_broadcast.c
new file mode 100644
index 0000000..42d4c9c
--- /dev/null
+++ b/nptl/libc-pthread_cond_broadcast.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_broadcast_2_0");
+
+int
+attribute_compat_text_section
+__pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond)
+{
+  return 0;
+}
+
+compat_symbol (libc, __pthread_cond_broadcast_2_0,
+	       pthread_cond_broadcast, GLIBC_2_0);
+#endif
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_broadcast");
+
+int
+__pthread_cond_broadcast (pthread_cond_t *cond)
+{
+  return 0;
+}
+
+versioned_symbol (libc, __pthread_cond_broadcast,
+		  pthread_cond_broadcast, GLIBC_2_3_2);
+#endif
diff --git a/nptl/libc-pthread_cond_destroy.c b/nptl/libc-pthread_cond_destroy.c
new file mode 100644
index 0000000..20ea92c
--- /dev/null
+++ b/nptl/libc-pthread_cond_destroy.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_destroy_2_0");
+
+int
+attribute_compat_text_section
+__pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond)
+{
+  return 0;
+}
+
+compat_symbol (libc, __pthread_cond_destroy_2_0, pthread_cond_destroy,
+	       GLIBC_2_0);
+#endif
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_destroy");
+
+int
+__pthread_cond_destroy (pthread_cond_t *cond)
+{
+  return 0;
+}
+
+versioned_symbol (libc, __pthread_cond_destroy, pthread_cond_destroy,
+		  GLIBC_2_3_2);
+#endif
diff --git a/nptl/libc-pthread_cond_init.c b/nptl/libc-pthread_cond_init.c
new file mode 100644
index 0000000..4684f31
--- /dev/null
+++ b/nptl/libc-pthread_cond_init.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_init_2_0");
+
+int
+attribute_compat_text_section
+__pthread_cond_init_2_0 (pthread_cond_2_0_t *cond,
+			  const pthread_condattr_t *cond_attr)
+{
+  return 0;
+}
+
+compat_symbol (libc, __pthread_cond_init_2_0, pthread_cond_init,
+	       GLIBC_2_0);
+#endif
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_init");
+
+int
+__pthread_cond_init (pthread_cond_t *cond,
+		     const pthread_condattr_t *cond_attr)
+{
+  return 0;
+}
+
+versioned_symbol (libc, __pthread_cond_init, pthread_cond_init,
+		  GLIBC_2_3_2);
+#endif
diff --git a/nptl/libc-pthread_cond_signal.c b/nptl/libc-pthread_cond_signal.c
new file mode 100644
index 0000000..7fbc840
--- /dev/null
+++ b/nptl/libc-pthread_cond_signal.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_signal_2_0");
+
+int
+attribute_compat_text_section
+__pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond)
+{
+  return 0;
+}
+
+compat_symbol (libc, __pthread_cond_signal_2_0, pthread_cond_signal,
+	       GLIBC_2_0);
+#endif
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_signal");
+
+int
+__pthread_cond_signal (pthread_cond_t *cond)
+{
+  return 0;
+}
+
+versioned_symbol (libc, __pthread_cond_signal, pthread_cond_signal,
+		  GLIBC_2_3_2);
+#endif
diff --git a/nptl/libc-pthread_cond_timedwait.c b/nptl/libc-pthread_cond_timedwait.c
new file mode 100644
index 0000000..3664a43
--- /dev/null
+++ b/nptl/libc-pthread_cond_timedwait.c
@@ -0,0 +1,51 @@
+/* Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_timedwait_2_0");
+
+int
+attribute_compat_text_section
+__pthread_cond_timedwait_2_0 (pthread_cond_t *cond,
+			      pthread_mutex_t *mutex,
+			      const struct timespec *abstime)
+{
+  return 0;
+}
+
+compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait,
+	       GLIBC_2_0);
+#endif
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_timedwait");
+
+int
+__pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
+			  const struct timespec *abstime)
+{
+  return 0;
+}
+
+versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait,
+		  GLIBC_2_3_2);
+#endif
diff --git a/nptl/libc-pthread_cond_wait.c b/nptl/libc-pthread_cond_wait.c
new file mode 100644
index 0000000..b555e74
--- /dev/null
+++ b/nptl/libc-pthread_cond_wait.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_wait_2_0");
+
+int
+attribute_compat_text_section
+__pthread_cond_wait_2_0 (pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+  return 0;
+}
+
+compat_symbol (libc, __pthread_cond_wait_2_0, pthread_cond_wait,
+	       GLIBC_2_0);
+#endif
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_cond_wait");
+
+int
+__pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+  return 0;
+}
+
+versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait,
+		  GLIBC_2_3_2);
+#endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_condattr_destroy.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_condattr_destroy.c
index 4a30822..e1d8f02 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_condattr_destroy.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_condattr_destroy");
+
+int
+pthread_condattr_destroy (pthread_condattr_t *attr)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_condattr_init.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_condattr_init.c
index 4a30822..4a9fc1a 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_condattr_init.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_condattr_init");
+
+int
+pthread_condattr_init (pthread_condattr_t *attr)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_equal.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_equal.c
index 4a30822..acefaf7 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_equal.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_equal");
+
+int
+pthread_equal (pthread_t thread1, pthread_t thread2)
+{
+  return 1;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_exit.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_exit.c
index 4a30822..c4df3d9 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_exit.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,19 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include <stdlib.h>
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_exit");
+asm (".secondary pthread_exit");
+
+void
+__pthread_exit (void *retval)
+{
+  exit (EXIT_SUCCESS);
+}
+
+strong_alias (__pthread_exit, pthread_exit);
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_getschedparam.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_getschedparam.c
index 4a30822..167491b 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_getschedparam.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,16 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_getschedparam");
+
+int
+pthread_getschedparam (pthread_t target_thread, int *policy,
+		       struct sched_param *param)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_getspecific.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_getspecific.c
index 4a30822..abd8cf9 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_getspecific.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,17 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include <stdlib.h>
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_getspecific");
+
+void *
+__pthread_getspecific (pthread_key_t key)
+{
+  /* Not valid.  */
+  return NULL;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_key_create.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_key_create.c
index 4a30822..7ff0450 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_key_create.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,16 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include <errno.h>
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_key_create");
+
+int
+__pthread_key_create (pthread_key_t *key, void (*destr) (void *))
+{
+  return EINVAL;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_mutex_lock.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_mutex_lock.c
index 4a30822..ece478e 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_mutex_lock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,18 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_mutex_lock");
+asm (".secondary pthread_mutex_lock");
+
+int
+__pthread_mutex_lock (pthread_mutex_t *mutex)
+{
+  return 0;
+}
+
+strong_alias (__pthread_mutex_lock, pthread_mutex_lock);
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_mutex_unlock.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_mutex_unlock.c
index 4a30822..897a198 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_mutex_unlock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,18 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_mutex_unlock");
+asm (".secondary pthread_mutex_unlock");
+
+int
+__pthread_mutex_unlock (pthread_mutex_t *mutex)
+{
+  return 0;
+}
+
+strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock);
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_once.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_once.c
index 4a30822..ba2574d 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_once.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,21 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_once");
+
+int
+__pthread_once (pthread_once_t *once_control,
+		void (*init_routine) (void))
+{
+  if (*once_control == PTHREAD_ONCE_INIT)
+    {
+      init_routine ();
+      *once_control |= 2;
+    }
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_rwlock_destroy.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_rwlock_destroy.c
index 4a30822..e9a99e9 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_rwlock_destroy.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_rwlock_destroy");
+
+int
+__pthread_rwlock_destroy (pthread_rwlock_t *rwlock)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_rwlock_init.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_rwlock_init.c
index 4a30822..460f581 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_rwlock_init.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,16 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_rwlock_init");
+
+int
+__pthread_rwlock_init (pthread_rwlock_t *rwlock,
+		       const pthread_rwlockattr_t *attr)
+{
+  return 0;
+}
 #endif
diff --git a/nptl/libc-pthread_rwlock_rdlock.c b/nptl/libc-pthread_rwlock_rdlock.c
new file mode 100644
index 0000000..7c81392
--- /dev/null
+++ b/nptl/libc-pthread_rwlock_rdlock.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_rwlock_rdlock");
+
+int
+__pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
+{
+  return 0;
+}
+#endif
diff --git a/nptl/libc-pthread_rwlock_unlock.c b/nptl/libc-pthread_rwlock_unlock.c
new file mode 100644
index 0000000..dcacefd
--- /dev/null
+++ b/nptl/libc-pthread_rwlock_unlock.c
@@ -0,0 +1,29 @@
+/* Copyright (C) 2012 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_rwlock_unlock");
+
+int
+__pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
+{
+  return 0;
+}
+#endif
diff --git a/nptl/libc-pthread_rwlock_wrlock.c b/nptl/libc-pthread_rwlock_wrlock.c
new file mode 100644
index 0000000..8f67b93
--- /dev/null
+++ b/nptl/libc-pthread_rwlock_wrlock.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 2003-2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_rwlock_wrlock");
+
+int
+__pthread_rwlock_wrlock (pthread_rwlock_t *rwlock)
+{
+  return 0;
+}
+#endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_self.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_self.c
index 4a30822..0f4359a 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_self.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_self");
+
+pthread_t
+pthread_self (void)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_setcancelstate.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_setcancelstate.c
index 4a30822..b0aa47c 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_setcancelstate.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,16 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include <errno.h>
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_setcancelstate");
+
+int
+pthread_setcancelstate (int state, int *oldstate)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_setcanceltype.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_setcanceltype.c
index 4a30822..a532c25 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_setcanceltype.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_setcanceltype");
+
+int
+pthread_setcanceltype (int type, int *oldtype)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_setschedparam.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_setschedparam.c
index 4a30822..d0aa05d 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_setschedparam.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,16 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary pthread_setschedparam");
+
+int
+pthread_setschedparam (pthread_t target_thread, int policy,
+		       const struct sched_param *param)
+{
+  return 0;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-pthread_setspecific.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-pthread_setspecific.c
index 4a30822..b454c1a 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-pthread_setspecific.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,17 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include <errno.h>
+#include "pthreadP.h"
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_setspecific");
+
+int
+__pthread_setspecific (pthread_key_t key, const void *value)
+{
+  /* Not valid.  */
+  return EINVAL;
+}
 #endif
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/nptl/libc-unwind.c
similarity index 52%
copy from sysdeps/unix/sysv/linux/fatal-prepare.h
copy to nptl/libc-unwind.c
index 4a30822..c624052 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/nptl/libc-unwind.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2012 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
@@ -15,23 +15,21 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <pthread.h>
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+#include "pthreadP.h"
+#include <sysdep.h>
 
-/* 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);		      \
-  }
+/* Make sure that it is used only when libpthread is not used  */
+asm (".secondary __pthread_unwind");
+
+void
+__attribute ((noreturn))
+__cleanup_fct_attribute
+attribute_compat_text_section
+__pthread_unwind (__pthread_unwind_buf_t *buf)
+{
+  /* We cannot call abort() here.  */
+  INTERNAL_SYSCALL_DECL (err);
+  INTERNAL_SYSCALL (kill, err, 1, SIGKILL);
+}
 #endif
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index fa89cbf..59227f6 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -225,7 +225,8 @@ extern int __pthread_debug attribute_hidden;
 
 extern void __pthread_unwind (__pthread_unwind_buf_t *__buf)
      __cleanup_fct_attribute __attribute ((__noreturn__))
-#if !defined SHARED && !defined IS_IN_libpthread
+#if !defined SHARED && !defined IS_IN_libpthread \
+     && !defined HAVE_ASM_SECONDARY_DIRECTIVE
      weak_function
 #endif
      ;
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
index 31bb08b..027368c 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
+++ b/nptl/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/generic/localplt.data b/sysdeps/generic/localplt.data
index d296519..64c8039 100644
--- a/sysdeps/generic/localplt.data
+++ b/sysdeps/generic/localplt.data
@@ -1,9 +1,13 @@
 # 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_setcancelstate and __pthread_unwind may be preempted by
+# libpthread at run-time.
+libc.so: __pthread_unwind
 libc.so: calloc
 libc.so: free
 libc.so: malloc
 libc.so: memalign
+libc.so: pthread_setcancelstate
 libc.so: realloc
 libm.so: matherr
diff --git a/sysdeps/unix/sysv/linux/fatal-prepare.h b/sysdeps/unix/sysv/linux/fatal-prepare.h
index 4a30822..db31630 100644
--- a/sysdeps/unix/sysv/linux/fatal-prepare.h
+++ b/sysdeps/unix/sysv/linux/fatal-prepare.h
@@ -19,19 +19,23 @@
 
 /* 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));			      \
-  }
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+# define FATAL_PREPARE pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL);
 #else
-# pragma weak pthread_setcancelstate
-# define FATAL_PREPARE \
-  {									      \
-    if (pthread_setcancelstate != NULL)					      \
-      pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL);		      \
-  }
+# 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
 #endif

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=de0e2600f62ac9d475631e1eed0ac19926196184

commit de0e2600f62ac9d475631e1eed0ac19926196184
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Sep 11 06:23:28 2012 -0700

    Make __pthread_initialize_minimal in libc.a seondary

diff --git a/ChangeLog.pthread b/ChangeLog.pthread
new file mode 100644
index 0000000..1c78bdd
--- /dev/null
+++ b/ChangeLog.pthread
@@ -0,0 +1,5 @@
+2012-09-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+	[BZ #14556]
+	* csu/libc-tls.c (__pthread_initialize_minimal): Mark it
+	secondary if HAVE_ASM_SECONDARY_DIRECTIVE is defined.
diff --git a/csu/libc-tls.c b/csu/libc-tls.c
index 9bc4d84..2d6f181 100644
--- a/csu/libc-tls.c
+++ b/csu/libc-tls.c
@@ -239,6 +239,11 @@ _dl_tls_setup (void)
 }
 
 
+#ifdef HAVE_ASM_SECONDARY_DIRECTIVE
+/* Make sure that it is used only when libpthread.a is not used  */
+asm (".secondary __pthread_initialize_minimal");
+#endif
+
 /* This is the minimal initialization function used when libpthread is
    not used.  */
 void
diff --git a/nptl/ChangeLog.pthread b/nptl/ChangeLog.pthread
new file mode 100644
index 0000000..7752efc
--- /dev/null
+++ b/nptl/ChangeLog.pthread
@@ -0,0 +1,11 @@
+2012-09-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+	[BZ #14556]
+	* Makefile (tests-static): Add tst-raise1-static.
+	(tests): Likewise.
+	* tst-raise1-static.c: New file.
+	* sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Make
+	__lll_lock_wait_private and __lll_unlock_wake_private weak in
+	libc.a.
+	* sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S: Likewise.
+	* sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S: Likewise.
diff --git a/nptl/Makefile b/nptl/Makefile
index 6f2b66c..86cb288 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -349,8 +349,8 @@ link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
 		    $(common-objpfx)libc.a
 
 tests-static += tst-locale1 tst-locale2 tst-stackguard1-static \
-		tst-cancel21-static
-tests += tst-stackguard1-static tst-cancel21-static
+		tst-cancel21-static tst-raise1-static
+tests += tst-stackguard1-static tst-cancel21-static tst-raise1-static
 xtests-static += tst-setuid1-static
 
 # These tests are linked with libc before libpthread
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
index 74dda47..60e0e0d 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -16,4 +16,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#if !defined NOT_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/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S
index 3214c29..e9ac47f 100644
--- a/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S
+++ b/nptl/sysdeps/unix/sysv/linux/sh/libc-lowlevellock.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2012 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
@@ -15,4 +15,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#if !defined NOT_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/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S
index 74dda47..60e0e0d 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/libc-lowlevellock.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -16,4 +16,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#if !defined NOT_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/nptl/tst-raise1-static.c b/nptl/tst-raise1-static.c
new file mode 100644
index 0000000..f25ad50
--- /dev/null
+++ b/nptl/tst-raise1-static.c
@@ -0,0 +1 @@
+#include "tst-raise1.c"

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=3e9845e1b211ff2aae9cd5e27014536942f13cf0

commit 3e9845e1b211ff2aae9cd5e27014536942f13cf0
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Sep 11 05:10:03 2012 -0700

    Place libpthread.a right before libc.a

diff --git a/ChangeLog.pr14569 b/ChangeLog.pr14569
new file mode 100644
index 0000000..05d42b8
--- /dev/null
+++ b/ChangeLog.pr14569
@@ -0,0 +1,6 @@
+2012-09-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+	[BZ #14569]
+	* Makeconfig (+link-static-before-libc): Also filter out
+	$(common-objpfx)nptl/libpthread%.  Remove $(link-libc-static).
+	(link-libc-static-tests): Place libpthread.a before libc.a.
diff --git a/Makeconfig b/Makeconfig
index 3ed9746..8573643 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -449,8 +449,9 @@ ifndef +link-static
 	      $(filter-out $(addprefix $(csu-objpfx),start.o \
 						     $(start-installed-name))\
 			   $(+preinit) $(link-extra-libs-static) \
+			   $(common-objpfx)nptl/libpthread% \
 			   $(common-objpfx)libc% $(+postinit),$^) \
-	      $(link-extra-libs-static) $(link-libc-static)
+	      $(link-extra-libs-static)
 +link-static-after-libc = $(+postctorT) $(+postinit)
 +link-static = $(+link-static-before-libc) $(link-libc-static) \
 	       $(+link-static-after-libc)
@@ -520,7 +521,12 @@ endif
 
 # The static libraries.
 link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
-link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib-tests) -Wl,--end-group
+# libpthread.a must be placed before libc.a between -start-group and
+# --end-group.
+link-libc-static-tests = -Wl,--start-group \
+			 $(filter $(common-objpfx)nptl/libpthread.a,$^) \
+			 $(common-objpfx)libc.a \
+			 $(static-gnulib-tests) -Wl,--end-group
 link-libc-bounded = $(common-objpfx)libc_b.a $(gnulib) $(common-objpfx)libc_b.a
 
 # How to link against libgcc.  Some libgcc functions, such as those

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=bb1ed73765632a0bfd2d6c9870d27c879440ba5d

commit bb1ed73765632a0bfd2d6c9870d27c879440ba5d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jul 4 07:55:52 2012 -0700

    Add 3 STB_SECONDARY tests

diff --git a/ChangeLog.second b/ChangeLog.second
index 4435ddb..17e32e6 100644
--- a/ChangeLog.second
+++ b/ChangeLog.second
@@ -1,5 +1,24 @@
 2012-09-06  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* elf/Makefile (tests): Add tst-secondary1 tst-secondary2
+	tst-secondary3 if STB_SECONDARY is supported by as/ld.
+	(modules-names): Add tst-secondarymod tst-secondary1mod
+	tst-secondary2mod tst-secondary3mod if STB_SECONDARY is supported
+	by as/ld.
+	(LDFLAGS-tst-secondarymod.so): New macro.
+	($(objpfx)tst-secondary1): New rule.
+	($(objpfx)tst-secondary2): Likewise.
+	($(objpfx)tst-secondary3): Likewise.
+
+	* elf/tst-secondary.h: New file.
+	* elf/tst-secondary1.c: Likewise.
+	* elf/tst-secondary1mod.c: Likewise.
+	* elf/tst-secondary2.c: Likewise.
+	* elf/tst-secondary2mod.c: Likewise.
+	* elf/tst-secondary3.c: Likewise.
+	* elf/tst-secondary3mod.c: Likewise.
+	* elf/tst-secondarymod.c: Likewise.
+
 	* config.h.in: Add HAVE_ASM_SECONDARY_DIRECTIVE.
 	* config.make.in (have-secondary): New macro.
 	* configure.in: Check if STB_SECONDARY is supported by as/ld.
diff --git a/elf/Makefile b/elf/Makefile
index b999376..4beb416 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -261,6 +261,11 @@ modules-names += ifuncmod1 ifuncmod3 ifuncmod5 ifuncmod6
 endif
 endif
 
+ifeq (yes,$(have-secondary))
+tests += tst-secondary1 tst-secondary2 tst-secondary3
+modules-names += tst-secondarymod tst-secondary1mod tst-secondary2mod \
+		 tst-secondary3mod
+endif
 
 include ../Rules
 
@@ -1103,6 +1108,17 @@ $(objpfx)ifuncmain5static: $(addprefix $(objpfx),ifuncdep5.o)
 $(objpfx)ifuncmain5staticpic: $(addprefix $(objpfx),ifuncdep5pic.o)
 $(objpfx)ifuncmain5picstatic: $(addprefix $(objpfx),ifuncdep5pic.o)
 
+LDFLAGS-tst-secondarymod.so = -Wl,-z,secondary
+
+$(objpfx)tst-secondary1: $(objpfx)tst-secondarymod.so \
+			 $(objpfx)tst-secondary1mod.so
+
+$(objpfx)tst-secondary2: $(objpfx)tst-secondarymod.so \
+			 $(objpfx)tst-secondary2mod.so
+
+$(objpfx)tst-secondary3: $(objpfx)tst-secondarymod.so \
+			 $(objpfx)tst-secondary3mod.so
+
 $(objpfx)tst-unique1: $(libdl)
 $(objpfx)tst-unique1.out: $(objpfx)tst-unique1mod1.so \
 			  $(objpfx)tst-unique1mod2.so
diff --git a/elf/tst-secondary.h b/elf/tst-secondary.h
new file mode 100644
index 0000000..0487e25
--- /dev/null
+++ b/elf/tst-secondary.h
@@ -0,0 +1,3 @@
+#define GLOBAL		1
+#define WEAK		2
+#define SECONDARY	3
diff --git a/elf/tst-secondary1.c b/elf/tst-secondary1.c
new file mode 100644
index 0000000..f4d6edd
--- /dev/null
+++ b/elf/tst-secondary1.c
@@ -0,0 +1,13 @@
+/* Verify that secdonary function is called.  */
+
+#include "tst-secondary.h"
+
+extern int bar (void);
+extern void foo (void);
+
+int
+main (void)
+{
+  foo ();
+  return bar () != SECONDARY;
+}
diff --git a/elf/tst-secondary1mod.c b/elf/tst-secondary1mod.c
new file mode 100644
index 0000000..cd0130c
--- /dev/null
+++ b/elf/tst-secondary1mod.c
@@ -0,0 +1,4 @@
+void
+foo (void)
+{
+}
diff --git a/elf/tst-secondary2.c b/elf/tst-secondary2.c
new file mode 100644
index 0000000..3f221cb
--- /dev/null
+++ b/elf/tst-secondary2.c
@@ -0,0 +1,13 @@
+/* Verify that global function is called.  */
+
+#include "tst-secondary.h"
+
+extern int bar (void);
+extern void foo (void);
+
+int
+main (void)
+{
+  foo ();
+  return bar () != GLOBAL;
+}
diff --git a/elf/tst-secondary2mod.c b/elf/tst-secondary2mod.c
new file mode 100644
index 0000000..f9407a9
--- /dev/null
+++ b/elf/tst-secondary2mod.c
@@ -0,0 +1,12 @@
+#include "tst-secondary.h"
+
+int
+bar (void)
+{
+  return GLOBAL;
+}
+
+void
+foo (void)
+{
+}
diff --git a/elf/tst-secondary3.c b/elf/tst-secondary3.c
new file mode 100644
index 0000000..b55baea
--- /dev/null
+++ b/elf/tst-secondary3.c
@@ -0,0 +1,13 @@
+/* Verify that weak function is called.  */
+
+#include "tst-secondary.h"
+
+extern int bar (void);
+extern void foo (void);
+
+int
+main (void)
+{
+  foo ();
+  return bar () != WEAK;
+}
diff --git a/elf/tst-secondary3mod.c b/elf/tst-secondary3mod.c
new file mode 100644
index 0000000..edfb25b
--- /dev/null
+++ b/elf/tst-secondary3mod.c
@@ -0,0 +1,13 @@
+#include "tst-secondary.h"
+
+int
+__attribute__ ((weak))
+bar (void)
+{
+  return WEAK;
+}
+
+void
+foo (void)
+{
+}
diff --git a/elf/tst-secondarymod.c b/elf/tst-secondarymod.c
new file mode 100644
index 0000000..5363e99
--- /dev/null
+++ b/elf/tst-secondarymod.c
@@ -0,0 +1,9 @@
+#include "tst-secondary.h"
+
+asm (".secondary bar");
+
+int
+bar (void)
+{
+  return SECONDARY;
+}

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=8dc3dce7c78a2185c390656871cfede17a02ac9c

commit 8dc3dce7c78a2185c390656871cfede17a02ac9c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Sep 9 14:38:37 2012 -0700

    Check if STB_SECONDARY is supported by as/ld

diff --git a/ChangeLog.second b/ChangeLog.second
index ad3eba0..4435ddb 100644
--- a/ChangeLog.second
+++ b/ChangeLog.second
@@ -1,3 +1,12 @@
+2012-09-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* config.h.in: Add HAVE_ASM_SECONDARY_DIRECTIVE.
+	* config.make.in (have-secondary): New macro.
+	* configure.in: Check if STB_SECONDARY is supported by as/ld.
+	Define HAVE_ASM_SECONDARY_DIRECTIVE and set have-secondary to yes
+	if the .secondary assembly directive works.
+	* configure: Regenerated.
+
 2012-06-30  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* elf/dl-addr.c (determine_info): Also check STB_SECONDARY.
diff --git a/config.h.in b/config.h.in
index 10a9925..855dc39 100644
--- a/config.h.in
+++ b/config.h.in
@@ -24,6 +24,10 @@
 /* Define if weak symbols are available via the `.weakext' directive.  */
 #undef	HAVE_ASM_WEAKEXT_DIRECTIVE
 
+/* Define if secondary symbols are available via the `.secondary'
+   directive.  */
+#undef	HAVE_ASM_SECONDARY_DIRECTIVE
+
 /* Define if CFI directives are available.  */
 #undef	HAVE_ASM_CFI_DIRECTIVES
 
diff --git a/config.make.in b/config.make.in
index d84fe38..4e69798 100644
--- a/config.make.in
+++ b/config.make.in
@@ -59,6 +59,7 @@ have-cpp-asm-debuginfo = @libc_cv_cpp_asm_debuginfo@
 have-forced-unwind = @libc_cv_forced_unwind@
 have-fpie = @libc_cv_fpie@
 have-mfma4 = @libc_cv_cc_fma4@
+have-secondary = @libc_cv_ld_secondary@
 have-as-vis3 = @libc_cv_sparc_as_vis3@
 gnu89-inline-CFLAGS = @gnu89_inline@
 have-ssp = @libc_cv_ssp@
diff --git a/configure b/configure
index d159ce0..65c29e9 100755
--- a/configure
+++ b/configure
@@ -608,6 +608,7 @@ have_libaudit
 LIBGD
 libc_cv_cc_submachine
 exceptions
+libc_cv_ld_secondary
 gnu89_inline
 libc_cv_ssp
 fno_unit_at_a_time
@@ -6725,8 +6726,10 @@ if { ac_try='${CC-cc} $ASFLAGS -c conftest.s 1>&5'
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; }; then
   libc_cv_asm_weak_directive=yes
+  libc_cv_asm_weak=.weak
 else
   libc_cv_asm_weak_directive=no
+  libc_cv_asm_weak=
 fi
 rm -f conftest*
 fi
@@ -6755,6 +6758,7 @@ EOF
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; }; then
     libc_cv_asm_weakext_directive=yes
+  libc_cv_asm_weak=.weakext
   else
     libc_cv_asm_weakext_directive=no
   fi
@@ -6773,6 +6777,71 @@ elif test $libc_cv_asm_weakext_directive = yes; then
 
 fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for .secondary assembler directive" >&5
+$as_echo_n "checking for .secondary assembler directive... " >&6; }
+if ${libc_cv_asm_secondary_directive+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.s <<EOF
+${libc_cv_dot_text}
+_sym:
+.secondary _sym
+EOF
+test -n "$libc_cv_asm_weak" && cat >> conftest.s <<EOF
+$libc_cv_asm_weak _sym
+EOF
+if ${CC-cc} -c $ASFLAGS -o conftest.o conftest.s 1>&5 2>&5; then
+  if $READELF -s conftest.o | fgrep _sym | fgrep SECOND > /dev/null; then
+    libc_cv_asm_secondary_directive=yes
+  else
+    libc_cv_asm_secondary_directive=no
+  fi
+else
+  libc_cv_asm_secondary_directive=no
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_asm_secondary_directive" >&5
+$as_echo "$libc_cv_asm_secondary_directive" >&6; }
+if test $libc_cv_asm_secondary_directive = yes; then
+  $as_echo "#define HAVE_ASM_SECONDARY_DIRECTIVE 1" >>confdefs.h
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for secondary symbol in shared library" >&5
+$as_echo_n "checking for secondary symbol in shared library... " >&6; }
+if ${libc_cv_ld_secondary+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+asm (".secondary foo");
+void foo (void) { }
+EOF
+  if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
+			    -fPIC -shared -o conftest.so conftest.c
+			    -nostartfiles -nostdlib
+			    1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+  then
+    if $READELF -s conftest.so | fgrep foo | fgrep SECOND > /dev/null; then
+      libc_cv_ld_secondary=yes
+    else
+      libc_cv_ld_secondary=no
+    fi
+  else
+    libc_cv_ld_secondary=no
+  fi
+  rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_ld_secondary" >&5
+$as_echo "$libc_cv_ld_secondary" >&6; }
+else
+  libc_cv_ld_secondary=no
+fi
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether CFI directives are supported" >&5
 $as_echo_n "checking whether CFI directives are supported... " >&6; }
 if ${libc_cv_asm_cfi_directives+:} false; then :
diff --git a/configure.in b/configure.in
index a174646..28b0bfd 100644
--- a/configure.in
+++ b/configure.in
@@ -1757,8 +1757,10 @@ foo:
 EOF
 if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
   libc_cv_asm_weak_directive=yes
+  libc_cv_asm_weak=.weak
 else
   libc_cv_asm_weak_directive=no
+  libc_cv_asm_weak=
 fi
 rm -f conftest*])
 
@@ -1777,6 +1779,7 @@ baz:
 EOF
   if AC_TRY_COMMAND(${CC-cc} $ASFLAGS -c conftest.s 1>&AS_MESSAGE_LOG_FD); then
     libc_cv_asm_weakext_directive=yes
+  libc_cv_asm_weak=.weakext
   else
     libc_cv_asm_weakext_directive=no
   fi
@@ -1790,6 +1793,53 @@ elif test $libc_cv_asm_weakext_directive = yes; then
   AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE)
 fi
 
+AC_CACHE_CHECK(for .secondary assembler directive,
+	       libc_cv_asm_secondary_directive, [dnl
+cat > conftest.s <<EOF
+${libc_cv_dot_text}
+_sym:
+.secondary _sym
+EOF
+test -n "$libc_cv_asm_weak" && cat >> conftest.s <<EOF
+$libc_cv_asm_weak _sym
+EOF
+if ${CC-cc} -c $ASFLAGS -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
+  if $READELF -s conftest.o | fgrep _sym | fgrep SECOND > /dev/null; then
+    libc_cv_asm_secondary_directive=yes
+  else
+    libc_cv_asm_secondary_directive=no
+  fi
+else
+  libc_cv_asm_secondary_directive=no
+fi
+rm -f conftest*])
+if test $libc_cv_asm_secondary_directive = yes; then
+  AC_DEFINE(HAVE_ASM_SECONDARY_DIRECTIVE)
+  AC_CACHE_CHECK(for secondary symbol in shared library,
+		 libc_cv_ld_secondary, [dnl
+cat > conftest.c <<EOF
+asm (".secondary foo");
+void foo (void) { }
+EOF
+  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
+			    -fPIC -shared -o conftest.so conftest.c
+			    -nostartfiles -nostdlib
+			    1>&AS_MESSAGE_LOG_FD])
+  then
+    if $READELF -s conftest.so | fgrep foo | fgrep SECOND > /dev/null; then
+      libc_cv_ld_secondary=yes
+    else
+      libc_cv_ld_secondary=no
+    fi
+  else
+    libc_cv_ld_secondary=no
+  fi
+  rm -f conftest*])
+else
+  libc_cv_ld_secondary=no
+fi
+AC_SUBST(libc_cv_ld_secondary)
+
 AC_CACHE_CHECK(whether CFI directives are supported, libc_cv_asm_cfi_directives, [dnl
 case $machine in
   sparc/sparc64*) cfi_offset=2047;;

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=3a737f9567e2849b4bd4806844a1952ea8a25d02

commit 3a737f9567e2849b4bd4806844a1952ea8a25d02
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Jun 30 12:53:04 2012 -0700

    Add STB_SECONDARY support

diff --git a/ChangeLog.second b/ChangeLog.second
new file mode 100644
index 0000000..ad3eba0
--- /dev/null
+++ b/ChangeLog.second
@@ -0,0 +1,7 @@
+2012-06-30  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elf/dl-addr.c (determine_info): Also check STB_SECONDARY.
+	* elf/dl-lookup.c (do_lookup_x): Handle STB_SECONDARY.
+	(_dl_lookup_symbol_x): Likewise.
+	* elf/sprof.c (read_symbols): Likewise.
+	* elf/elf.h (STB_SECONDARY): New.
diff --git a/elf/dl-addr.c b/elf/dl-addr.c
index 498faf1..dc2aca3 100644
--- a/elf/dl-addr.c
+++ b/elf/dl-addr.c
@@ -87,7 +87,8 @@ determine_info (const ElfW(Addr) addr, struct link_map *match, Dl_info *info,
 
       for (; (void *) symtab < (void *) symtabend; ++symtab)
 	if ((ELFW(ST_BIND) (symtab->st_info) == STB_GLOBAL
-	     || ELFW(ST_BIND) (symtab->st_info) == STB_WEAK)
+	     || ELFW(ST_BIND) (symtab->st_info) == STB_WEAK
+	     || ELFW(ST_BIND) (symtab->st_info) == STB_SECONDARY)
 	    && ELFW(ST_TYPE) (symtab->st_info) != STT_TLS
 	    && (symtab->st_shndx != SHN_UNDEF
 		|| symtab->st_value != 0)
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index e7f7148..0e94d51 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -286,10 +286,15 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
 	found_it:
 	  switch (__builtin_expect (ELFW(ST_BIND) (sym->st_info), STB_GLOBAL))
 	    {
+	    case STB_SECONDARY:
+	      /* Secondary definition.  Use this value if we don't find
+		 another.  */
+	      goto dynamic_weak;
 	    case STB_WEAK:
 	      /* Weak definition.  Use this value if we don't find another.  */
 	      if (__builtin_expect (GLRO(dl_dynamic_weak), 0))
 		{
+dynamic_weak:
 		  if (! result->s)
 		    {
 		      result->s = sym;
@@ -769,7 +774,9 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map,
 
   if (__builtin_expect (current_value.s == NULL, 0))
     {
-      if ((*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK)
+      if ((*ref == NULL
+	   || (ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK
+	       && ELFW(ST_BIND) ((*ref)->st_info) != STB_SECONDARY))
 	  && skip_map == NULL
 	  && !(GLRO(dl_debug_mask) & DL_DEBUG_UNUSED))
 	{
diff --git a/elf/elf.h b/elf/elf.h
index 41fc3bd..2b0a0c5 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -444,7 +444,8 @@ typedef struct
 #define STB_LOCAL	0		/* Local symbol */
 #define STB_GLOBAL	1		/* Global symbol */
 #define STB_WEAK	2		/* Weak symbol */
-#define	STB_NUM		3		/* Number of defined types.  */
+#define STB_SECONDARY	3		/* Secondary symbol */
+#define	STB_NUM		4		/* Number of defined types.  */
 #define STB_LOOS	10		/* Start of OS-specific */
 #define STB_GNU_UNIQUE	10		/* Unique symbol.  */
 #define STB_HIOS	12		/* End of OS-specific */
diff --git a/elf/sprof.c b/elf/sprof.c
index 2097d31..2325180 100644
--- a/elf/sprof.c
+++ b/elf/sprof.c
@@ -1078,7 +1078,8 @@ read_symbols (struct shobj *shobj)
 	    newsym->name = &shobj->strtab[sym->st_name];
 	    newsym->addr = sym->st_value;
 	    newsym->size = sym->st_size;
-	    newsym->weak = ELFW(ST_BIND) (sym->st_info) == STB_WEAK;
+	    newsym->weak = (ELFW(ST_BIND) (sym->st_info) == STB_SECONDARY
+			    || ELFW(ST_BIND) (sym->st_info) == STB_WEAK);
 	    newsym->hidden = (ELFW(ST_VISIBILITY) (sym->st_other)
 			      != STV_DEFAULT);
 	    newsym->ticks = 0;
@@ -1136,7 +1137,8 @@ read_symbols (struct shobj *shobj)
 	      newsym->name = &strtab[symtab->st_name];
 	      newsym->addr = symtab->st_value;
 	      newsym->size = symtab->st_size;
-	      newsym->weak = ELFW(ST_BIND) (symtab->st_info) == STB_WEAK;
+	      newsym->weak = (ELFW(ST_BIND) (symtab->st_info) == STB_SECONDARY
+			      || ELFW(ST_BIND) (symtab->st_info) == STB_WEAK);
 	      newsym->hidden = (ELFW(ST_VISIBILITY) (symtab->st_other)
 				!= STV_DEFAULT);
 	      newsym->ticks = 0;

-----------------------------------------------------------------------


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]