1178739Sgonzo/*- 2178739Sgonzo * Copyright 1996-1998 John D. Polstra. 3178739Sgonzo * All rights reserved. 4178739Sgonzo * Copyright (c) 1995 Christopher G. Demetriou 5178739Sgonzo * All rights reserved. 6178739Sgonzo * 7178739Sgonzo * Redistribution and use in source and binary forms, with or without 8178739Sgonzo * modification, are permitted provided that the following conditions 9178739Sgonzo * are met: 10178739Sgonzo * 1. Redistributions of source code must retain the above copyright 11178739Sgonzo * notice, this list of conditions and the following disclaimer. 12178739Sgonzo * 2. Redistributions in binary form must reproduce the above copyright 13178739Sgonzo * notice, this list of conditions and the following disclaimer in the 14178739Sgonzo * documentation and/or other materials provided with the distribution. 15178739Sgonzo * 3. All advertising materials mentioning features or use of this software 16178739Sgonzo * must display the following acknowledgement: 17178739Sgonzo * This product includes software developed by Christopher G. Demetriou 18178739Sgonzo * for the NetBSD Project. 19178739Sgonzo * 4. The name of the author may not be used to endorse or promote products 20178739Sgonzo * derived from this software without specific prior written permission 21178739Sgonzo * 22178739Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23178739Sgonzo * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24178739Sgonzo * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25178739Sgonzo * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26178739Sgonzo * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27178739Sgonzo * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28178739Sgonzo * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29178739Sgonzo * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30178739Sgonzo * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31178739Sgonzo * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32178739Sgonzo * 33178739Sgonzo * $FreeBSD$ 34178739Sgonzo */ 35178739Sgonzo 36178739Sgonzo#include <sys/cdefs.h> 37178739Sgonzo__FBSDID("$FreeBSD$"); 38178739Sgonzo 39178739Sgonzo#include <stdlib.h> 40178739Sgonzo#include "libc_private.h" 41178739Sgonzo#include "crtbrand.c" 42232832Skib#include "ignore_init.c" 43178739Sgonzo 44178739Sgonzostruct Struct_Obj_Entry; 45178739Sgonzostruct ps_strings; 46178739Sgonzo 47178739Sgonzo#ifdef GCRT 48178739Sgonzoextern void _mcleanup(void); 49178739Sgonzoextern void monstartup(void *, void *); 50178739Sgonzoextern int eprol; 51178739Sgonzoextern int etext; 52178739Sgonzo#endif 53178739Sgonzo 54204756Suqsvoid __start(char **, void (*)(void), struct Struct_Obj_Entry *, struct ps_strings *); 55204756Suqs 56178739Sgonzo/* The entry function. */ 57178739Sgonzovoid 58178739Sgonzo__start(char **ap, 59178739Sgonzo void (*cleanup)(void), /* from shared loader */ 60204757Suqs struct Struct_Obj_Entry *obj __unused, /* from shared loader */ 61204757Suqs struct ps_strings *ps_strings __unused) 62178739Sgonzo{ 63178739Sgonzo int argc; 64178739Sgonzo char **argv; 65178739Sgonzo char **env; 66178739Sgonzo 67178739Sgonzo argc = * (long *) ap; 68178739Sgonzo argv = ap + 1; 69178739Sgonzo env = ap + 2 + argc; 70245133Skib handle_argv(argc, argv, env); 71178739Sgonzo 72178739Sgonzo if (&_DYNAMIC != NULL) 73178739Sgonzo atexit(cleanup); 74232580Sgonzo else 75232580Sgonzo _init_tls(); 76232580Sgonzo 77178739Sgonzo#ifdef GCRT 78178739Sgonzo atexit(_mcleanup); 79178739Sgonzo monstartup(&eprol, &etext); 80178739Sgonzo#endif 81232832Skib 82232832Skib handle_static_init(argc, argv, env); 83232832Skib exit(main(argc, argv, env)); 84178739Sgonzo} 85178739Sgonzo 86178739Sgonzo#ifdef GCRT 87178739Sgonzo__asm__(".text"); 88178739Sgonzo__asm__("eprol:"); 89178739Sgonzo__asm__(".previous"); 90178739Sgonzo#endif 91