(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / sysdeps / powerpc / elf / libc-start.c
blobeed3e06c8a16e34c4334b3858723db40366aed1c
1 /* Copyright (C) 1998,2000,2001,2002,2003,2004 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, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #include <stdlib.h>
20 #include <unistd.h>
21 #include <ldsodefs.h>
22 #include <bp-start.h>
23 #include <bp-sym.h>
25 extern int __cache_line_size;
26 weak_extern (__cache_line_size)
28 /* The main work is done in the generic function. */
29 #define LIBC_START_MAIN generic_start_main
30 #define LIBC_START_DISABLE_INLINE
31 #define LIBC_START_MAIN_AUXVEC_ARG
32 #define MAIN_AUXVEC_ARG
33 #define INIT_MAIN_ARGS
34 #include <sysdeps/generic/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);
46 int
47 /* GKM FIXME: GCC: this should get __BP_ prefix by virtue of the
48 BPs in the arglist of startup_info.main and startup_info.init. */
49 BP_SYM (__libc_start_main) (int argc, char *__unbounded *__unbounded ubp_av,
50 char *__unbounded *__unbounded ubp_ev,
51 ElfW(auxv_t) *__unbounded auxvec,
52 void (*rtld_fini) (void),
53 struct startup_info *__unbounded stinfo,
54 char *__unbounded *__unbounded stack_on_entry)
56 #if __BOUNDED_POINTERS__
57 char **argv;
58 #else
59 # define argv ubp_av
60 #endif
62 /* the PPC SVR4 ABI says that the top thing on the stack will
63 be a NULL pointer, so if not we assume that we're being called
64 as a statically-linked program by Linux... */
65 if (*stack_on_entry != NULL)
67 char *__unbounded *__unbounded temp;
68 /* ...in which case, we have argc as the top thing on the
69 stack, followed by argv (NULL-terminated), envp (likewise),
70 and the auxilary vector. */
71 /* 32/64-bit agnostic load from stack */
72 argc = *(long int *__unbounded) stack_on_entry;
73 ubp_av = stack_on_entry + 1;
74 ubp_ev = ubp_av + argc + 1;
75 #ifdef HAVE_AUX_VECTOR
76 temp = ubp_ev;
77 while (*temp != NULL)
78 ++temp;
79 auxvec = (ElfW(auxv_t) *)++temp;
80 #endif
81 rtld_fini = NULL;
84 /* Initialize the __cache_line_size variable from the aux vector. */
85 for (ElfW(auxv_t) *av = auxvec; av->a_type != AT_NULL; ++av)
86 switch (av->a_type)
88 case AT_DCACHEBSIZE:
90 int *cls = & __cache_line_size;
91 if (cls != NULL)
92 *cls = av->a_un.a_val;
94 break;
97 return generic_start_main (stinfo->main, argc, ubp_av, auxvec,
98 stinfo->init, stinfo->fini, rtld_fini,
99 stack_on_entry);