1 /* Startup code compliant to the ELF PowerPC ABI.
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 /* This is SVR4/PPC ABI compliant, and works under Linux when
26 /* Just a little assembler stub before gcc gets its hands on our
32 # save the stack pointer, in case we're statically linked under Linux
34 # set up an initial stack frame, and clear the LR
40 # set r13 to point at the 'small data area'
42 addi 13,13,_SDA_BASE_@l
47 /* Define a symbol for the first piece of initialized data. */
49 weak_alias (__data_start, data_start)
51 /* these probably should go, at least go somewhere else
52 (sysdeps/mach/something?). */
53 void (*_mach_init_routine) (void);
54 void (*_thread_init_routine) (void);
56 void __libc_init_first (int argc, char **argv, char **envp);
57 int main (int argc, char **argv, char **envp, void *auxvec);
64 static void __start1(int argc, char **argv, char **envp,
65 void *auxvec, void (*exitfn) (void), char **arguments)
66 __attribute__ ((unused));
68 __start1(int argc, char **argv, char **envp,
69 void *auxvec, void (*exitfn) (void),
72 /* the PPC SVR4 ABI says that the top thing on the stack will
73 be a NULL pointer, so if not we assume that we're being called
74 as a statically-linked program by Linux. */
75 int abi_compliant_startup = *arguments == NULL;
77 if (!abi_compliant_startup)
79 argc = *(int *) arguments;
83 while (auxvec != NULL)
92 /* libc init routine, in case we are statically linked
93 (otherwise ld.so will have called it when it loaded libc, but
94 calling it twice doesn't hurt). */
95 __libc_init_first (argc, argv, envp);
98 /* ELF constructors/destructors */
103 /* Stuff so we can build Mach/Linux executables (like vmlinux). */
104 if (_mach_init_routine != 0)
105 _mach_init_routine ();
106 if (_thread_init_routine != 0)
107 _thread_init_routine ();
109 /* the rest of the program */
110 exit (main (argc, argv, envp, auxvec));