chiark / gitweb /
[PATCH] sync with latest version of klibc (0.107)
[elogind.git] / klibc / klibc / __static_init.c
1 /*
2  * __static_init.c
3  *
4  * This function takes the raw data block set up by the ELF loader
5  * in the kernel and parses it.  It is invoked by crt0.S which makes
6  * any necessary adjustments and passes calls this function using
7  * the standard C calling convention.
8  *
9  * The arguments are:
10  *  uintptr_t *elfdata   -- The ELF loader data block; usually from the stack.
11  *                          Basically a pointer to argc.
12  *  void (*onexit)(void) -- Function to install into onexit
13  */
14
15 #include <stddef.h>
16 #include <stdlib.h>
17 #include <stdint.h>
18 #include <klibc/compiler.h>
19 #include <elf.h>
20
21 char **environ;
22
23 extern int main(int, char **, char **);
24
25 __noreturn __libc_init(uintptr_t *elfdata, void (*onexit)(void))
26 {
27   int argc;
28   char **argv, **envp;
29
30   (void)onexit;                 /* For now, we ignore this... */
31
32   argc = (int)*elfdata++;
33   argv = (char **)elfdata;
34   envp = argv+(argc+1);
35
36   environ = envp;
37   exit(main(argc, argv, envp));
38 }
39
40