diff options
author | guenther <> | 2015-11-10 04:14:03 +0000 |
---|---|---|
committer | guenther <> | 2015-11-10 04:14:03 +0000 |
commit | 5651c0192047b065735a7a8aba261e465338ead7 (patch) | |
tree | 6d0e63d20e0eee5e59decf6cc99b8bbc76d33970 /src/lib | |
parent | e5a0272a073ca8207e74df103d4a339ca402e6c0 (diff) | |
download | openbsd-5651c0192047b065735a7a8aba261e465338ead7.tar.gz openbsd-5651c0192047b065735a7a8aba261e465338ead7.tar.bz2 openbsd-5651c0192047b065735a7a8aba261e465338ead7.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 'src/lib')
-rw-r--r-- | src/lib/libc/stdlib/atexit.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lib/libc/stdlib/atexit.c b/src/lib/libc/stdlib/atexit.c index a44de37c88..83cc1282a9 100644 --- a/src/lib/libc/stdlib/atexit.c +++ b/src/lib/libc/stdlib/atexit.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: atexit.c,v 1.23 2015/10/25 18:03:17 guenther Exp $ */ | 1 | /* $OpenBSD: atexit.c,v 1.24 2015/11/10 04:14:03 guenther Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2002 Daniel Hartmeier | 3 | * Copyright (c) 2002 Daniel Hartmeier |
4 | * All rights reserved. | 4 | * All rights reserved. |
@@ -110,6 +110,18 @@ unlock: | |||
110 | DEF_STRONG(__cxa_atexit); | 110 | DEF_STRONG(__cxa_atexit); |
111 | 111 | ||
112 | /* | 112 | /* |
113 | * Copy of atexit() used by libc and anything staticly linked into the | ||
114 | * executable. This passes NULL for the dso, so the callbacks are only | ||
115 | * invoked by exit() and not dlclose() | ||
116 | */ | ||
117 | int | ||
118 | atexit(void (*fn)(void)) | ||
119 | { | ||
120 | return (__cxa_atexit((void (*)(void *))fn, NULL, NULL)); | ||
121 | } | ||
122 | DEF_STRONG(atexit); | ||
123 | |||
124 | /* | ||
113 | * Call all handlers registered with __cxa_atexit() for the shared | 125 | * Call all handlers registered with __cxa_atexit() for the shared |
114 | * object owning 'dso'. | 126 | * object owning 'dso'. |
115 | * Note: if 'dso' is NULL, then all remaining handlers are called. | 127 | * Note: if 'dso' is NULL, then all remaining handlers are called. |