]> sourceware.org Git - glibc.git/blame - sysdeps/unix/sysv/linux/init-first.c
Mon Jul 1 12:29:50 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[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>
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
28extern void __libc_init (int, char **, char **);
29extern void __libc_global_ctors (void);
30
31
32static void
33init (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
66void
67_init (int argc, ...)
68{
69 init (&argc);
70
71 __libc_global_ctors ();
72}
73#endif
74
75
76void
77__libc_init_first (int argc __attribute__ ((unused)), ...)
78{
79#ifndef PIC
80 init (&argc);
81#endif
82}
This page took 1.904394 seconds and 5 git commands to generate.