00db10
diff -pruN glibc-2.17-c758a686/nptl/pt-crti.S glibc-2.17-c758a686/nptl/pt-crti.S
00db10
--- glibc-2.17-c758a686/nptl/pt-crti.S	2012-12-25 08:32:13.000000000 +0530
00db10
+++ glibc-2.17-c758a686/nptl/pt-crti.S	2013-07-30 15:53:08.416386853 +0530
00db10
@@ -39,5 +39,6 @@
00db10
 
00db10
 #define PREINIT_FUNCTION __pthread_initialize_minimal_internal
00db10
 #define PREINIT_FUNCTION_WEAK 0
00db10
+#define PREINIT_FUNCTION_HAS_ARGS 1
00db10
 
00db10
 #include <crti.S>
00db10
diff -pruN glibc-2.17-c758a686/sysdeps/i386/crti.S glibc-2.17-c758a686/sysdeps/i386/crti.S
00db10
--- glibc-2.17-c758a686/sysdeps/i386/crti.S	2012-12-25 08:32:13.000000000 +0530
00db10
+++ glibc-2.17-c758a686/sysdeps/i386/crti.S	2013-07-30 16:38:41.085291690 +0530
00db10
@@ -49,6 +49,13 @@
00db10
 # define PREINIT_FUNCTION_WEAK 1
00db10
 #endif
00db10
 
00db10
+/* If the preinit function takes the argc, argv and envp arguments, push them
00db10
+   again on top before making the call.  This is only used by for pt-crti for
00db10
+   nptl.  */
00db10
+#ifndef PREINIT_FUNCTION_HAS_ARGS
00db10
+# define PREINIT_FUNCTION_HAS_ARGS 0
00db10
+#endif
00db10
+
00db10
 #if PREINIT_FUNCTION_WEAK
00db10
 	weak_extern (PREINIT_FUNCTION)
00db10
 #else
00db10
@@ -64,6 +68,18 @@ _init:
00db10
 	/* Maintain 16-byte stack alignment for called functions.  */
00db10
 	subl $8, %esp
00db10
 	LOAD_PIC_REG (bx)
00db10
+#if PREINIT_FUNCTION_HAS_ARGS
00db10
+/* Get argc, argv and envp from the stack and push them again on top so that
00db10
+   the called function can access them.  Maintain 16-byte alignment for value
00db10
+   in %esp for called functions.  */
00db10
+	movl 16(%esp), %eax
00db10
+	movl 20(%esp), %ecx
00db10
+	movl 24(%esp), %edx
00db10
+	subl $4, %esp
00db10
+	pushl %edx
00db10
+	pushl %ecx
00db10
+	pushl %eax
00db10
+#endif
00db10
 #if PREINIT_FUNCTION_WEAK
00db10
 	movl PREINIT_FUNCTION@GOT(%ebx), %eax
00db10
 	testl %eax, %eax
00db10
@@ -73,6 +89,9 @@ _init:
00db10
 #else
00db10
 	call PREINIT_FUNCTION
00db10
 #endif
00db10
+#if PREINIT_FUNCTION_HAS_ARGS
00db10
+	addl $16, %esp
00db10
+#endif
00db10
 
00db10
 	.section .fini,"ax",@progbits
00db10
 	.p2align 2