crt1.c (216338) | crt1.c (232832) |
---|---|
1/* LINTLIBRARY */ 2/*- 3 * Copyright 1996-1998 John D. Polstra. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/* LINTLIBRARY */ 2/*- 3 * Copyright 1996-1998 John D. Polstra. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/lib/csu/amd64/crt1.c 216338 2010-12-09 21:31:21Z dim $"); | 28__FBSDID("$FreeBSD: head/lib/csu/amd64/crt1.c 232832 2012-03-11 20:04:09Z kib $"); |
29 30#ifndef lint 31#ifndef __GNUC__ 32#error "GCC is needed to compile this file" 33#endif 34#endif /* lint */ 35 36#include <stdlib.h> 37 38#include "libc_private.h" 39#include "crtbrand.c" | 29 30#ifndef lint 31#ifndef __GNUC__ 32#error "GCC is needed to compile this file" 33#endif 34#endif /* lint */ 35 36#include <stdlib.h> 37 38#include "libc_private.h" 39#include "crtbrand.c" |
40#include "ignore_init.c" |
|
40 | 41 |
41extern int _DYNAMIC; 42#pragma weak _DYNAMIC 43 | |
44typedef void (*fptr)(void); 45 | 42typedef void (*fptr)(void); 43 |
46extern void _fini(void); 47extern void _init(void); 48extern int main(int, char **, char **); 49 | |
50#ifdef GCRT 51extern void _mcleanup(void); 52extern void monstartup(void *, void *); 53extern int eprol; 54extern int etext; 55#endif 56 | 44#ifdef GCRT 45extern void _mcleanup(void); 46extern void monstartup(void *, void *); 47extern int eprol; 48extern int etext; 49#endif 50 |
57char **environ; 58const char *__progname = ""; 59 | |
60void _start(char **, void (*)(void)); 61 62/* The entry function. */ 63void 64_start(char **ap, void (*cleanup)(void)) 65{ 66 int argc; 67 char **argv; 68 char **env; | 51void _start(char **, void (*)(void)); 52 53/* The entry function. */ 54void 55_start(char **ap, void (*cleanup)(void)) 56{ 57 int argc; 58 char **argv; 59 char **env; |
69 const char *s; | |
70 71 argc = *(long *)(void *)ap; 72 argv = ap + 1; 73 env = ap + 2 + argc; 74 environ = env; | 60 61 argc = *(long *)(void *)ap; 62 argv = ap + 1; 63 env = ap + 2 + argc; 64 environ = env; |
75 if (argc > 0 && argv[0] != NULL) { 76 __progname = argv[0]; 77 for (s = __progname; *s != '\0'; s++) 78 if (*s == '/') 79 __progname = s + 1; 80 } | 65 if (argc > 0 && argv[0] != NULL) 66 handle_progname(argv[0]); |
81 82 if (&_DYNAMIC != NULL) 83 atexit(cleanup); 84 else 85 _init_tls(); 86 87#ifdef GCRT 88 atexit(_mcleanup); | 67 68 if (&_DYNAMIC != NULL) 69 atexit(cleanup); 70 else 71 _init_tls(); 72 73#ifdef GCRT 74 atexit(_mcleanup); |
89#endif 90 atexit(_fini); 91#ifdef GCRT | |
92 monstartup(&eprol, &etext); 93__asm__("eprol:"); 94#endif | 75 monstartup(&eprol, &etext); 76__asm__("eprol:"); 77#endif |
95 _init(); 96 exit( main(argc, argv, env) ); | 78 79 handle_static_init(argc, argv, env); 80 exit(main(argc, argv, env)); |
97} | 81} |