summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2014-01-18 09:08:43 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2014-01-18 09:08:43 +0000
commit5d9a6f225ea47c9e0084b8aa8032ef1948ac07b7 (patch)
tree692dba7ff04b79a8c98a34778f16c7e5461f7eff
parent1513c71df19abd9a585cf06feda1b2feafda9545 (diff)
Make ld.so pass its cleanup handler in $2 as required by the MIPS System V
ABI, and completely remove the code that attempts to call atexit(3) directly.
-rw-r--r--libexec/ld.so/loader.c25
-rw-r--r--libexec/ld.so/mips64/ldasm.S7
2 files changed, 5 insertions, 27 deletions
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c
index b857777235a..f0b95adaa21 100644
--- a/libexec/ld.so/loader.c
+++ b/libexec/ld.so/loader.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loader.c,v 1.144 2013/12/25 15:14:59 miod Exp $ */
+/* $OpenBSD: loader.c,v 1.145 2014/01/18 09:08:42 kettenis Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -604,29 +604,6 @@ _dl_boot(const char **argv, char **envp, const long dyn_loff, long *dl_data)
_dl_call_init(_dl_objects);
}
-#if defined(__mips64__) /* XXX */
- /*
- * 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_object_t *sobj;
- const Elf_Sym *sym;
- Elf_Addr ooff;
-
- sym = NULL;
- ooff = _dl_find_symbol("__cxa_atexit", &sym,
- SYM_SEARCH_ALL|SYM_NOWARNNOTFOUND|SYM_PLT,
- NULL, dyn_obj, &sobj);
- if (sym == NULL)
- _dl_printf("cannot find __cxa_atexit, destructors will not be run!\n");
- else
- (*(void (*)(void (*)(void), void *, void *))
- (sym->st_value + ooff))(_dl_dtors, NULL, NULL);
- }
-#endif
-
DL_DEB(("entry point: 0x%lx\n", dl_data[AUX_entry]));
/*
diff --git a/libexec/ld.so/mips64/ldasm.S b/libexec/ld.so/mips64/ldasm.S
index 2d7c19c28f5..7a73bc6a9c8 100644
--- a/libexec/ld.so/mips64/ldasm.S
+++ b/libexec/ld.so/mips64/ldasm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldasm.S,v 1.8 2013/01/14 05:24:07 miod Exp $ */
+/* $OpenBSD: ldasm.S,v 1.9 2014/01/18 09:08:42 kettenis Exp $ */
/*
* Copyright (c) 1998-2002 Opsycon AB, Sweden.
@@ -66,11 +66,12 @@ LEAF(_dl_start, FRAMESZ) /* Not really LEAF, but we simplify */
move a2, s0 # Load offset
jal _dl_boot # Go do the linking.
+ move t9, v0 # Entry address from _dl_boot.
+ LA v0, _dl_dtors # cleanup
+
RESTORE_GP64
PTR_ADDU sp, FRAMESZ # Restore stack pointer.
- move t9, v0 # Entry address from _dl_boot.
move ra, zero # Mark last stack frame.
- move v0, zero # cleanup
j t9 # Go execute the 'real' program.
END(_dl_start)