2003-01-26 23:14:47 +00:00
|
|
|
/* LINTLIBRARY */
|
1998-03-07 20:27:11 +00:00
|
|
|
/*-
|
|
|
|
* Copyright 1996-1998 John D. Polstra.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2010-12-09 21:31:21 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1998-03-07 20:27:11 +00:00
|
|
|
#include <stdlib.h>
|
2002-07-03 14:42:39 +00:00
|
|
|
|
2002-03-29 22:43:43 +00:00
|
|
|
#include "libc_private.h"
|
2000-10-28 21:26:48 +00:00
|
|
|
#include "crtbrand.c"
|
2012-03-11 20:04:09 +00:00
|
|
|
#include "ignore_init.c"
|
2002-07-16 12:28:50 +00:00
|
|
|
|
1998-03-07 20:27:11 +00:00
|
|
|
typedef void (*fptr)(void);
|
|
|
|
|
1998-09-07 23:32:00 +00:00
|
|
|
#ifdef GCRT
|
|
|
|
extern void _mcleanup(void);
|
|
|
|
extern void monstartup(void *, void *);
|
|
|
|
extern int eprol;
|
|
|
|
extern int etext;
|
|
|
|
#endif
|
|
|
|
|
2010-03-05 13:28:05 +00:00
|
|
|
void _start(char **, void (*)(void));
|
|
|
|
|
2002-07-16 12:28:50 +00:00
|
|
|
/* The entry function. */
|
1998-03-07 20:27:11 +00:00
|
|
|
void
|
2003-04-30 19:27:07 +00:00
|
|
|
_start(char **ap, void (*cleanup)(void))
|
1998-03-07 20:27:11 +00:00
|
|
|
{
|
2002-07-03 14:42:39 +00:00
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
char **env;
|
1998-03-07 20:27:11 +00:00
|
|
|
|
2003-04-30 19:27:07 +00:00
|
|
|
argc = *(long *)(void *)ap;
|
|
|
|
argv = ap + 1;
|
|
|
|
env = ap + 2 + argc;
|
2013-01-07 17:58:27 +00:00
|
|
|
handle_argv(argc, argv, env);
|
1998-03-07 20:27:11 +00:00
|
|
|
|
2002-07-03 14:42:39 +00:00
|
|
|
if (&_DYNAMIC != NULL)
|
2002-07-16 12:28:50 +00:00
|
|
|
atexit(cleanup);
|
2004-08-15 16:18:52 +00:00
|
|
|
else
|
|
|
|
_init_tls();
|
1998-03-07 20:27:11 +00:00
|
|
|
|
1998-09-07 23:32:00 +00:00
|
|
|
#ifdef GCRT
|
2002-07-03 14:42:39 +00:00
|
|
|
atexit(_mcleanup);
|
|
|
|
monstartup(&eprol, &etext);
|
2005-10-07 22:13:17 +00:00
|
|
|
__asm__("eprol:");
|
1998-09-07 23:32:00 +00:00
|
|
|
#endif
|
2012-03-11 20:04:09 +00:00
|
|
|
|
|
|
|
handle_static_init(argc, argv, env);
|
|
|
|
exit(main(argc, argv, env));
|
1998-03-07 20:27:11 +00:00
|
|
|
}
|