]>
Commit | Line | Data |
---|---|---|
2a072de4 RM |
1 | /* Initialization code run first thing by the ELF startup code. Linux version. |
2 | Copyright (C) 1995, 1996 Free Software Foundation, Inc. | |
0324daa0 RM |
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> | |
41cfadd6 | 21 | #include <sysdep.h> |
0324daa0 RM |
22 | #include "fpu_control.h" |
23 | ||
2a072de4 RM |
24 | /* This code is mostly the same for all machines. This version works at |
25 | least for i386 and m68k, and probably any CISCy machine with a normal | |
26 | stack arrangement. */ | |
27 | ||
0324daa0 RM |
28 | extern void __libc_init (int, char **, char **); |
29 | extern void __libc_global_ctors (void); | |
30 | ||
31 | ||
32 | static void | |
33 | init (int *data) | |
34 | { | |
8d71c7b0 RM |
35 | extern int __personality (int); |
36 | ||
0324daa0 RM |
37 | int argc = *data; |
38 | char **argv = (void *) (data + 1); | |
39 | char **envp = &argv[argc + 1]; | |
40 | ||
8d71c7b0 RM |
41 | /* The `personality' system call takes one argument that chooses the |
42 | "personality", i.e. the set of system calls and such. Zero is the | |
43 | native Linux value; we must make this call first thing to disable | |
44 | emulation of some other system that might have been enabled by default | |
45 | based on the executable format. */ | |
46 | __personality (0); | |
0324daa0 RM |
47 | |
48 | /* Set the FPU control word to the proper default value. */ | |
42d2676e | 49 | __setfpucw (__fpu_control); |
0324daa0 RM |
50 | |
51 | __environ = envp; | |
52 | __libc_init (argc, argv, envp); | |
53 | } | |
54 | ||
55 | #ifdef PIC | |
56 | /* This function is called to initialize the shared C library. | |
57 | It is called just before the user _start code from i386/elf/start.S, | |
58 | with the stack set up as that code gets it. */ | |
59 | ||
60 | /* NOTE! The linker notices the magical name `_init' and sets the DT_INIT | |
61 | pointer in the dynamic section based solely on that. It is convention | |
62 | for this function to be in the `.init' section, but the symbol name is | |
63 | the only thing that really matters!! */ | |
64 | /*void _init (int argc, ...) __attribute__ ((unused, section (".init")));*/ | |
65 | ||
66 | void | |
67 | _init (int argc, ...) | |
68 | { | |
69 | init (&argc); | |
70 | ||
71 | __libc_global_ctors (); | |
72 | } | |
73 | #endif | |
74 | ||
75 | ||
76 | void | |
77 | __libc_init_first (int argc __attribute__ ((unused)), ...) | |
78 | { | |
79 | #ifndef PIC | |
80 | init (&argc); | |
81 | #endif | |
82 | } |