Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / unix / sysv / linux / powerpc / libc-start.c
bloba9364c786a24d42293e0d6312decf4612093d48b
1 /* Copyright (C) 1998-2015 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>
24 int __cache_line_size attribute_hidden;
25 /* The main work is done in the generic function. */
26 #define LIBC_START_MAIN generic_start_main
27 #define LIBC_START_DISABLE_INLINE
28 #define LIBC_START_MAIN_AUXVEC_ARG
29 #define MAIN_AUXVEC_ARG
30 #define INIT_MAIN_ARGS
31 #include <csu/libc-start.c>
33 struct startup_info
35 void *sda_base;
36 int (*main) (int, char **, char **, void *);
37 int (*init) (int, char **, char **, void *);
38 void (*fini) (void);
41 int
42 __libc_start_main (int argc, char **argv,
43 char **ev,
44 ElfW (auxv_t) * auxvec,
45 void (*rtld_fini) (void),
46 struct startup_info *stinfo,
47 char **stack_on_entry)
49 /* the PPC SVR4 ABI says that the top thing on the stack will
50 be a NULL pointer, so if not we assume that we're being called
51 as a statically-linked program by Linux... */
52 if (*stack_on_entry != NULL)
54 char **temp;
55 /* ...in which case, we have argc as the top thing on the
56 stack, followed by argv (NULL-terminated), envp (likewise),
57 and the auxiliary vector. */
58 /* 32/64-bit agnostic load from stack */
59 argc = *(long int *) stack_on_entry;
60 argv = stack_on_entry + 1;
61 ev = argv + argc + 1;
62 #ifdef HAVE_AUX_VECTOR
63 temp = ev;
64 while (*temp != NULL)
65 ++temp;
66 auxvec = (ElfW (auxv_t) *)++ temp;
67 #endif
68 rtld_fini = NULL;
71 /* Initialize the __cache_line_size variable from the aux vector. */
72 for (ElfW (auxv_t) * av = auxvec; av->a_type != AT_NULL; ++av)
73 switch (av->a_type)
75 case AT_DCACHEBSIZE:
76 __cache_line_size = av->a_un.a_val;
77 break;
80 return generic_start_main (stinfo->main, argc, argv, auxvec,
81 stinfo->init, stinfo->fini, rtld_fini,
82 stack_on_entry);