diff options
-rw-r--r-- | libc/misc/internals/__uClibc_main.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c index 9251caecb..a6e48850e 100644 --- a/libc/misc/internals/__uClibc_main.c +++ b/libc/misc/internals/__uClibc_main.c @@ -76,11 +76,40 @@ weak_alias(__secure, _dl_secure); void __uClibc_init(void) { static int been_there_done_that = 0; +#ifdef __ARCH_HAS_MMU__ + unsigned long *aux_dat; + Elf32_auxv_t auxvt[AT_EGID + 1]; +#endif if (been_there_done_that) return; been_there_done_that++; + /* Pull stuff from the ELF header when possible */ +#ifdef __ARCH_HAS_MMU__ + aux_dat = (unsigned long*)envp; + while (*aux_dat) { + aux_dat++; + } + aux_dat++; + while (*aux_dat) { + Elf32_auxv_t *auxv_entry = (Elf32_auxv_t *) aux_dat; + if (auxv_entry->a_type <= AT_EGID) { + memcpy(&(auxvt[auxv_entry->a_type]), auxv_entry, sizeof(Elf32_auxv_t)); + } + aux_dat += 2; + } + __pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE; +#else + __pagesize = PAGE_SIZE; +#endif + + /* If we are dynamically linked, then ldso already did this for us. */ + if (__environ==NULL) { + /* Statically linked. */ + __environ = envp; + } + #ifdef __UCLIBC_HAS_THREADS__ /* Before we start initialzing uClibc we have to call * __pthread_initialize_minimal so we can use pthread_locks @@ -113,6 +142,8 @@ void __uClibc_init(void) if (likely(_stdio_init != NULL)) _stdio_init(); + __progname = *argv; + } #ifdef __UCLIBC_CTOR_DTOR__ @@ -127,42 +158,11 @@ void __attribute__ ((__noreturn__)) __uClibc_start_main(int argc, char **argv, char **envp, void (*app_init)(void), void (*app_fini)(void)) { - /* Pull stuff from the ELF header when possible */ -#ifdef __ARCH_HAS_MMU__ - unsigned long *aux_dat; - Elf32_auxv_t auxvt[AT_EGID + 1]; - aux_dat = (unsigned long*)envp; - while (*aux_dat) { - aux_dat++; - } - aux_dat++; - while (*aux_dat) { - Elf32_auxv_t *auxv_entry = (Elf32_auxv_t *) aux_dat; - if (auxv_entry->a_type <= AT_EGID) { - memcpy(&(auxvt[auxv_entry->a_type]), auxv_entry, sizeof(Elf32_auxv_t)); - } - aux_dat += 2; - } - __pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE; -#else - __pagesize = PAGE_SIZE; -#endif - - /* If we are dynamically linked the shared lib loader already - * did this for us. But if we are statically linked, we need - * to do this for ourselves. */ - if (__environ==NULL) { - /* Statically linked. */ - __environ = envp; - } - /* We need to initialize uClibc. If we are dynamically linked this * may have already been completed by the shared lib loader. We call * __uClibc_init() regardless, to be sure the right thing happens. */ __uClibc_init(); - __progname = *argv; - #ifdef __UCLIBC_CTOR_DTOR__ /* Arrange for the application's dtors to run before we exit. */ __app_fini = app_fini; |