Files
glibc/sysdeps/unix/sysv/linux/init-first.c
T

110 lines
3.1 KiB
C
Raw Normal View History

/* Initialization code run first thing by the ELF startup code. Linux version.
Copyright (C) 1995-2004, 2005 Free Software Foundation, Inc.
1996-11-28 04:16:09 +00:00
This file is part of the GNU C Library.
1996-11-28 04:16:09 +00:00
The GNU C Library is free software; you can redistribute it and/or
2001-07-06 04:58:11 +00:00
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.
1996-11-28 04:16:09 +00:00
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
2001-07-06 04:58:11 +00:00
Lesser General Public License for more details.
2001-07-06 04:58:11 +00:00
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
1999-05-26 23:37:38 +00:00
#include <stdio.h>
2000-04-22 07:19:25 +00:00
#include <stdlib.h>
1999-05-26 23:37:38 +00:00
#include <fcntl.h>
#include <unistd.h>
#include <sysdep.h>
#include <fpu_control.h>
1999-05-26 23:37:38 +00:00
#include <sys/param.h>
1997-02-10 03:19:57 +00:00
#include <sys/types.h>
2000-12-31 19:13:04 +00:00
#include <libc-internal.h>
2002-02-01 01:33:04 +00:00
#include <ldsodefs.h>
2000-08-22 17:48:22 +00:00
1996-08-19 01:07:44 +00:00
/* Set nonzero if we have to be prepared for more then one libc being
used in the process. Safe assumption if initializer never runs. */
2002-03-13 06:33:52 +00:00
int __libc_multiple_libcs attribute_hidden = 1;
1996-08-07 23:50:59 +00:00
1996-08-26 10:28:45 +00:00
/* Remember the command line argument and enviroment contents for
later calls of initializers for dynamic libraries. */
2002-03-13 02:17:12 +00:00
int __libc_argc attribute_hidden;
char **__libc_argv attribute_hidden;
1996-08-26 10:28:45 +00:00
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
2001-08-11 20:40:40 +00:00
#ifdef USE_NONOPTION_FLAGS
1997-08-24 10:55:18 +00:00
extern void __getopt_clean_environment (char **);
2001-08-11 20:40:40 +00:00
#endif
2002-10-24 19:14:59 +00:00
__libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
2000-03-04 01:04:33 +00:00
/* Make sure we don't initialize twice. */
1996-08-19 01:07:44 +00:00
if (!__libc_multiple_libcs)
1996-08-07 23:50:59 +00:00
{
1998-09-20 09:48:01 +00:00
/* Set the FPU control word to the proper default value if the
1998-09-22 19:08:42 +00:00
kernel would use a different value. (In a static program we
don't have this information.) */
2000-03-31 05:50:02 +00:00
#ifdef SHARED
2004-03-05 10:29:47 +00:00
if (__fpu_control != GLRO(dl_fpu_control))
1998-09-22 19:08:42 +00:00
#endif
1998-09-20 09:48:01 +00:00
__setfpucw (__fpu_control);
1996-08-07 23:50:59 +00:00
}
1996-09-05 02:49:18 +00:00
/* Save the command-line arguments. */
__libc_argc = argc;
__libc_argv = argv;
__environ = envp;
2000-03-31 05:50:02 +00:00
#ifndef SHARED
1997-12-14 22:24:57 +00:00
__libc_init_secure ();
2002-02-24 08:34:04 +00:00
/* First the initialization which normally would be done by the
dynamic linker. */
_dl_non_dynamic_init ();
1997-12-14 22:24:57 +00:00
#endif
2002-02-23 08:47:54 +00:00
__init_misc (argc, argv, envp);
2001-08-11 20:40:40 +00:00
#ifdef USE_NONOPTION_FLAGS
1997-02-10 03:19:57 +00:00
/* This is a hack to make the special getopt in GNU libc working. */
1997-08-24 10:55:18 +00:00
__getopt_clean_environment (envp);
2001-08-11 20:40:40 +00:00
#endif
1997-02-10 03:19:57 +00:00
2000-03-31 05:50:02 +00:00
#ifdef SHARED
__libc_global_ctors ();
#endif
}
1996-09-23 00:24:55 +00:00
/* 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. */
2000-11-20 09:16:41 +00:00
extern void _dl_start (void) __attribute__ ((noreturn));
1996-09-23 00:24:55 +00:00
void
1996-10-02 01:40:17 +00:00
_dl_start (void)
1996-09-23 00:24:55 +00:00
{
abort ();
}