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.
|
2009-12-02 16:34:20 +00:00
|
|
|
*
|
|
|
|
* $FreeBSD$
|
1998-03-07 20:27:11 +00:00
|
|
|
*/
|
|
|
|
|
2010-12-09 21:31:21 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2002-07-16 12:28:50 +00:00
|
|
|
#ifndef lint
|
1998-03-07 20:27:11 +00:00
|
|
|
#ifndef __GNUC__
|
|
|
|
#error "GCC is needed to compile this file"
|
|
|
|
#endif
|
2002-07-16 12:28:50 +00:00
|
|
|
#endif /* lint */
|
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);
|
|
|
|
|
2002-07-16 12:28:50 +00:00
|
|
|
extern void _start(char *, ...);
|
1998-03-07 20:27:11 +00:00
|
|
|
|
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
|
|
|
|
|
2009-12-02 16:34:20 +00:00
|
|
|
void _start1(fptr, int, char *[]) __dead2;
|
1998-03-07 20:27:11 +00:00
|
|
|
|
2009-12-02 16:34:20 +00:00
|
|
|
/* The entry function, C part. */
|
1998-03-07 20:27:11 +00:00
|
|
|
void
|
2009-12-02 16:34:20 +00:00
|
|
|
_start1(fptr cleanup, int argc, char *argv[])
|
1998-03-07 20:27:11 +00:00
|
|
|
{
|
2002-07-03 14:42:39 +00:00
|
|
|
char **env;
|
1998-03-07 20:27:11 +00:00
|
|
|
|
2002-07-03 14:42:39 +00:00
|
|
|
env = argv + argc + 1;
|
2013-01-07 17:58:27 +00:00
|
|
|
handle_argv(argc, argv, env);
|
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
|
|
|
}
|
1998-09-07 23:32:00 +00:00
|
|
|
|
2009-12-02 16:34:20 +00:00
|
|
|
__asm(".hidden _start1");
|