diff options
author | guenther <> | 2019-06-02 01:03:01 +0000 |
---|---|---|
committer | guenther <> | 2019-06-02 01:03:01 +0000 |
commit | 067458d3e4d7e3ca6e967ce3ae9e59c217b2d319 (patch) | |
tree | 7d7261eb7ce107c1c6d6a5b9fe7ff3e3204af517 /src/lib/libc/stdlib/thread_atexit.c | |
parent | c6d26d2db7ee608499714dc433ddb9978db53cef (diff) | |
download | openbsd-067458d3e4d7e3ca6e967ce3ae9e59c217b2d319.tar.gz openbsd-067458d3e4d7e3ca6e967ce3ae9e59c217b2d319.tar.bz2 openbsd-067458d3e4d7e3ca6e967ce3ae9e59c217b2d319.zip |
Complete the ld.so boot cleanup: move most libc initialization from
_csu_finish() to _libc_preinit(), which is an .init_array function
in shared libc (and mark it INITFIRST) or a .preinit_array function
in static libc, grabbing the _dl_cb callback there from ld.so. Then
in _csu_finish(), invoke the dl_clean_boot() callback to free ld.so's
startup bits before main() gets control.
Other cleanups this permits:
- move various startup structures into .data.rel.ro
- the dl* stubs in libc can be strong and call the callbacks provided
via _dl_cb
- no longer need to conditionalize dlctl() calls on presence of _DYNAMIC
original concept and full diff ok kettenis@
ok deraadt@
Diffstat (limited to 'src/lib/libc/stdlib/thread_atexit.c')
-rw-r--r-- | src/lib/libc/stdlib/thread_atexit.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/lib/libc/stdlib/thread_atexit.c b/src/lib/libc/stdlib/thread_atexit.c index 2e00428eba..ef0423c428 100644 --- a/src/lib/libc/stdlib/thread_atexit.c +++ b/src/lib/libc/stdlib/thread_atexit.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: thread_atexit.c,v 1.1 2017/12/16 20:06:56 guenther Exp $ */ | 1 | /* $OpenBSD: thread_atexit.c,v 1.2 2019/06/02 01:03:01 guenther Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org> | 3 | * Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org> |
4 | * | 4 | * |
@@ -16,15 +16,11 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <dlfcn.h> | 18 | #include <dlfcn.h> |
19 | #include <elf.h> | ||
20 | #pragma weak _DYNAMIC | ||
21 | #include <stdlib.h> | 19 | #include <stdlib.h> |
22 | #include <tib.h> | 20 | #include <tib.h> |
23 | 21 | ||
24 | #include "atexit.h" | 22 | #include "atexit.h" |
25 | 23 | ||
26 | typeof(dlctl) dlctl asm("_dlctl") __attribute__((weak)); | ||
27 | |||
28 | __weak_alias(__cxa_thread_atexit, __cxa_thread_atexit_impl); | 24 | __weak_alias(__cxa_thread_atexit, __cxa_thread_atexit_impl); |
29 | 25 | ||
30 | int | 26 | int |
@@ -37,8 +33,7 @@ __cxa_thread_atexit_impl(void (*func)(void *), void *arg, void *dso) | |||
37 | if (fnp == NULL) | 33 | if (fnp == NULL) |
38 | return -1; | 34 | return -1; |
39 | 35 | ||
40 | if (_DYNAMIC) | 36 | dlctl(NULL, DL_REFERENCE, dso); |
41 | dlctl(NULL, DL_REFERENCE, dso); | ||
42 | 37 | ||
43 | fnp->func = func; | 38 | fnp->func = func; |
44 | fnp->arg = arg; | 39 | fnp->arg = arg; |