|
Packit |
6c4009 |
/* Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <stdlib.h>
|
|
Packit |
6c4009 |
#include <unistd.h>
|
|
Packit |
6c4009 |
#include <ldsodefs.h>
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef SHARED
|
|
Packit |
6c4009 |
#include <hwcapinfo.h>
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
int __cache_line_size attribute_hidden;
|
|
Packit |
6c4009 |
/* The main work is done in the generic function. */
|
|
Packit |
6c4009 |
#define LIBC_START_MAIN generic_start_main
|
|
Packit |
6c4009 |
#define LIBC_START_DISABLE_INLINE
|
|
Packit |
6c4009 |
#define LIBC_START_MAIN_AUXVEC_ARG
|
|
Packit |
6c4009 |
#define MAIN_AUXVEC_ARG
|
|
Packit |
6c4009 |
#define INIT_MAIN_ARGS
|
|
Packit |
6c4009 |
#include <csu/libc-start.c>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
struct startup_info
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
void *sda_base;
|
|
Packit |
6c4009 |
int (*main) (int, char **, char **, void *);
|
|
Packit |
6c4009 |
int (*init) (int, char **, char **, void *);
|
|
Packit |
6c4009 |
void (*fini) (void);
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
int
|
|
Packit |
6c4009 |
__libc_start_main (int argc, char **argv,
|
|
Packit |
6c4009 |
char **ev,
|
|
Packit |
6c4009 |
ElfW (auxv_t) * auxvec,
|
|
Packit |
6c4009 |
void (*rtld_fini) (void),
|
|
Packit |
6c4009 |
struct startup_info *stinfo,
|
|
Packit |
6c4009 |
char **stack_on_entry)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* the PPC SVR4 ABI says that the top thing on the stack will
|
|
Packit |
6c4009 |
be a NULL pointer, so if not we assume that we're being called
|
|
Packit |
6c4009 |
as a statically-linked program by Linux... */
|
|
Packit |
6c4009 |
if (*stack_on_entry != NULL)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
char **temp;
|
|
Packit |
6c4009 |
/* ...in which case, we have argc as the top thing on the
|
|
Packit |
6c4009 |
stack, followed by argv (NULL-terminated), envp (likewise),
|
|
Packit |
6c4009 |
and the auxiliary vector. */
|
|
Packit |
6c4009 |
/* 32/64-bit agnostic load from stack */
|
|
Packit |
6c4009 |
argc = *(long int *) stack_on_entry;
|
|
Packit |
6c4009 |
argv = stack_on_entry + 1;
|
|
Packit |
6c4009 |
ev = argv + argc + 1;
|
|
Packit |
6c4009 |
#ifdef HAVE_AUX_VECTOR
|
|
Packit |
6c4009 |
temp = ev;
|
|
Packit |
6c4009 |
while (*temp != NULL)
|
|
Packit |
6c4009 |
++temp;
|
|
Packit |
6c4009 |
auxvec = (ElfW (auxv_t) *)++ temp;
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
rtld_fini = NULL;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Initialize the __cache_line_size variable from the aux vector. For the
|
|
Packit |
6c4009 |
static case, we also need _dl_hwcap, _dl_hwcap2 and _dl_platform, so we
|
|
Packit |
6c4009 |
can call __tcb_parse_hwcap_and_convert_at_platform (). */
|
|
Packit |
6c4009 |
for (ElfW (auxv_t) * av = auxvec; av->a_type != AT_NULL; ++av)
|
|
Packit |
6c4009 |
switch (av->a_type)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
case AT_DCACHEBSIZE:
|
|
Packit |
6c4009 |
__cache_line_size = av->a_un.a_val;
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
#ifndef SHARED
|
|
Packit |
6c4009 |
case AT_HWCAP:
|
|
Packit |
6c4009 |
_dl_hwcap = (unsigned long int) av->a_un.a_val;
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
case AT_HWCAP2:
|
|
Packit |
6c4009 |
_dl_hwcap2 = (unsigned long int) av->a_un.a_val;
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
case AT_PLATFORM:
|
|
Packit |
6c4009 |
_dl_platform = (void *) av->a_un.a_val;
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Initialize hwcap/hwcap2 and platform data so it can be copied to
|
|
Packit |
6c4009 |
the TCB later in __libc_setup_tls (). (static case only). */
|
|
Packit |
6c4009 |
#ifndef SHARED
|
|
Packit |
6c4009 |
__tcb_parse_hwcap_and_convert_at_platform ();
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return generic_start_main (stinfo->main, argc, argv, auxvec,
|
|
Packit |
6c4009 |
stinfo->init, stinfo->fini, rtld_fini,
|
|
Packit |
6c4009 |
stack_on_entry);
|
|
Packit |
6c4009 |
}
|