Update.
[glibc.git] / sysdeps / unix / arm / start.c
blob772384727a975687e23053005497cecbddc8555d
1 /* Special startup code for ARM a.out binaries.
2 Copyright (C) 1998 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 #include <errno.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <sysdep.h>
25 /* The first piece of initialized data. */
26 int __data_start = 0;
27 #ifdef HAVE_WEAK_SYMBOLS
28 weak_alias (__data_start, data_start)
29 #endif
31 #ifndef errno
32 volatile int __errno;
33 strong_alias (__errno, errno)
34 #endif
36 extern void __libc_init __P ((int argc, char **argv, char **envp));
37 extern int main __P ((int argc, char **argv, char **envp));
39 /* N.B.: It is important that this be the first function.
40 This file is the first thing in the text section. */
42 /* If this was in C it might create its own stack frame and
43 screw up the arguments. */
44 #ifdef NO_UNDERSCORES
45 asm (".text; .globl _start; _start: B start1");
46 #else
47 asm (".text; .globl __start; __start: B _start1");
49 /* Make an alias called `start' (no leading underscore, so it can't
50 conflict with C symbols) for `_start'. This is the name vendor crt0.o's
51 tend to use, and thus the name most linkers expect. */
52 asm (".set start, __start");
53 #endif
55 /* Fool gcc into thinking that more args are passed. This makes it look
56 on the stack (correctly) for the real arguments. It causes somewhat
57 strange register usage in start1(), but we aren't too bothered about
58 that at the moment. */
59 #define DUMMIES a1, a2, a3, a4
61 #ifdef DUMMIES
62 #define ARG_DUMMIES DUMMIES,
63 #define DECL_DUMMIES int DUMMIES;
64 #else
65 #define ARG_DUMMIES
66 #define DECL_DUMMIES
67 #endif
69 /* ARGSUSED */
70 static void
71 start1 (ARG_DUMMIES argc, argv, envp)
72 DECL_DUMMIES
73 int argc;
74 char **argv;
75 char **envp;
77 /* Store a pointer to the environment. */
78 __environ = envp;
80 /* Do C library initializations. */
81 __libc_init (argc, argv, __environ);
83 /* Call the user program. */
84 exit (main (argc, argv, __environ));