95e7cf295e
Long ago static startup did not parse the auxiliary vector and therefore
could not get at any `AT_FPUCW' tag to check whether upon FPU context
allocation the kernel would use a FPU control word setting different to
that provided by the `__fpu_control' variable. Static startup therefore
always initialized the FPU control word, forcing immediate FPU context
allocation even for binaries that otherwise never used the FPU.
As from GIT commit f8f900ecb9
static
startup supports parsing the auxiliary vector, so now it can avoid
explicit initialization of the FPU control word, just as can dynamic
startup, in the usual case where the setting written to the FPU control
word would be the same as the kernel uses. This defers FPU context
allocation until the binary itself actually pokes at the FPU.
Note that the `AT_FPUCW' tag is usually absent from the auxiliary vector
in which case _FPU_DEFAULT is assumed to be the kernel default.
113 lines
3.1 KiB
C
113 lines
3.1 KiB
C
/* Initialization code run first thing by the ELF startup code. Common version
|
|
Copyright (C) 1995-2013 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#include <ctype.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <sysdep.h>
|
|
#include <fpu_control.h>
|
|
#include <sys/param.h>
|
|
#include <sys/types.h>
|
|
#include <libc-internal.h>
|
|
|
|
#include <ldsodefs.h>
|
|
|
|
/* Set nonzero if we have to be prepared for more than one libc being
|
|
used in the process. Safe assumption if initializer never runs. */
|
|
int __libc_multiple_libcs attribute_hidden = 1;
|
|
|
|
/* Remember the command line argument and enviroment contents for
|
|
later calls of initializers for dynamic libraries. */
|
|
int __libc_argc attribute_hidden;
|
|
char **__libc_argv attribute_hidden;
|
|
|
|
|
|
void
|
|
__libc_init_first (int argc, char **argv, char **envp)
|
|
{
|
|
#ifdef SHARED
|
|
/* For DSOs we do not need __libc_init_first but instead _init. */
|
|
}
|
|
|
|
void
|
|
attribute_hidden
|
|
_init (int argc, char **argv, char **envp)
|
|
{
|
|
#endif
|
|
#ifdef USE_NONOPTION_FLAGS
|
|
extern void __getopt_clean_environment (char **);
|
|
#endif
|
|
|
|
__libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
|
|
|
|
/* Make sure we don't initialize twice. */
|
|
if (!__libc_multiple_libcs)
|
|
{
|
|
/* Set the FPU control word to the proper default value if the
|
|
kernel would use a different value. */
|
|
if (__fpu_control != GLRO(dl_fpu_control))
|
|
__setfpucw (__fpu_control);
|
|
}
|
|
|
|
/* Save the command-line arguments. */
|
|
__libc_argc = argc;
|
|
__libc_argv = argv;
|
|
__environ = envp;
|
|
|
|
#ifndef SHARED
|
|
__libc_init_secure ();
|
|
|
|
/* First the initialization which normally would be done by the
|
|
dynamic linker. */
|
|
_dl_non_dynamic_init ();
|
|
#endif
|
|
|
|
#ifdef VDSO_SETUP
|
|
VDSO_SETUP ();
|
|
#endif
|
|
|
|
__init_misc (argc, argv, envp);
|
|
|
|
#ifdef USE_NONOPTION_FLAGS
|
|
/* This is a hack to make the special getopt in GNU libc working. */
|
|
__getopt_clean_environment (envp);
|
|
#endif
|
|
|
|
/* Initialize ctype data. */
|
|
__ctype_init ();
|
|
|
|
#if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
|
|
__libc_global_ctors ();
|
|
#endif
|
|
}
|
|
|
|
/* This function is defined here so that if this file ever gets into
|
|
ld.so we will get a link error. Having this file silently included
|
|
in ld.so causes disaster, because the _init definition above will
|
|
cause ld.so to gain an init function, which is not a cool thing. */
|
|
|
|
extern void _dl_start (void) __attribute__ ((noreturn));
|
|
|
|
void
|
|
_dl_start (void)
|
|
{
|
|
abort ();
|
|
}
|