]> 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
23396375
UD
32extern int __libc_is_static;
33#ifdef PIC
34weak_extern (__libc_is_static)
35#endif
36
0324daa0 37static void
3776d592 38init (void *data)
0324daa0 39{
8d71c7b0
RM
40 extern int __personality (int);
41
3776d592
RM
42 int argc = *(long *)data;
43 char **argv = (char **)data + 1;
0324daa0
RM
44 char **envp = &argv[argc + 1];
45
23396375
UD
46#ifdef PIC
47 if (&__libc_is_static != NULL)
48#endif
49 {
50#ifdef PIC
51 /* We must not call `personality' twice. */
52 if (__libc_is_static == 0)
53#endif
54 {
55 /* The `personality' system call takes one argument that
56 chooses the "personality", i.e. the set of system calls
57 and such. We must make this call first thing to disable
58 emulation of some other system that might have been
59 enabled by default based on the executable format. */
60 __personality (PER_LINUX);
61
62 /* Set the FPU control word to the proper default value. */
63 __setfpucw (__fpu_control);
64 }
65
66 /* We set LIBC_IS_STATIC to a value > 0 for the static library
67 and < 0 for the shared library. This information might be
68 useful for the running program but it is mainly necessary for
69 the above `if' statement. */
70#ifdef PIC
71 __libc_is_static = -1;
72#else
73 __libc_is_static = 1;
74#endif
75 }
0324daa0
RM
76
77 __environ = envp;
78 __libc_init (argc, argv, envp);
3776d592
RM
79
80#ifdef PIC
81 __libc_global_ctors ();
82#endif
0324daa0
RM
83}
84
85#ifdef PIC
0324daa0 86
3776d592 87SYSDEP_CALL_INIT(_init, init);
0324daa0
RM
88
89void
3776d592 90__libc_init_first (void)
0324daa0 91{
0324daa0 92}
0324daa0 93
3776d592
RM
94#else
95
96SYSDEP_CALL_INIT(__libc_init_first, init);
0324daa0 97
0324daa0 98#endif
This page took 0.06291 seconds and 5 git commands to generate.