diff options
Diffstat (limited to 'lib/csu/sparc64/crt1.c')
-rw-r--r-- | lib/csu/sparc64/crt1.c | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/lib/csu/sparc64/crt1.c b/lib/csu/sparc64/crt1.c index cd684f3..4bde8dc 100644 --- a/lib/csu/sparc64/crt1.c +++ b/lib/csu/sparc64/crt1.c @@ -1,5 +1,5 @@ -/* - * Copyright 2001 David E. O'Brien +/*- + * Copyright 2001 David E. O'Brien. * All rights reserved. * Copyright (c) 1995, 1998 Berkeley Software Design, Inc. * All rights reserved. @@ -29,25 +29,32 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef lint #ifndef __GNUC__ #error "GCC is needed to compile this file" #endif +#endif /* lint */ #include <stdlib.h> + #include "libc_private.h" #include "crtbrand.c" struct Struct_Obj_Entry; struct ps_strings; -#pragma weak _DYNAMIC extern int _DYNAMIC; +#pragma weak _DYNAMIC + +typedef void (*fptr)(void); -extern void _init(void); extern void _fini(void); +extern void _init(void); extern int main(int, char **, char **); -extern void __sparc64_sigtramp_setup(void); -extern void __sparc64_utrap_setup(void); +extern void _start(char **, void (*)(void), struct Struct_Obj_Entry *, + struct ps_strings *); +extern void __sparc_sigtramp_setup(void); +extern void __sparc_utrap_setup(void); #ifdef GCRT extern void _mcleanup(void); @@ -59,9 +66,30 @@ 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 @@ -70,26 +98,20 @@ const char *__progname = ""; * Note: kernel may (is not set in stone yet) pass ELF aux vector in %o1, * but for now we do not use it here. */ +/* ARGSUSED */ void -_start(char **ap, - void (*cleanup)(void), /* from shared loader */ - struct Struct_Obj_Entry *obj, /* from shared loader */ - struct ps_strings *ps_strings) +_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; -#if 0 - void (*term)(void); - /* Grab %g1 before it gets used for anything by the compiler. */ - /* Sparc ELF psABI specifies a termination routine (if any) will be in - %g1 */ - __asm__ volatile("mov %%g1,%0" : "=r"(term)); -#endif + term = get_term(); - argc = * (long *) ap; + argc = *(long *)(void *)ap; argv = ap + 1; env = ap + 2 + argc; environ = env; @@ -102,14 +124,13 @@ _start(char **ap, __sparc_sigtramp_setup(); __sparc_utrap_setup(); -#if 0 + /* * If the kernel or a shared library wants us to call * a termination function, arrange to do so. */ if (term) atexit(term); -#endif if (&_DYNAMIC != NULL) atexit(cleanup); |