]>
sourceware.org Git - glibc.git/blob - sysdeps/unix/sysv/linux/init-first.c
ae163bcd493aefbc49043ee6523fb4cb747abd8e
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.
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.
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.
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. */
22 #include <fpu_control.h>
23 #include <linux/personality.h>
24 #include "init-first.h"
26 extern void __libc_init (int, char **, char **);
27 extern void __libc_global_ctors (void);
29 /* The function is called from assembly stubs the compiler can't see. */
30 static void init (void *) __attribute__ ((unused
));
32 extern int _dl_starting_up
;
33 weak_extern (_dl_starting_up
)
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;
39 /* Remember the command line argument and enviroment contents for
40 later calls of initializers for dynamic libraries. */
49 extern int __personality (int);
51 __libc_multiple_libcs
= &_dl_starting_up
&& ! _dl_starting_up
;
54 /* We must not call `personality' twice. */
55 if (!__libc_multiple_libcs
)
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];
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
);
70 /* Set the FPU control word to the proper default value. */
71 __setfpucw (__fpu_control
);
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
;
82 __environ
= __libc_envp
;
83 __libc_init (__libc_argc
, __libc_argv
, __libc_envp
);
86 __libc_global_ctors ();
92 SYSDEP_CALL_INIT(_init
, init
);
95 __libc_init_first (void)
101 SYSDEP_CALL_INIT(__libc_init_first
, init
);
This page took 0.042905 seconds and 5 git commands to generate.