1109905Smarkm/* LINTLIBRARY */ 270657Sobrien/*- 370657Sobrien * Copyright 2001 David E. O'Brien. 470657Sobrien * All rights reserved. 570657Sobrien * Copyright 1996-1998 John D. Polstra. 670657Sobrien * All rights reserved. 770657Sobrien * Copyright (c) 1997 Jason R. Thorpe. 870657Sobrien * Copyright (c) 1995 Christopher G. Demetriou 970657Sobrien * All rights reserved. 1070657Sobrien * 1170657Sobrien * Redistribution and use in source and binary forms, with or without 1270657Sobrien * modification, are permitted provided that the following conditions 1370657Sobrien * are met: 1470657Sobrien * 1. Redistributions of source code must retain the above copyright 1570657Sobrien * notice, this list of conditions and the following disclaimer. 1670657Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1770657Sobrien * notice, this list of conditions and the following disclaimer in the 1870657Sobrien * documentation and/or other materials provided with the distribution. 1970657Sobrien * 3. All advertising materials mentioning features or use of this software 2070657Sobrien * must display the following acknowledgement: 2170657Sobrien * This product includes software developed for the 2270657Sobrien * FreeBSD Project. See http://www.freebsd.org/ for 2370657Sobrien * information about FreeBSD. 2470657Sobrien * This product includes software developed for the 2570657Sobrien * NetBSD Project. See http://www.netbsd.org/ for 2670657Sobrien * information about NetBSD. 2770657Sobrien * 4. The name of the author may not be used to endorse or promote products 2870657Sobrien * derived from this software without specific prior written permission 2970657Sobrien * 3070657Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 3170657Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 3270657Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 3370657Sobrien * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 3470657Sobrien * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 3570657Sobrien * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3670657Sobrien * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3770657Sobrien * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3870657Sobrien * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3970657Sobrien * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4070657Sobrien */ 4170657Sobrien 42216338Sdim#include <sys/cdefs.h> 43216338Sdim__FBSDID("$FreeBSD$"); 44216338Sdim 45100167Smarkm#ifndef lint 4670657Sobrien#ifndef __GNUC__ 4770657Sobrien#error "GCC is needed to compile this file" 4870657Sobrien#endif 49100167Smarkm#endif /* lint */ 5070657Sobrien 5170657Sobrien#include <stdlib.h> 52100167Smarkm 5393399Smarkm#include "libc_private.h" 5470657Sobrien#include "crtbrand.c" 55232832Skib#include "ignore_init.c" 5670657Sobrien 5780740Smpstruct Struct_Obj_Entry; 5880740Smpstruct ps_strings; 5980740Smp 60209869Snwhitehornextern void _start(int, char **, char **, const struct Struct_Obj_Entry *, 61209869Snwhitehorn void (*)(void), struct ps_strings *); 6270657Sobrien 6370657Sobrien#ifdef GCRT 6470657Sobrienextern void _mcleanup(void); 6570657Sobrienextern void monstartup(void *, void *); 6670657Sobrienextern int eprol; 6770657Sobrienextern int etext; 6870657Sobrien#endif 6970657Sobrien 7080740Smpstruct ps_strings *__ps_strings; 7170657Sobrien 72100167Smarkm/* The entry function. */ 73100167Smarkm/* 7493036Sobrien * First 5 arguments are specified by the PowerPC SVR4 ABI. 7593036Sobrien * The last argument, ps_strings, is a BSD extension. 7693036Sobrien */ 77100167Smarkm/* ARGSUSED */ 7870657Sobrienvoid 79100167Smarkm_start(int argc, char **argv, char **env, 80100167Smarkm const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void), 81100167Smarkm struct ps_strings *ps_strings) 8270657Sobrien{ 8370657Sobrien 84245133Skib handle_argv(argc, argv, env); 8570657Sobrien 8670657Sobrien if (ps_strings != (struct ps_strings *)0) 8770657Sobrien __ps_strings = ps_strings; 8870657Sobrien 8970657Sobrien if (&_DYNAMIC != NULL) 9070657Sobrien atexit(cleanup); 91133754Sdfr else 92133754Sdfr _init_tls(); 9370657Sobrien 9470657Sobrien#ifdef GCRT 9570657Sobrien atexit(_mcleanup); 9670657Sobrien monstartup(&eprol, &etext); 9770657Sobrien#endif 98232832Skib 99232832Skib handle_static_init(argc, argv, env); 100232832Skib exit(main(argc, argv, env)); 10170657Sobrien} 10270657Sobrien 10370657Sobrien#ifdef GCRT 10470657Sobrien__asm__(".text"); 10570657Sobrien__asm__("eprol:"); 10670657Sobrien__asm__(".previous"); 10770657Sobrien#endif 108