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