crt1.c (232616) | crt1.c (232832) |
---|---|
1/*- 2 * Copyright 1996-1998 John D. Polstra. 3 * All rights reserved. 4 * Copyright (c) 1995 Christopher G. Demetriou 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 16 unchanged lines hidden (view full) --- 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * | 1/*- 2 * Copyright 1996-1998 John D. Polstra. 3 * All rights reserved. 4 * Copyright (c) 1995 Christopher G. Demetriou 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 16 unchanged lines hidden (view full) --- 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * |
33 * $FreeBSD: head/lib/csu/mips/crt1.c 232616 2012-03-06 19:19:33Z gonzo $ | 33 * $FreeBSD: head/lib/csu/mips/crt1.c 232832 2012-03-11 20:04:09Z kib $ |
34 */ 35 36#include <sys/cdefs.h> | 34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/lib/csu/mips/crt1.c 232616 2012-03-06 19:19:33Z gonzo $"); | 37__FBSDID("$FreeBSD: head/lib/csu/mips/crt1.c 232832 2012-03-11 20:04:09Z kib $"); |
38 39#ifndef __GNUC__ 40#error "GCC is needed to compile this file" 41#endif 42 43#include <stdlib.h> 44#include "libc_private.h" 45#include "crtbrand.c" | 38 39#ifndef __GNUC__ 40#error "GCC is needed to compile this file" 41#endif 42 43#include <stdlib.h> 44#include "libc_private.h" 45#include "crtbrand.c" |
46#include "ignore_init.c" |
|
46 47struct Struct_Obj_Entry; 48struct ps_strings; 49 | 47 48struct Struct_Obj_Entry; 49struct ps_strings; 50 |
50extern int _DYNAMIC; 51#pragma weak _DYNAMIC 52 53extern void _init(void); 54extern void _fini(void); 55extern int main(int, char **, char **); 56 | |
57#ifdef GCRT 58extern void _mcleanup(void); 59extern void monstartup(void *, void *); 60extern int eprol; 61extern int etext; 62#endif 63 | 51#ifdef GCRT 52extern void _mcleanup(void); 53extern void monstartup(void *, void *); 54extern int eprol; 55extern int etext; 56#endif 57 |
64char **environ; 65const char *__progname = ""; 66 | |
67void __start(char **, void (*)(void), struct Struct_Obj_Entry *, struct ps_strings *); 68 69/* The entry function. */ 70void 71__start(char **ap, 72 void (*cleanup)(void), /* from shared loader */ 73 struct Struct_Obj_Entry *obj __unused, /* from shared loader */ 74 struct ps_strings *ps_strings __unused) 75{ 76 int argc; 77 char **argv; 78 char **env; 79 80 argc = * (long *) ap; 81 argv = ap + 1; 82 env = ap + 2 + argc; 83 environ = env; | 58void __start(char **, void (*)(void), struct Struct_Obj_Entry *, struct ps_strings *); 59 60/* The entry function. */ 61void 62__start(char **ap, 63 void (*cleanup)(void), /* from shared loader */ 64 struct Struct_Obj_Entry *obj __unused, /* from shared loader */ 65 struct ps_strings *ps_strings __unused) 66{ 67 int argc; 68 char **argv; 69 char **env; 70 71 argc = * (long *) ap; 72 argv = ap + 1; 73 env = ap + 2 + argc; 74 environ = env; |
84 if (argc > 0 && argv[0] != NULL) { 85 const char *s; 86 __progname = argv[0]; 87 for (s = __progname; *s != '\0'; s++) 88 if (*s == '/') 89 __progname = s + 1; 90 } | 75 if (argc > 0 && argv[0] != NULL) 76 handle_progname(argv[0]); |
91 92 if (&_DYNAMIC != NULL) 93 atexit(cleanup); 94 else 95 _init_tls(); 96 97#ifdef GCRT 98 atexit(_mcleanup); | 77 78 if (&_DYNAMIC != NULL) 79 atexit(cleanup); 80 else 81 _init_tls(); 82 83#ifdef GCRT 84 atexit(_mcleanup); |
99#endif 100 atexit(_fini); 101#ifdef GCRT | |
102 monstartup(&eprol, &etext); 103#endif | 85 monstartup(&eprol, &etext); 86#endif |
104 _init(); 105 exit( main(argc, argv, env) ); | 87 88 handle_static_init(argc, argv, env); 89 exit(main(argc, argv, env)); |
106} 107 108#ifdef GCRT 109__asm__(".text"); 110__asm__("eprol:"); 111__asm__(".previous"); 112#endif | 90} 91 92#ifdef GCRT 93__asm__(".text"); 94__asm__("eprol:"); 95__asm__(".previous"); 96#endif |