]> sourceware.org Git - glibc.git/blame - sysdeps/unix/sysv/linux/init-first.c
handle password file locking.
[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
dcf0671d
UD
39/* Remember the command line argument and enviroment contents for
40 later calls of initializers for dynamic libraries. */
41int __libc_argc;
42char **__libc_argv;
43char **__libc_envp;
44
45
0324daa0 46static void
3776d592 47init (void *data)
0324daa0 48{
8d71c7b0
RM
49 extern int __personality (int);
50
39778c6c
UD
51 __libc_multiple_libcs = &_dl_starting_up && ! _dl_starting_up;
52
dcf0671d 53
39778c6c
UD
54 /* We must not call `personality' twice. */
55 if (!__libc_multiple_libcs)
23396375 56 {
dcf0671d
UD
57 /* The argument we got points to the values describing the
58 command line argument etc. */
59 __libc_argc = *(int *)data;
60 __libc_argv = (char **)data + 1;
61 __libc_envp = &__libc_argv[__libc_argc + 1];
62
39778c6c
UD
63 /* The `personality' system call takes one argument that chooses
64 the "personality", i.e. the set of system calls and such. We
65 must make this call first thing to disable emulation of some
66 other system that might have been enabled by default based on
67 the executable format. */
68 __personality (PER_LINUX);
69
70 /* Set the FPU control word to the proper default value. */
71 __setfpucw (__fpu_control);
23396375 72 }
dcf0671d
UD
73 else
74 {
75 /* The argument we got points to the values describing the
76 command line argument etc. */
77 __libc_argc = *((int *)data)++;
78 __libc_argv = *((char ***)data)++;
79 __libc_envp = *(char ***)data;
80 }
0324daa0 81
dcf0671d
UD
82 __environ = __libc_envp;
83 __libc_init (__libc_argc, __libc_argv, __libc_envp);
3776d592
RM
84
85#ifdef PIC
86 __libc_global_ctors ();
87#endif
0324daa0
RM
88}
89
90#ifdef PIC
0324daa0 91
3776d592 92SYSDEP_CALL_INIT(_init, init);
0324daa0
RM
93
94void
3776d592 95__libc_init_first (void)
0324daa0 96{
0324daa0 97}
0324daa0 98
3776d592
RM
99#else
100
101SYSDEP_CALL_INIT(__libc_init_first, init);
0324daa0 102
0324daa0 103#endif
This page took 0.068101 seconds and 5 git commands to generate.