]> sourceware.org Git - glibc.git/blob - sysdeps/unix/sysv/linux/init-first.c
Update.
[glibc.git] / sysdeps / unix / sysv / linux / init-first.c
1 /* Initialization code run first thing by the ELF startup code. Linux version.
2 Copyright (C) 1995, 1996 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, MA 02139, USA. */
19
20 #include <unistd.h>
21 #include <sysdep.h>
22 #include <fpu_control.h>
23 #include <linux/personality.h>
24 #include "init-first.h"
25
26 extern void __libc_init (int, char **, char **);
27 extern void __libc_global_ctors (void);
28
29 /* The function is called from assembly stubs the compiler can't see. */
30 static void init (void *) __attribute__ ((unused));
31
32 extern int _dl_starting_up;
33 weak_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. */
37 int __libc_multiple_libcs = 1;
38
39 static void
40 init (void *data)
41 {
42 extern int __personality (int);
43
44 int argc = *(long *)data;
45 char **argv = (char **)data + 1;
46 char **envp = &argv[argc + 1];
47
48
49 __libc_multiple_libcs = &_dl_starting_up && ! _dl_starting_up;
50
51 /* We must not call `personality' twice. */
52 if (!__libc_multiple_libcs)
53 {
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);
63 }
64
65 __environ = envp;
66 __libc_init (argc, argv, envp);
67
68 #ifdef PIC
69 __libc_global_ctors ();
70 #endif
71 }
72
73 #ifdef PIC
74
75 SYSDEP_CALL_INIT(_init, init);
76
77 void
78 __libc_init_first (void)
79 {
80 }
81
82 #else
83
84 SYSDEP_CALL_INIT(__libc_init_first, init);
85
86 #endif
This page took 0.045834 seconds and 6 git commands to generate.