diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2019-06-02 01:03:02 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2019-06-02 01:03:02 +0000 |
commit | 4a80a8ec4a5d6d7d4690398d18ba3e11a49f0d8d (patch) | |
tree | ba6f9621a1170d5b6b13543f937687973ef87a85 /lib/libc/stdlib | |
parent | a8565da1091ea7a7792ae6d3d19d0fa477404ab6 (diff) |
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 'lib/libc/stdlib')
-rw-r--r-- | lib/libc/stdlib/thread_atexit.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/libc/stdlib/thread_atexit.c b/lib/libc/stdlib/thread_atexit.c index 2e00428eba4..ef0423c4284 100644 --- a/lib/libc/stdlib/thread_atexit.c +++ b/lib/libc/stdlib/thread_atexit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: thread_atexit.c,v 1.1 2017/12/16 20:06:56 guenther Exp $ */ +/* $OpenBSD: thread_atexit.c,v 1.2 2019/06/02 01:03:01 guenther Exp $ */ /* * Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org> * @@ -16,15 +16,11 @@ */ #include <dlfcn.h> -#include <elf.h> -#pragma weak _DYNAMIC #include <stdlib.h> #include <tib.h> #include "atexit.h" -typeof(dlctl) dlctl asm("_dlctl") __attribute__((weak)); - __weak_alias(__cxa_thread_atexit, __cxa_thread_atexit_impl); int @@ -37,8 +33,7 @@ __cxa_thread_atexit_impl(void (*func)(void *), void *arg, void *dso) if (fnp == NULL) return -1; - if (_DYNAMIC) - dlctl(NULL, DL_REFERENCE, dso); + dlctl(NULL, DL_REFERENCE, dso); fnp->func = func; fnp->arg = arg; |