[uClibc-cvs] svn commit: trunk/uClibc/libc/misc/internals

andersen at uclibc.org andersen at uclibc.org
Thu May 26 22:19:20 UTC 2005


Author: andersen
Date: 2005-05-26 16:19:19 -0600 (Thu, 26 May 2005)
New Revision: 10413

Log:
This commit breaks the entire world (yet again).  Calculate the
position of envp in C code based on argv and argp.  No need to
caclulate that in asm for N arches.  This way, we better match
what glibc does.  All arches will need to be fixed to match up
with this change.


Modified:
   trunk/uClibc/libc/misc/internals/__uClibc_main.c


Changeset:
Modified: trunk/uClibc/libc/misc/internals/__uClibc_main.c
===================================================================
--- trunk/uClibc/libc/misc/internals/__uClibc_main.c	2005-05-26 22:16:31 UTC (rev 10412)
+++ trunk/uClibc/libc/misc/internals/__uClibc_main.c	2005-05-26 22:19:19 UTC (rev 10413)
@@ -164,11 +164,9 @@
  * are initialized, just before we call the application's main function.
  */
 void __attribute__ ((__noreturn__))
-__uClibc_start_main(int (*main)(int argc, char **argv, char **envp),
-		    int argc, char **argv, char **envp,
-		    void (*app_init)(void), void (*app_fini)(void),
-		    void (*rtld_fini)(void),
-		    void *stack_end)
+__uClibc_start_main(int (*main)(int, char **, char **), int argc,
+		    char **argv, void (*app_init)(void), void (*app_fini)(void),
+		    void (*rtld_fini)(void), void *stack_end)
 {
 #ifdef __ARCH_HAS_MMU__
     unsigned long *aux_dat;
@@ -182,15 +180,19 @@
 
     __rtld_fini = rtld_fini;
 
-    /* If we are dynamically linked, then ldso already did this for us. */
-    if (__environ==NULL) {
-	/* Statically linked. */
-	__environ = envp;
+    /* The environment begins right after argv.  */
+    __environ = &argv[argc + 1];
+
+    /* If the first thing after argv is the arguments
+     * the the environment is empty. */
+    if ((char *) __environ == *argv) {
+	/* Make __environ point to the NULL at argv[argc] */
+	__environ = &argv[argc];
     }
 
     /* Pull stuff from the ELF header when possible */
 #ifdef __ARCH_HAS_MMU__
-    aux_dat = (unsigned long*)envp;
+    aux_dat = (unsigned long*)__environ;
     while (*aux_dat) {
 	aux_dat++;
     }
@@ -249,5 +251,5 @@
     /*
      * Finally, invoke application's main and then exit.
      */
-    exit(main(argc, argv, envp));
+    exit(main(argc, argv, __environ));
 }




More information about the uClibc-cvs mailing list