diff options
author | 2015-11-10 04:14:03 +0000 | |
---|---|---|
committer | 2015-11-10 04:14:03 +0000 | |
commit | 6897476f8d3f1ad745809cc8163365f785e57a2d (patch) | |
tree | 3a49f02e6a0fda10fd2852d3b3faef4867992778 /lib/libc/thread/atfork.c | |
parent | Always honor ${DESTDIR}. OK miod@ (diff) | |
download | wireguard-openbsd-6897476f8d3f1ad745809cc8163365f785e57a2d.tar.xz wireguard-openbsd-6897476f8d3f1ad745809cc8163365f785e57a2d.zip |
libc.so can't be unloaded, so move the hidden atexit() and pthread_atfork()
stubs for the executable from crtbegin.o into libc, which lets them be
excluded from static links that don't use them.
For this, drop the normal crt{begin,end}S.o from libc.so: the .init and .fini
sections for libc aren't called at the right times anyway, so it's good that
they're unused. libc.so just needs __guard_local and the .note.openbsd.ident
section, so add them to stack_protector.c for now (this will be improved)
"good time" deraadt@
Diffstat (limited to 'lib/libc/thread/atfork.c')
-rw-r--r-- | lib/libc/thread/atfork.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/libc/thread/atfork.c b/lib/libc/thread/atfork.c index e4ae398df5a..09e1c1cef5d 100644 --- a/lib/libc/thread/atfork.c +++ b/lib/libc/thread/atfork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atfork.c,v 1.1 2015/04/07 01:27:07 guenther Exp $ */ +/* $OpenBSD: atfork.c,v 1.2 2015/11/10 04:14:03 guenther Exp $ */ /* * Copyright (c) 2008 Kurt Miller <kurt@openbsd.org> @@ -32,10 +32,15 @@ #include <errno.h> #include <stdlib.h> +#include <pthread.h> #include "thread_private.h" #include "atfork.h" +int _thread_atfork(void (*_prepare)(void), void (*_parent)(void), + void (*_child)(void), void *_dso); +PROTO_NORMAL(_thread_atfork); + int _thread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void), void *dso) @@ -54,3 +59,15 @@ _thread_atfork(void (*prepare)(void), void (*parent)(void), _ATFORK_UNLOCK(); return (0); } +DEF_STRONG(_thread_atfork); + +/* + * Copy of pthread_atfork() used by libc and anything staticly linked + * into the executable. This passes NULL for the dso, so the callbacks + * are never removed by dlclose() + */ +int +pthread_atfork(void (*prep)(void), void (*parent)(void), void (*child)(void)) +{ + return (_thread_atfork(prep, parent, child, NULL)); +} |