Regenerated
[glibc.git] / sysdeps / unix / start.c
blobe58bb3804d1f3823d686c2a30379824c7d99d2a2
1 /* Copyright (C) 1991, 1993, 1995 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with the GNU C Library; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
18 #include <ansidecl.h>
19 #include <errno.h>
20 #include <stdlib.h>
21 #include <unistd.h>
22 #include <sysdep.h> /* In case it wants to define anything. */
24 /* The first piece of initialized data. */
25 int __data_start = 0;
26 #ifdef HAVE_WEAK_SYMBOLS
27 weak_alias (__data_start, data_start)
28 #endif
30 #ifdef DUMMIES
31 #define ARG_DUMMIES DUMMIES,
32 #define DECL_DUMMIES int DUMMIES;
33 #else
34 #define ARG_DUMMIES
35 #define DECL_DUMMIES
36 #endif
38 #ifndef errno
39 volatile int errno;
40 #endif
42 extern void EXFUN(__libc_init, (int argc, char **argv, char **envp));
43 extern int EXFUN(main, (int argc, char **argv, char **envp));
46 /* Not a prototype because it gets called strangely. */
47 static void start1();
49 #ifndef HAVE__start
51 /* N.B.: It is important that this be the first function.
52 This file is the first thing in the text section. */
53 void
54 DEFUN_VOID(_start)
56 start1();
59 #ifndef NO_UNDERSCORES
60 /* Make an alias called `start' (no leading underscore, so it can't
61 conflict with C symbols) for `_start'. This is the name vendor crt0.o's
62 tend to use, and thus the name most linkers expect. */
63 asm (".set start, __start");
64 #endif
66 #endif
68 /* ARGSUSED */
69 static void
70 start1 (ARG_DUMMIES argc, argp)
71 DECL_DUMMIES
72 int argc;
73 char *argp;
75 char **argv = &argp;
77 /* The environment starts just after ARGV. */
78 __environ = &argv[argc + 1];
80 /* If the first thing after ARGV is the arguments
81 themselves, there is no environment. */
82 if ((char *) __environ == *argv)
83 /* The environment is empty. Make __environ
84 point at ARGV[ARGC], which is NULL. */
85 --__environ;
87 /* Do C library initializations. */
88 __libc_init (argc, argv, __environ);
90 /* Call the user program. */
91 exit (main (argc, argv, __environ));