X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fenv%2F__libc_start_main.c;h=2a8698bb19439809a7acc469caa6e2656c90a58c;hb=HEAD;hp=70af77b57d311c8b886718f7a71c1ce0c5f53027;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/env/__libc_start_main.c b/src/env/__libc_start_main.c index 70af77b5..2a8698bb 100644 --- a/src/env/__libc_start_main.c +++ b/src/env/__libc_start_main.c @@ -1,24 +1,52 @@ +#include #include "libc.h" -/* Any use of __environ/environ will override this symbol. */ -char **__dummy_environ = (void *)-1; -weak_alias(__dummy_environ, ___environ); +void __init_tls(size_t *); +void __init_security(size_t *); +void __init_ldso_ctors(void); -int __libc_start_main( - int (*main)(int, char **, char **), int argc, char **argv, - int (*init)(int, char **, char **), void (*fini)(void), - void (*ldso_fini)(void)) +#ifndef SHARED +static void dummy() {} +weak_alias(dummy, _init); +extern void (*const __init_array_start)() __attribute__((weak)); +extern void (*const __init_array_end)() __attribute__((weak)); +#endif + +#define AUX_CNT 38 + +extern size_t __hwcap, __sysinfo; +extern char *__progname, *__progname_full; + +void __init_libc(char **envp, char *pn) { - /* Save the environment if it may be used by libc/application */ - char **envp = argv+argc+1; - if (___environ != (void *)-1) ___environ = envp; + size_t i, *auxv, aux[AUX_CNT] = { 0 }; + __environ = envp; + for (i=0; envp[i]; i++); + libc.auxv = auxv = (void *)(envp+i+1); + for (i=0; auxv[i]; i+=2) if (auxv[i]