]> sourceware.org Git - glibc.git/blame - sysdeps/unix/sysv/linux/init-first.c
Update.
[glibc.git] / sysdeps / unix / sysv / linux / init-first.c
CommitLineData
2a072de4
RM
1/* Initialization code run first thing by the ELF startup code. Linux version.
2Copyright (C) 1995, 1996 Free Software Foundation, Inc.
0324daa0
RM
3This file is part of the GNU C Library.
4
5The GNU C Library is free software; you can redistribute it and/or
6modify it under the terms of the GNU Library General Public License as
7published by the Free Software Foundation; either version 2 of the
8License, or (at your option) any later version.
9
10The GNU C Library is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13Library General Public License for more details.
14
15You should have received a copy of the GNU Library General Public
16License along with the GNU C Library; see the file COPYING.LIB. If
17not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18Cambridge, MA 02139, USA. */
19
20#include <unistd.h>
41cfadd6 21#include <sysdep.h>
3776d592 22#include <fpu_control.h>
23396375 23#include <linux/personality.h>
3776d592 24#include "init-first.h"
2a072de4 25
0324daa0
RM
26extern void __libc_init (int, char **, char **);
27extern void __libc_global_ctors (void);
28
3776d592
RM
29/* The function is called from assembly stubs the compiler can't see. */
30static void init (void *) __attribute__ ((unused));
0324daa0 31
39778c6c
UD
32extern int _dl_starting_up;
33weak_extern (_dl_starting_up)
34
35/* Set nonzero if we have to be prepared for more then one libc being
36 used in the process. Safe assumption if initializer never runs. */
37int __libc_multiple_libcs = 1;
23396375 38
0324daa0 39static void
3776d592 40init (void *data)
0324daa0 41{
8d71c7b0
RM
42 extern int __personality (int);
43
3776d592
RM
44 int argc = *(long *)data;
45 char **argv = (char **)data + 1;
0324daa0
RM
46 char **envp = &argv[argc + 1];
47
a8922de8 48
39778c6c
UD
49 __libc_multiple_libcs = &_dl_starting_up && ! _dl_starting_up;
50
51 /* We must not call `personality' twice. */
52 if (!__libc_multiple_libcs)
23396375 53 {
39778c6c
UD
54 /* The `personality' system call takes one argument that chooses
55 the "personality", i.e. the set of system calls and such. We
56 must make this call first thing to disable emulation of some
57 other system that might have been enabled by default based on
58 the executable format. */
59 __personality (PER_LINUX);
60
61 /* Set the FPU control word to the proper default value. */
62 __setfpucw (__fpu_control);
23396375 63 }
0324daa0
RM
64
65 __environ = envp;
66 __libc_init (argc, argv, envp);
3776d592
RM
67
68#ifdef PIC
69 __libc_global_ctors ();
70#endif
0324daa0
RM
71}
72
73#ifdef PIC
0324daa0 74
3776d592 75SYSDEP_CALL_INIT(_init, init);
0324daa0
RM
76
77void
3776d592 78__libc_init_first (void)
0324daa0 79{
0324daa0 80}
0324daa0 81
3776d592
RM
82#else
83
84SYSDEP_CALL_INIT(__libc_init_first, init);
0324daa0 85
0324daa0 86#endif
This page took 0.066023 seconds and 5 git commands to generate.