crt1.c revision 245133
1193326Sed/* LINTLIBRARY */ 2193326Sed/*- 3193326Sed * Copyright 2001 David E. O'Brien. 4193326Sed * All rights reserved. 5193326Sed * Copyright 1996-1998 John D. Polstra. 6193326Sed * All rights reserved. 7193326Sed * Copyright (c) 1997 Jason R. Thorpe. 8193326Sed * Copyright (c) 1995 Christopher G. Demetriou 9193326Sed * All rights reserved. 10193326Sed * 11193326Sed * Redistribution and use in source and binary forms, with or without 12193326Sed * modification, are permitted provided that the following conditions 13193326Sed * are met: 14212904Sdim * 1. Redistributions of source code must retain the above copyright 15193326Sed * notice, this list of conditions and the following disclaimer. 16198092Srdivacky * 2. Redistributions in binary form must reproduce the above copyright 17193326Sed * notice, this list of conditions and the following disclaimer in the 18193326Sed * documentation and/or other materials provided with the distribution. 19234353Sdim * 3. All advertising materials mentioning features or use of this software 20193326Sed * must display the following acknowledgement: 21193326Sed * This product includes software developed for the 22193326Sed * FreeBSD Project. See http://www.freebsd.org/ for 23198092Srdivacky * information about FreeBSD. 24194179Sed * This product includes software developed for the 25193326Sed * NetBSD Project. See http://www.netbsd.org/ for 26249423Sdim * information about NetBSD. 27249423Sdim * 4. The name of the author may not be used to endorse or promote products 28249423Sdim * derived from this software without specific prior written permission 29249423Sdim * 30249423Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 31249423Sdim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 32249423Sdim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 33249423Sdim * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 34249423Sdim * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 35249423Sdim * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 36234353Sdim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 37193326Sed * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38218893Sdim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 39226633Sdim * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 40234353Sdim */ 41198092Srdivacky 42234353Sdim#include <sys/cdefs.h> 43234353Sdim__FBSDID("$FreeBSD: head/lib/csu/powerpc/crt1.c 245133 2013-01-07 17:58:27Z kib $"); 44218893Sdim 45201361Srdivacky#ifndef lint 46234353Sdim#ifndef __GNUC__ 47193326Sed#error "GCC is needed to compile this file" 48234353Sdim#endif 49193326Sed#endif /* lint */ 50193326Sed 51193326Sed#include <stdlib.h> 52212904Sdim 53193326Sed#include "libc_private.h" 54199482Srdivacky#include "crtbrand.c" 55199482Srdivacky#include "ignore_init.c" 56199482Srdivacky 57199482Srdivackystruct Struct_Obj_Entry; 58193326Sedstruct ps_strings; 59199482Srdivacky 60199482Srdivacky#ifdef GCRT 61199482Srdivackyextern void _mcleanup(void); 62199482Srdivackyextern void monstartup(void *, void *); 63199482Srdivackyextern int eprol; 64193326Sedextern int etext; 65199482Srdivacky#endif 66199482Srdivacky 67199482Srdivackystruct ps_strings *__ps_strings; 68193326Sed 69199482Srdivackyvoid _start(int, char **, char **, const struct Struct_Obj_Entry *, 70199482Srdivacky void (*)(void), struct ps_strings *); 71199482Srdivacky 72193326Sed/* The entry function. */ 73199482Srdivacky/* 74199482Srdivacky * First 5 arguments are specified by the PowerPC SVR4 ABI. 75199482Srdivacky * The last argument, ps_strings, is a BSD extension. 76199482Srdivacky */ 77199482Srdivacky/* ARGSUSED */ 78193326Sedvoid 79199482Srdivacky_start(int argc, char **argv, char **env, 80199482Srdivacky const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void), 81199482Srdivacky struct ps_strings *ps_strings) 82193326Sed{ 83199482Srdivacky 84199482Srdivacky 85199482Srdivacky handle_argv(argc, argv, env); 86199482Srdivacky 87199482Srdivacky if (ps_strings != (struct ps_strings *)0) 88193326Sed __ps_strings = ps_strings; 89199482Srdivacky 90199482Srdivacky if (&_DYNAMIC != NULL) 91199482Srdivacky atexit(cleanup); 92226633Sdim else 93193326Sed _init_tls(); 94199482Srdivacky 95199482Srdivacky#ifdef GCRT 96193326Sed atexit(_mcleanup); 97199482Srdivacky monstartup(&eprol, &etext); 98199482Srdivacky#endif 99193326Sed 100199482Srdivacky handle_static_init(argc, argv, env); 101218893Sdim exit(main(argc, argv, env)); 102199482Srdivacky} 103199482Srdivacky 104199482Srdivacky#ifdef GCRT 105263508Sdim__asm__(".text"); 106199482Srdivacky__asm__("eprol:"); 107193326Sed__asm__(".previous"); 108199482Srdivacky#endif 109234353Sdim