ldbl-128ibm-compat: Redirect complex math functions
[glibc.git] / csu / init-first.c
blob264e6f348dc69bc3376a6a3141ed0416b5844351
1 /* Initialization code run first thing by the ELF startup code. Common version
2 Copyright (C) 1995-2020 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 Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <ctype.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <fcntl.h>
23 #include <unistd.h>
24 #include <sysdep.h>
25 #include <fpu_control.h>
26 #include <sys/param.h>
27 #include <sys/types.h>
28 #include <libc-internal.h>
30 #include <ldsodefs.h>
32 /* Set nonzero if we have to be prepared for more than one libc being
33 used in the process. Safe assumption if initializer never runs. */
34 int __libc_multiple_libcs attribute_hidden = 1;
36 /* Remember the command line argument and enviroment contents for
37 later calls of initializers for dynamic libraries. */
38 int __libc_argc attribute_hidden;
39 char **__libc_argv attribute_hidden;
42 void
43 __libc_init_first (int argc, char **argv, char **envp)
45 #ifdef SHARED
46 /* For DSOs we do not need __libc_init_first but an ELF constructor. */
49 static void __attribute__ ((constructor))
50 _init_first (int argc, char **argv, char **envp)
52 #endif
54 __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
56 /* Make sure we don't initialize twice. */
57 if (!__libc_multiple_libcs)
59 /* Set the FPU control word to the proper default value if the
60 kernel would use a different value. */
61 if (__fpu_control != GLRO(dl_fpu_control))
62 __setfpucw (__fpu_control);
65 /* Save the command-line arguments. */
66 __libc_argc = argc;
67 __libc_argv = argv;
68 __environ = envp;
70 #ifndef SHARED
71 /* First the initialization which normally would be done by the
72 dynamic linker. */
73 _dl_non_dynamic_init ();
74 #endif
76 __init_misc (argc, argv, envp);
78 /* Initialize ctype data. */
79 __ctype_init ();
81 #if defined SHARED && !defined NO_CTORS_DTORS_SECTIONS
82 __libc_global_ctors ();
83 #endif
86 /* This function is defined here so that if this file ever gets into
87 ld.so we will get a link error. Having this file silently included
88 in ld.so causes disaster, because the _init_first definition above
89 will cause ld.so to gain an ELF constructor, which is not a cool
90 thing. */
92 extern void _dl_start (void) __attribute__ ((noreturn));
94 void
95 _dl_start (void)
97 abort ();