Update copyright notices with scripts/update-copyrights.
[glibc.git] / sysdeps / unix / sysv / linux / powerpc / libc-start.c
blob5887db00a8b2fed6c4de5b8cddf37b9095afe063
1 /* Copyright (C) 1998-2013 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
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) 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 GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <ldsodefs.h>
21 #include <sysdep.h>
22 #include <bp-start.h>
23 #include <bp-sym.h>
26 int __cache_line_size attribute_hidden;
27 /* The main work is done in the generic function. */
28 #define LIBC_START_MAIN generic_start_main
29 #define LIBC_START_DISABLE_INLINE
30 #define LIBC_START_MAIN_AUXVEC_ARG
31 #define MAIN_AUXVEC_ARG
32 #define INIT_MAIN_ARGS
33 #include <csu/libc-start.c>
35 struct startup_info
37 void *__unbounded sda_base;
38 int (*main) (int, char **, char **, void *);
39 int (*init) (int, char **, char **, void *);
40 void (*fini) (void);
43 int
44 /* GKM FIXME: GCC: this should get __BP_ prefix by virtue of the
45 BPs in the arglist of startup_info.main and startup_info.init. */
46 BP_SYM (__libc_start_main) (int argc, char *__unbounded *__unbounded ubp_av,
47 char *__unbounded *__unbounded ubp_ev,
48 ElfW (auxv_t) * __unbounded auxvec,
49 void (*rtld_fini) (void),
50 struct startup_info *__unbounded stinfo,
51 char *__unbounded *__unbounded stack_on_entry)
53 #if __BOUNDED_POINTERS__
54 char **argv;
55 #else
56 # define argv ubp_av
57 #endif
59 /* the PPC SVR4 ABI says that the top thing on the stack will
60 be a NULL pointer, so if not we assume that we're being called
61 as a statically-linked program by Linux... */
62 if (*stack_on_entry != NULL)
64 char *__unbounded * __unbounded temp;
65 /* ...in which case, we have argc as the top thing on the
66 stack, followed by argv (NULL-terminated), envp (likewise),
67 and the auxilary vector. */
68 /* 32/64-bit agnostic load from stack */
69 argc = *(long int *__unbounded) stack_on_entry;
70 ubp_av = stack_on_entry + 1;
71 ubp_ev = ubp_av + argc + 1;
72 #ifdef HAVE_AUX_VECTOR
73 temp = ubp_ev;
74 while (*temp != NULL)
75 ++temp;
76 auxvec = (ElfW (auxv_t) *)++ temp;
77 #endif
78 rtld_fini = NULL;
81 /* Initialize the __cache_line_size variable from the aux vector. */
82 for (ElfW (auxv_t) * av = auxvec; av->a_type != AT_NULL; ++av)
83 switch (av->a_type)
85 case AT_DCACHEBSIZE:
86 __cache_line_size = av->a_un.a_val;
87 break;
90 return generic_start_main (stinfo->main, argc, ubp_av, auxvec,
91 stinfo->init, stinfo->fini, rtld_fini,
92 stack_on_entry);