]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/powerpc/libc-start.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / powerpc / libc-start.c
CommitLineData
d614a753 1/* Copyright (C) 1998-2020 Free Software Foundation, Inc.
66000494
UD
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
66000494
UD
8
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
41bdb6e2 12 Lesser General Public License for more details.
66000494 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6 15 License along with the GNU C Library; if not, see
5a82c748 16 <https://www.gnu.org/licenses/>. */
66000494
UD
17
18#include <stdlib.h>
19#include <unistd.h>
a42195db 20#include <ldsodefs.h>
6df7ffad 21#include <sysdep.h>
66000494 22
67385a01
CES
23#ifndef SHARED
24#include <hwcapinfo.h>
25#endif
8c2e201b 26
75fb247e
UD
27int __cache_line_size attribute_hidden;
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 <csu/libc-start.c>
35
36struct startup_info
37 {
70d9946a 38 void *sda_base;
75fb247e
UD
39 int (*main) (int, char **, char **, void *);
40 int (*init) (int, char **, char **, void *);
41 void (*fini) (void);
42 };
43
66000494 44int
e97ed6dd
JM
45__libc_start_main (int argc, char **argv,
46 char **ev,
47 ElfW (auxv_t) * auxvec,
48 void (*rtld_fini) (void),
49 struct startup_info *stinfo,
50 char **stack_on_entry)
66000494 51{
66000494
UD
52 /* the PPC SVR4 ABI says that the top thing on the stack will
53 be a NULL pointer, so if not we assume that we're being called
8c2e201b 54 as a statically-linked program by Linux... */
66000494
UD
55 if (*stack_on_entry != NULL)
56 {
70d9946a 57 char **temp;
66000494 58 /* ...in which case, we have argc as the top thing on the
8c2e201b 59 stack, followed by argv (NULL-terminated), envp (likewise),
6f65e668 60 and the auxiliary vector. */
1010f17b 61 /* 32/64-bit agnostic load from stack */
70d9946a
JM
62 argc = *(long int *) stack_on_entry;
63 argv = stack_on_entry + 1;
64 ev = argv + argc + 1;
f58f41f1 65#ifdef HAVE_AUX_VECTOR
70d9946a 66 temp = ev;
b8a5737a 67 while (*temp != NULL)
8c2e201b
UD
68 ++temp;
69 auxvec = (ElfW (auxv_t) *)++ temp;
51ac41a7 70#endif
66000494
UD
71 rtld_fini = NULL;
72 }
73
67385a01
CES
74 /* Initialize the __cache_line_size variable from the aux vector. For the
75 static case, we also need _dl_hwcap, _dl_hwcap2 and _dl_platform, so we
76 can call __tcb_parse_hwcap_and_convert_at_platform (). */
8c2e201b 77 for (ElfW (auxv_t) * av = auxvec; av->a_type != AT_NULL; ++av)
1e084487
UD
78 switch (av->a_type)
79 {
80 case AT_DCACHEBSIZE:
fa03b94e 81 __cache_line_size = av->a_un.a_val;
8c2e201b 82 break;
67385a01
CES
83#ifndef SHARED
84 case AT_HWCAP:
85 _dl_hwcap = (unsigned long int) av->a_un.a_val;
86 break;
87 case AT_HWCAP2:
88 _dl_hwcap2 = (unsigned long int) av->a_un.a_val;
89 break;
90 case AT_PLATFORM:
91 _dl_platform = (void *) av->a_un.a_val;
92 break;
93#endif
1e084487 94 }
75fb247e 95
67385a01
CES
96 /* Initialize hwcap/hwcap2 and platform data so it can be copied to
97 the TCB later in __libc_setup_tls (). (static case only). */
98#ifndef SHARED
99 __tcb_parse_hwcap_and_convert_at_platform ();
100#endif
101
70d9946a 102 return generic_start_main (stinfo->main, argc, argv, auxvec,
124dcac8
RM
103 stinfo->init, stinfo->fini, rtld_fini,
104 stack_on_entry);
66000494 105}