summaryrefslogtreecommitdiff
path: root/lib/librthread/rthread_fork.c
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2012-08-22 23:43:33 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2012-08-22 23:43:33 +0000
commit1f26125669866612ffdb6de97081736444827832 (patch)
tree28bd4ef1aecbc2a8114c2bab28690b2f2d29061d /lib/librthread/rthread_fork.c
parent55197ac21f217cfc7481f89abe3f2ff958a56d60 (diff)
We want to check that the dynamic linker is available at run-time, so
we should actually check for _DYNAMIC at run-time rather than checking for __PIC__ at compile time, since the two are actually independent. Problem and solution identified by guenther; minor tweaks by me. ok guenther
Diffstat (limited to 'lib/librthread/rthread_fork.c')
-rw-r--r--lib/librthread/rthread_fork.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/librthread/rthread_fork.c b/lib/librthread/rthread_fork.c
index d5786ed5449..c5847363929 100644
--- a/lib/librthread/rthread_fork.c
+++ b/lib/librthread/rthread_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_fork.c,v 1.5 2012/08/22 22:34:57 matthew Exp $ */
+/* $OpenBSD: rthread_fork.c,v 1.6 2012/08/22 23:43:32 matthew Exp $ */
/*
* Copyright (c) 2008 Kurt Miller <kurt@openbsd.org>
@@ -30,6 +30,12 @@
* $FreeBSD: /repoman/r/ncvs/src/lib/libc_r/uthread/uthread_atfork.c,v 1.1 2004/12/10 03:36:45 grog Exp $
*/
+#if defined(__ELF__)
+#include <sys/types.h>
+#include <sys/exec_elf.h>
+#pragma weak _DYNAMIC
+#endif
+
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
@@ -77,30 +83,34 @@ _dofork(int is_vfork)
* binding in the other locking functions can succeed.
*/
-#if defined(__ELF__) && defined(__PIC__)
- _rthread_dl_lock(0);
+#if defined(__ELF__)
+ if (_DYNAMIC)
+ _rthread_dl_lock(0);
#endif
_thread_atexit_lock();
_thread_malloc_lock();
_thread_arc4_lock();
-#if defined(__ELF__) && defined(__PIC__)
- _rthread_bind_lock(0);
+#if defined(__ELF__)
+ if (_DYNAMIC)
+ _rthread_bind_lock(0);
#endif
newid = sys_fork();
-#if defined(__ELF__) && defined(__PIC__)
- _rthread_bind_lock(1);
+#if defined(__ELF__)
+ if (_DYNAMIC)
+ _rthread_bind_lock(1);
#endif
_thread_arc4_unlock();
_thread_malloc_unlock();
_thread_atexit_unlock();
-#if defined(__ELF__) && defined(__PIC__)
- _rthread_dl_lock(1);
+#if defined(__ELF__)
+ if (_DYNAMIC)
+ _rthread_dl_lock(1);
#endif
if (newid == 0) {