From 34893fe49b98c37cc61a39b80a1d1e931d99b0d8 Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Sun, 26 Jan 2003 23:01:36 +0000 Subject: [PATCH] Remove the get_term() function. It pretty much can't work for FreeBSD, and makes ugly diffs with the other crt1.c's. Leave behind a comment (words supplied by Thomas Moestl) that explain the issue. OK'ed by: tmm --- lib/csu/sparc64/crt1.c | 43 +++++++----------------------------------- 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/lib/csu/sparc64/crt1.c b/lib/csu/sparc64/crt1.c index 379696535dc5..bdafbe555e52 100644 --- a/lib/csu/sparc64/crt1.c +++ b/lib/csu/sparc64/crt1.c @@ -65,51 +65,29 @@ extern int etext; char **environ; const char *__progname = ""; -/* - * Grab %g1 before it gets used for anything by the compiler. - * Sparc ELF psABI specifies a termination routine (if any) will be in - * %g1 - */ -static __inline fptr -get_term(void) -{ - fptr retval; - -#if 0 -#ifdef __GNUC__ - __asm__ volatile("mov %%g1,%0" : "=r"(retval)); -#else - retval = (fptr)0; /* XXXX Fix this for other compilers */ -#endif -#else - retval = (fptr)0; /* XXXX temporary */ -#endif - return(retval); -} - /* The entry function. */ /* - * %o0 holds ps_strings pointer. For Solaris compat and/or shared - * libraries, if %g1 is not 0, it is a routine to pass to atexit(). - * (By passing the pointer in the usual argument register, we avoid - * having to do any inline assembly, except to recover %g1.) + * %o0 holds ps_strings pointer. * * Note: kernel may (is not set in stone yet) pass ELF aux vector in %o1, * but for now we do not use it here. + * + * The SPARC compliance definitions specifies that the kernel pass the + * address of a function to be executed on exit in %g1. We do not make + * use of it as it is quite broken, because gcc can use this register + * as a temporary, so it is not safe from C code. Its even more broken + * for dynamic executables since rtld runs first. */ /* ARGSUSED */ void _start(char **ap, void (*cleanup)(void), struct Struct_Obj_Entry *obj __unused, struct ps_strings *ps_strings __unused) { - void (*term)(void); int argc; char **argv; char **env; const char *s; - term = get_term(); - argc = *(long *)(void *)ap; argv = ap + 1; env = ap + 2 + argc; @@ -123,13 +101,6 @@ _start(char **ap, void (*cleanup)(void), struct Struct_Obj_Entry *obj __unused, __sparc_utrap_setup(); - /* - * If the kernel or a shared library wants us to call - * a termination function, arrange to do so. - */ - if (term) - atexit(term); - if (&_DYNAMIC != NULL) atexit(cleanup);