about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/dl-sysdep.c6
-rw-r--r--sysdeps/i386/dl-machine.h17
2 files changed, 12 insertions, 11 deletions
diff --git a/sysdeps/generic/dl-sysdep.c b/sysdeps/generic/dl-sysdep.c
index c1cf37da76..49eaad6737 100644
--- a/sysdeps/generic/dl-sysdep.c
+++ b/sysdeps/generic/dl-sysdep.c
@@ -42,13 +42,13 @@ _dl_sysdep_start (void **start_argptr,
 
   user_entry = (Elf32_Addr) &_start;
   _dl_argc = *(int *) start_argptr;
-  _dl_argv = start_argptr + 1;
+  _dl_argv = (char **) start_argptr + 1;
   _environ = &_dl_argv[_dl_argc + 1];
   start_argptr = (void **) _environ;
   while (*start_argptr)
     ++start_argptr;
 
-  for (av = ++start_argptr; av->a_type != AT_NULL; ++av)
+  for (av = (void *) ++start_argptr; av->a_type != AT_NULL; ++av)
     switch (av->a_type)
       {
       case AT_PHDR:
@@ -77,7 +77,7 @@ _dl_sysdep_start (void **start_argptr,
   _dl_secure = uid != euid || gid != egid;
 
   (*dl_main) (phdr, phnum, &user_entry);
-  start_argptr[-1] = (void *) user_entry;
+  return user_entry;
 }
 
 int
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 800c2d7b68..546828093f 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -182,15 +182,16 @@ _dl_start_user:\n\
 	addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %ebx\n\
 	# See if we were run as a command with the executable file\n\
 	# name as an extra leading argument.\n\
-	movl rtld_command@GOT(%ebx), %eax\n\
+	movl _dl_skip_args@GOT(%ebx), %eax\n\
 	movl (%eax),%eax\n\
-	testl %eax,%eax\n\
-	jz 0f\n\
-	# Pop the original argument count, decrement it, and replace\n\
-	# the original first argument pointer with the new count.\n\
-	popl %eax\n\
-	decl %eax\n\
-	movl %eax,(%esp)\n\
+	# Pop the original argument count.\n\
+	popl %ecx\n\
+	# Subtract _dl_skip_args from it.\n\
+	subl %eax, %ecx\n\
+	# Adjust the stack pointer to skip _dl_skip_args words.\n\
+	leal (%esp,%eax,4), %esp\n\
+	# Push back the modified argument count.\n\
+	pushl %ecx\n\
 	# Call _dl_init_next to return the address of an initializer\n\
 	# function to run.\n\
 0:	call _dl_init_next@PLT\n\