diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2015-11-10 04:14:04 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2015-11-10 04:14:04 +0000 |
commit | 2de40dc0593bdf96a17ccf05b725d8b4260ec0e1 (patch) | |
tree | b6f874627bc9312c7060c11146e21ee5df3d1218 /lib/libc/thread | |
parent | f15bb8f1a90ffad3aace60e831d29da29747ed5e (diff) |
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')
-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)); +} |