[uClibc-cvs] CVS update of uClibc/libc/misc/internals (__uClibc_main.c)

Erik Andersen andersen at codepoet.org
Mon Aug 16 20:35:16 UTC 2004


    Date: Monday, August 16, 2004 @ 14:35:16
  Author: andersen
    Path: /var/cvs/uClibc/libc/misc/internals

Modified: __uClibc_main.c (1.40 -> 1.41)

Setup __pagesize from inside __uClibc_init(), or else when registering
dtors via atexit(), atexit may need to call realloc with __pagesize
still set to 0.  ugh.
 -Erik


Index: uClibc/libc/misc/internals/__uClibc_main.c
diff -u uClibc/libc/misc/internals/__uClibc_main.c:1.40 uClibc/libc/misc/internals/__uClibc_main.c:1.41
--- uClibc/libc/misc/internals/__uClibc_main.c:1.40	Mon Aug 16 13:22:52 2004
+++ uClibc/libc/misc/internals/__uClibc_main.c	Mon Aug 16 14:35:15 2004
@@ -76,11 +76,40 @@
 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 @@
     if (likely(_stdio_init != NULL))
 	_stdio_init();
 
+    __progname = *argv;
+
 }
 
 #ifdef __UCLIBC_CTOR_DTOR__
@@ -127,42 +158,11 @@
 __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;



More information about the uClibc-cvs mailing list