summaryrefslogtreecommitdiff
path: root/lib/libc/arch/i386
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-04-07 01:27:08 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-04-07 01:27:08 +0000
commit88c62139002b1fec001c04b3594a04d1bbfb1342 (patch)
tree0509c1476b98d3b86a67ed3837dd2dd5f29944de /lib/libc/arch/i386
parent1e37072b7b75ac23dc21e9d893b197aab716875c (diff)
Make pthread_atfork() track the DSO that called it like atexit() does,
unregistering callbacks if the DSO is unloaded. Move the callback handling from libpthread to libc, though libpthread still overrides the inner call to handle locking and thread-library reinitialization. Major version bump for both libc and libpthread. verification that this fixes various ports ajacoutot@ asm assistance miod@; ok millert@ deraadt@
Diffstat (limited to 'lib/libc/arch/i386')
-rw-r--r--lib/libc/arch/i386/SYS.h28
-rw-r--r--lib/libc/arch/i386/sys/fork.S5
2 files changed, 30 insertions, 3 deletions
diff --git a/lib/libc/arch/i386/SYS.h b/lib/libc/arch/i386/SYS.h
index cc199d6bf3d..a6c1c852c03 100644
--- a/lib/libc/arch/i386/SYS.h
+++ b/lib/libc/arch/i386/SYS.h
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: SYS.h,v 1.19 2014/06/04 20:13:49 matthew Exp $
+ * $OpenBSD: SYS.h,v 1.20 2015/04/07 01:27:06 guenther Exp $
*/
#include <machine/asm.h>
@@ -49,6 +49,8 @@
ENTRY(_thread_sys_ ## x); \
.weak _C_LABEL(x); \
_C_LABEL(x) = _C_LABEL(_thread_sys_ ## x)
+#define SYSENTRY_HIDDEN(x) \
+ ENTRY(_thread_sys_ ## x)
#define __DO_SYSCALL(x) \
movl $(SYS_ ## x),%eax; \
@@ -62,6 +64,9 @@
#define _SYSCALL_NOERROR(x,y) \
SYSENTRY(x); \
__DO_SYSCALL(y);
+#define _SYSCALL_HIDDEN_NOERROR(x,y) \
+ SYSENTRY_HIDDEN(x); \
+ __DO_SYSCALL(y);
#define SYSCALL_NOERROR(x) \
_SYSCALL_NOERROR(x,x)
@@ -77,6 +82,15 @@
jmp *%ecx; \
_SYSCALL_NOERROR(x,y) \
jc 2b
+#define _SYSCALL_HIDDEN(x,y) \
+ .text; \
+ .align 2; \
+ 2: PIC_PROLOGUE; \
+ movl PIC_GOT(CERROR), %ecx; \
+ PIC_EPILOGUE; \
+ jmp *%ecx; \
+ _SYSCALL_HIDDEN_NOERROR(x,y) \
+ jc 2b
#else
#define _SYSCALL(x,y) \
.text; \
@@ -85,6 +99,13 @@
jmp PIC_PLT(CERROR); \
_SYSCALL_NOERROR(x,y) \
jc 2b
+#define _SYSCALL_HIDDEN(x,y) \
+ .text; \
+ .align 2; \
+ 2: \
+ jmp PIC_PLT(CERROR); \
+ _SYSCALL_HIDDEN_NOERROR(x,y) \
+ jc 2b
#endif
#define SYSCALL(x) \
@@ -99,9 +120,14 @@
#define PSEUDO(x,y) \
_SYSCALL(x,y); \
ret
+#define PSEUDO_HIDDEN(x,y) \
+ _SYSCALL_HIDDEN(x,y); \
+ ret
/* perform a syscall with the same name, set errno, return */
#define RSYSCALL(x) \
PSEUDO(x,x);
+#define RSYSCALL_HIDDEN(x) \
+ PSEUDO_HIDDEN(x,x)
.globl CERROR
diff --git a/lib/libc/arch/i386/sys/fork.S b/lib/libc/arch/i386/sys/fork.S
index 205ae5942c1..1e750d3f0d6 100644
--- a/lib/libc/arch/i386/sys/fork.S
+++ b/lib/libc/arch/i386/sys/fork.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: fork.S,v 1.5 2015/03/31 04:32:01 guenther Exp $ */
+/* $OpenBSD: fork.S,v 1.6 2015/04/07 01:27:06 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -33,4 +33,5 @@
#include "SYS.h"
-RSYSCALL(fork)
+RSYSCALL_HIDDEN(fork)
+WEAK_ALIAS(_thread_fork,_thread_sys_fork)