summaryrefslogtreecommitdiff
path: root/libexec/ld.so
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2004-05-24 20:24:55 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2004-05-24 20:24:55 +0000
commit5e667b5515dde94b3685ef381e4ce788b52add25 (patch)
treea2b065297a3bef598937f2c9b0bc302c9eb15335 /libexec/ld.so
parent6f87c994e188c5ccef743be390012f0dc3392e83 (diff)
doing ldd exit asap -- move all other tasks towards after it.
call atext(_dl_dtors) at the very end -- allows debuggering it. drahn@ ok
Diffstat (limited to 'libexec/ld.so')
-rw-r--r--libexec/ld.so/loader.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c
index fc07883d129..d1f11657260 100644
--- a/libexec/ld.so/loader.c
+++ b/libexec/ld.so/loader.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loader.c,v 1.74 2004/05/24 20:16:12 drahn Exp $ */
+/* $OpenBSD: loader.c,v 1.75 2004/05/24 20:24:54 mickey Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -337,9 +337,6 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data)
_dl_add_object(dyn_obj);
dyn_obj->status |= STAT_RELOC_DONE;
- if (_dl_traceld == NULL)
- _dl_fixup_user_env();
-
/*
* Everything should be in place now for doing the relocation
* and binding. Call _dl_rtld to do the job. Fingers crossed.
@@ -347,6 +344,16 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data)
if (_dl_traceld == NULL)
_dl_rtld(_dl_objects);
+ if (_dl_debug || _dl_traceld)
+ _dl_show_objects();
+
+ DL_DEB(("dynamic loading done.\n"));
+
+ if (_dl_traceld)
+ _dl_exit(0);
+
+ _dl_fixup_user_env();
+
/*
* The first object is the executable itself,
* it is responsible for running it's own ctors/dtors
@@ -354,31 +361,12 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data)
* the shared libraries which follow.
* Do not run init code if run from ldd.
*/
- if ((_dl_traceld == NULL) && (_dl_objects->next != NULL)) {
+ if (_dl_objects->next != NULL) {
_dl_objects->status |= STAT_INIT_DONE;
_dl_call_init(_dl_objects);
}
/*
- * Schedule a routine to be run at shutdown, by using atexit.
- * Cannot call atexit directly from ld.so?
- * Do not schedule destructors if run from ldd.
- */
- if (_dl_traceld == NULL) {
- const Elf_Sym *sym;
- Elf_Addr ooff;
-
- sym = NULL;
- ooff = _dl_find_symbol("atexit", _dl_objects, &sym,
- SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT, 0, dyn_obj);
- if (sym == NULL)
- _dl_printf("cannot find atexit, destructors will not be run!\n");
- else
- (*(void (*)(Elf_Addr))(sym->st_value + ooff))
- ((Elf_Addr)_dl_dtors);
- }
-
- /*
* Finally make something to help gdb when poking around in the code.
*/
#ifdef __mips__
@@ -408,12 +396,24 @@ _dl_boot(const char **argv, char **envp, const long loff, long *dl_data)
_dl_debug_state();
- if (_dl_debug || _dl_traceld) {
- _dl_show_objects();
- DL_DEB(("dynamic loading done.\n"));
+ /*
+ * Schedule a routine to be run at shutdown, by using atexit.
+ * Cannot call atexit directly from ld.so?
+ * Do not schedule destructors if run from ldd.
+ */
+ {
+ const Elf_Sym *sym;
+ Elf_Addr ooff;
+
+ sym = NULL;
+ ooff = _dl_find_symbol("atexit", _dl_objects, &sym,
+ SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT, 0, dyn_obj);
+ if (sym == NULL)
+ _dl_printf("cannot find atexit, destructors will not be run!\n");
+ else
+ (*(void (*)(Elf_Addr))(sym->st_value + ooff))
+ ((Elf_Addr)_dl_dtors);
}
- if (_dl_traceld)
- _dl_exit(0);
DL_DEB(("entry point: 0x%lx\n", dl_data[AUX_entry]));