Modify the startup mechanism so that any call into valgrind's libpthread.so
will start up valgrind if it is not already running.  This more or less
sidesteps the problem that sometimes valgrind.so isn't init'd first by
the dynamic linker.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@257 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_startup.S b/coregrind/vg_startup.S
index a0bb4ea..63ee590 100644
--- a/coregrind/vg_startup.S
+++ b/coregrind/vg_startup.S
@@ -54,11 +54,23 @@
 	call VG_(startup)
 .section .fini
 	call VG_(shutdown)
+
+.section .data
+valgrind_already_initted:
+	.word	0
+	
 .section .text
 	
 
-
+.global VG_(startup)
 VG_(startup):
+	cmpl	$0, valgrind_already_initted
+	je	really_start_up
+	ret
+
+really_start_up:
+	movl	$1, valgrind_already_initted
+	
         # Record %esp as it was when we got here.  This is because argv/c
 	# and envp[] are passed as args to this function, and we need to see
 	# envp so we can get at the env var VG_ARGS without help from libc.