2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / powerpc / libc-start.c
blob1e6fce42f70d2f99d89989a76499ea0353569c2d
1 /* Copyright (C) 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2007
2 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 Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <stdlib.h>
21 #include <unistd.h>
22 #include <ldsodefs.h>
23 #include <sysdep.h>
24 #include <bp-start.h>
25 #include <bp-sym.h>
28 int __cache_line_size attribute_hidden;
29 /* The main work is done in the generic function. */
30 #define LIBC_START_MAIN generic_start_main
31 #define LIBC_START_DISABLE_INLINE
32 #define LIBC_START_MAIN_AUXVEC_ARG
33 #define MAIN_AUXVEC_ARG
34 #define INIT_MAIN_ARGS
35 #include <csu/libc-start.c>
37 struct startup_info
39 void *__unbounded sda_base;
40 int (*main) (int, char **, char **, void *);
41 int (*init) (int, char **, char **, void *);
42 void (*fini) (void);
45 int
46 /* GKM FIXME: GCC: this should get __BP_ prefix by virtue of the
47 BPs in the arglist of startup_info.main and startup_info.init. */
48 BP_SYM (__libc_start_main) (int argc, char *__unbounded *__unbounded ubp_av,
49 char *__unbounded *__unbounded ubp_ev,
50 ElfW (auxv_t) * __unbounded auxvec,
51 void (*rtld_fini) (void),
52 struct startup_info *__unbounded stinfo,
53 char *__unbounded *__unbounded stack_on_entry)
55 #if __BOUNDED_POINTERS__
56 char **argv;
57 #else
58 # define argv ubp_av
59 #endif
61 /* the PPC SVR4 ABI says that the top thing on the stack will
62 be a NULL pointer, so if not we assume that we're being called
63 as a statically-linked program by Linux... */
64 if (*stack_on_entry != NULL)
66 char *__unbounded * __unbounded temp;
67 /* ...in which case, we have argc as the top thing on the
68 stack, followed by argv (NULL-terminated), envp (likewise),
69 and the auxilary vector. */
70 /* 32/64-bit agnostic load from stack */
71 argc = *(long int *__unbounded) stack_on_entry;
72 ubp_av = stack_on_entry + 1;
73 ubp_ev = ubp_av + argc + 1;
74 #ifdef HAVE_AUX_VECTOR
75 temp = ubp_ev;
76 while (*temp != NULL)
77 ++temp;
78 auxvec = (ElfW (auxv_t) *)++ temp;
79 #endif
80 rtld_fini = NULL;
83 /* Initialize the __cache_line_size variable from the aux vector. */
84 for (ElfW (auxv_t) * av = auxvec; av->a_type != AT_NULL; ++av)
85 switch (av->a_type)
87 case AT_DCACHEBSIZE:
88 __cache_line_size = av->a_un.a_val;
89 break;
92 return generic_start_main (stinfo->main, argc, ubp_av, auxvec,
93 stinfo->init, stinfo->fini, rtld_fini,
94 stack_on_entry);