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.
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
18 #include <klibc/compiler.h>
23 __noreturn __libc_init(uintptr_t *elfdata, void (*onexit)(void))
26 char **argv, **envp, **envend;
31 typedef int (*main_t)(int, char **, char **);
32 main_t main_ptr = NULL;
34 (void)onexit; /* For now, we ignore this... */
36 argc = (int)*elfdata++;
37 argv = (char **)elfdata;
40 /* The auxillary entry vector is after all the environment vars */
41 for ( envend = envp ; *envend ; envend++ );
42 auxentry = (struct auxentry *)(envend+1);
44 while ( auxentry->type ) {
45 if ( auxentry->type == AT_ENTRY ) {
46 main_ptr = (main_t)(auxentry->v);
53 exit(main_ptr(argc, argv, envp));