crt1.c revision 232832
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: head/lib/csu/powerpc/crt1.c 232832 2012-03-11 20:04:09Z kib $"); 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 6070657Sobrien#ifdef GCRT 6170657Sobrienextern void _mcleanup(void); 6270657Sobrienextern void monstartup(void *, void *); 6370657Sobrienextern int eprol; 6470657Sobrienextern int etext; 6570657Sobrien#endif 6670657Sobrien 6780740Smpstruct ps_strings *__ps_strings; 6870657Sobrien 69204756Suqsvoid _start(int, char **, char **, const struct Struct_Obj_Entry *, 70204756Suqs void (*)(void), struct ps_strings *); 71204756Suqs 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 84100167Smarkm environ = env; 8570657Sobrien 86232832Skib if (argc > 0 && argv[0] != NULL) 87232832Skib handle_progname(argv[0]); 8870657Sobrien 8970657Sobrien if (ps_strings != (struct ps_strings *)0) 9070657Sobrien __ps_strings = ps_strings; 9170657Sobrien 9270657Sobrien if (&_DYNAMIC != NULL) 9370657Sobrien atexit(cleanup); 94133754Sdfr else 95133754Sdfr _init_tls(); 9670657Sobrien 9770657Sobrien#ifdef GCRT 9870657Sobrien atexit(_mcleanup); 9970657Sobrien monstartup(&eprol, &etext); 10070657Sobrien#endif 101232832Skib 102232832Skib handle_static_init(argc, argv, env); 103232832Skib exit(main(argc, argv, env)); 10470657Sobrien} 10570657Sobrien 10670657Sobrien#ifdef GCRT 10770657Sobrien__asm__(".text"); 10870657Sobrien__asm__("eprol:"); 10970657Sobrien__asm__(".previous"); 11070657Sobrien#endif 111