Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Oct 2008 09:19:05 GMT
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 152146 for review
Message-ID:  <200810290919.m9T9J5Bo087547@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=152146

Change 152146 by peter@peter_overcee on 2008/10/29 09:18:53

	FreeBSD/amd64's exec binary handoff isn't compatible with the linux code.
	We have an extra argument in %rdi, so don't trash it during startup, and pass
	the extra argument to a custom _start_in_C handler.

Affected files ...

.. //depot/projects/valgrind/coregrind/m_main.c#8 edit

Differences ...

==== //depot/projects/valgrind/coregrind/m_main.c#8 (text+ko) ====

@@ -2495,15 +2495,15 @@
     "\t.globl _start\n"
     "\t.type _start,@function\n"
     "_start:\n"
-    /* set up the new stack in %rdi */
-    "\tmovq  $vgPlain_interim_stack, %rdi\n"
-    "\taddq  $"VG_STRINGIFY(VG_STACK_GUARD_SZB)", %rdi\n"
-    "\taddq  $"VG_STRINGIFY(VG_STACK_ACTIVE_SZB)", %rdi\n"
-    "\tandq  $~15, %rdi\n"
+    /* set up the new stack in %rsi */
+    "\tmovq  $vgPlain_interim_stack, %rsi\n"
+    "\taddq  $"VG_STRINGIFY(VG_STACK_GUARD_SZB)", %rsi\n"
+    "\taddq  $"VG_STRINGIFY(VG_STACK_ACTIVE_SZB)", %rsi\n"
+    "\tandq  $~15, %rsi\n"
     /* install it, and collect the original one */
-    "\txchgq %rdi, %rsp\n"
-    /* call _start_in_C_linux, passing it the startup %rsp */
-    "\tcall  _start_in_C_linux\n"
+    "\txchgq %rsi, %rsp\n"
+    /* call _start_in_C_amd64_freebsd, passing it the startup %rsp */
+    "\tcall  _start_in_C_amd64_freebsd\n"
     "\thlt\n"
     ".previous\n"
 );
@@ -2518,6 +2518,26 @@
 #include <elf.h>
 /* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
 
+#if defined(VGP_amd64_freebsd)
+void _start_in_C_amd64_freebsd ( UWord* pArgc, UWord *initial_sp );
+void _start_in_C_amd64_freebsd ( UWord* pArgc, UWord *initial_sp )
+{
+   Int     r;
+   Word    argc = pArgc[0];
+   HChar** argv = (HChar**)&pArgc[1];
+   HChar** envp = (HChar**)&pArgc[1+argc+1];
+
+   VG_(memset)( &the_iicii, 0, sizeof(the_iicii) );
+   VG_(memset)( &the_iifii, 0, sizeof(the_iifii) );
+
+   the_iicii.sp_at_startup = (Addr)initial_sp;
+
+   r = valgrind_main( (Int)argc, argv, envp );
+   /* NOTREACHED */
+   VG_(exit)(r);
+}
+
+#else
 /* Avoid compiler warnings: this fn _is_ used, but labelling it
    'static' causes gcc to complain it isn't. */
 void _start_in_C_linux ( UWord* pArgc );
@@ -2556,6 +2576,7 @@
    /* NOTREACHED */
    VG_(exit)(r);
 }
+#endif
 
 #endif /* defined(VGO_linux) */
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810290919.m9T9J5Bo087547>