Back to index

glibc  2.9
Go to the documentation of this file.
00001 /* Special startup code for ARM a.out binaries.
00002    Copyright (C) 1998, 2004 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00010    In addition to the permissions in the GNU Lesser General Public
00011    License, the Free Software Foundation gives you unlimited
00012    permission to link the compiled version of this file with other
00013    programs, and to distribute those programs without any restriction
00014    coming from the use of this file. (The GNU Lesser General Public
00015    License restrictions do apply in other respects; for example, they
00016    cover modification of the file, and distribution when not linked
00017    into another program.)
00019    Note that people who make modified versions of this file are not
00020    obligated to grant this special exception for their modified
00021    versions; it is their choice whether to do so. The GNU Lesser
00022    General Public License gives permission to release a modified
00023    version without this exception; this exception also makes it
00024    possible to release a modified version which carries forward this
00025    exception.
00027    The GNU C Library is distributed in the hope that it will be useful,
00028    but WITHOUT ANY WARRANTY; without even the implied warranty of
00030    Lesser General Public License for more details.
00032    You should have received a copy of the GNU Lesser General Public
00033    License along with the GNU C Library; if not, write to the Free
00034    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00035    02111-1307 USA.  */
00037 #include <errno.h>
00038 #include <stdlib.h>
00039 #include <unistd.h>
00040 #include <sysdep.h>
00042 /* The first piece of initialized data.  */
00043 int __data_start = 0;
00044 #ifdef HAVE_WEAK_SYMBOLS
00045 weak_alias (__data_start, data_start)
00046 #endif
00048 extern void __libc_init (int argc, char **argv, char **envp);
00049 extern int main (int argc, char **argv, char **envp);
00051 /* N.B.: It is important that this be the first function.
00052    This file is the first thing in the text section.  */
00054 /* If this was in C it might create its own stack frame and
00055    screw up the arguments.  */
00056 #ifdef NO_UNDERSCORES
00057 asm (".text; .globl _start; _start: B start1");
00058 #else
00059 asm (".text; .globl __start; __start: B _start1");
00061 /* Make an alias called `start' (no leading underscore, so it can't
00062    conflict with C symbols) for `_start'.  This is the name vendor crt0.o's
00063    tend to use, and thus the name most linkers expect.  */
00064 asm (".set start, __start");
00065 #endif
00067 /* Fool gcc into thinking that more args are passed.  This makes it look
00068    on the stack (correctly) for the real arguments.  It causes somewhat
00069    strange register usage in start1(), but we aren't too bothered about
00070    that at the moment. */
00071 #define DUMMIES a1, a2, a3, a4
00073 #ifdef DUMMIES
00074 #define       ARG_DUMMIES   DUMMIES,
00075 #define       DECL_DUMMIES  int DUMMIES;
00076 #else
00077 #define       ARG_DUMMIES
00078 #define       DECL_DUMMIES
00079 #endif
00081 /* ARGSUSED */
00082 static void
00083 start1 (ARG_DUMMIES argc, argv, envp)
00084      DECL_DUMMIES
00085      int argc;
00086      char **argv;
00087      char **envp;
00088 {
00089   /* Store a pointer to the environment.  */
00090   __environ = envp;
00092   /* Do C library initializations.  */
00093   __libc_init (argc, argv, __environ);
00095   /* Call the user program.  */
00096   exit (main (argc, argv, __environ));
00097 }