2.5-18.1
[glibc.git] / sysdeps / unix / sysv / linux / powerpc / libc-start.c
bloba8005c116316043306f9526962df493731983527
1 /* Copyright (C) 1998,2000,2001,2002,2003,2004,2005 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)
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);
44 #ifdef SHARED
45 # include <sys/time.h>
46 # include <dl-vdso.h>
47 # undef __gettimeofday
48 # undef __clock_gettime
49 # undef __clock_getres
50 # include <bits/libc-vdso.h>
52 void *__vdso_gettimeofday;
53 void *__vdso_clock_gettime;
54 void *__vdso_clock_getres;
55 void *__vdso_get_tbfreq;
57 static inline void _libc_vdso_platform_setup (void)
59 __vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday",
60 "LINUX_2.6.15");
62 __vdso_clock_gettime = _dl_vdso_vsym ("__kernel_clock_gettime",
63 "LINUX_2.6.15");
65 __vdso_clock_getres = _dl_vdso_vsym ("__kernel_clock_getres",
66 "LINUX_2.6.15");
68 __vdso_get_tbfreq = _dl_vdso_vsym ("__kernel_vdso_get_tbfreq",
69 "LINUX_2.6.15");
71 #endif
73 int
74 /* GKM FIXME: GCC: this should get __BP_ prefix by virtue of the
75 BPs in the arglist of startup_info.main and startup_info.init. */
76 BP_SYM (__libc_start_main) (int argc, char *__unbounded *__unbounded ubp_av,
77 char *__unbounded *__unbounded ubp_ev,
78 ElfW (auxv_t) * __unbounded auxvec,
79 void (*rtld_fini) (void),
80 struct startup_info *__unbounded stinfo,
81 char *__unbounded *__unbounded stack_on_entry)
83 #if __BOUNDED_POINTERS__
84 char **argv;
85 #else
86 # define argv ubp_av
87 #endif
89 /* the PPC SVR4 ABI says that the top thing on the stack will
90 be a NULL pointer, so if not we assume that we're being called
91 as a statically-linked program by Linux... */
92 if (*stack_on_entry != NULL)
94 char *__unbounded * __unbounded temp;
95 /* ...in which case, we have argc as the top thing on the
96 stack, followed by argv (NULL-terminated), envp (likewise),
97 and the auxilary vector. */
98 /* 32/64-bit agnostic load from stack */
99 argc = *(long int *__unbounded) stack_on_entry;
100 ubp_av = stack_on_entry + 1;
101 ubp_ev = ubp_av + argc + 1;
102 #ifdef HAVE_AUX_VECTOR
103 temp = ubp_ev;
104 while (*temp != NULL)
105 ++temp;
106 auxvec = (ElfW (auxv_t) *)++ temp;
107 #endif
108 rtld_fini = NULL;
111 /* Initialize the __cache_line_size variable from the aux vector. */
112 for (ElfW (auxv_t) * av = auxvec; av->a_type != AT_NULL; ++av)
113 switch (av->a_type)
115 case AT_DCACHEBSIZE:
117 int *cls = &__cache_line_size;
118 if (cls != NULL)
119 *cls = av->a_un.a_val;
121 break;
123 #ifdef SHARED
124 /* Resolve and initialize function pointers for VDSO functions. */
125 _libc_vdso_platform_setup ();
126 #endif
127 return generic_start_main (stinfo->main, argc, ubp_av, auxvec,
128 stinfo->init, stinfo->fini, rtld_fini,
129 stack_on_entry);