]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Finally finish pissing around with jmp_with_stack. Now at least we
authorJulian Seward <jseward@acm.org>
Tue, 22 Mar 2005 02:03:09 +0000 (02:03 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 22 Mar 2005 02:03:09 +0000 (02:03 +0000)
can get a startup on amd64.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3403

coregrind/amd64/jmp_with_stack.c
coregrind/stage1.c

index 068b52450bd5eabd15c1a988aa32526982e04016..1b7033e5a891530e45d64ebe14c3ae3b45e8d81a 100644 (file)
    "   movq $0, %r15\n"
 
 
-/* Call f(), but first switch stacks, using 'stack' as the new stack,
-   and use 'retaddr' as f's return-to address.  Also, clear all the
-   integer registers before entering f. */
+/* Jump to 'dst', but first set the stack pointer to 'stack'.  Also,
+   clear all the integer registers before entering 'dst'.  It's
+   important that the stack pointer is set to exactly 'stack' and not
+   (eg) stack - apparently_harmless_looking_small_offset.  Basically
+   because the code at 'dst' might be wanting to scan the area above
+   'stack' (viz, the auxv array), and putting spurious words on the
+   stack confuses it.
+*/
 /*
 __attribute__((noreturn))
-void call_on_new_stack_0_0 ( Addr stack,
-                            Addr retaddr,
-                            void (*f)(void) );
+void jump_and_switch_stacks ( Addr stack, Addr dst );
+
   %rdi == stack
-  %rsi == retaddr
-  %rdx == f
+  %rsi == dst
 */
 asm(
-".global call_on_new_stack_0_0\n"
-"call_on_new_stack_0_0:\n"
+".global jump_and_switch_stacks\n"
+"jump_and_switch_stacks:\n"
 "   movq   %rdi, %rsp\n"  /* set stack */
-"   pushq  %rsi\n"        /* retaddr to stack */
-"   pushq  %rdx\n"        /* f to stack*/
+"   pushq  %rsi\n"        /* f to stack*/
     ZERO_ALL_INT_REGS
 "   ret\n"                /* jump to f */
 "   ud2\n"                /* should never get here */
index 6ab8c93cd424053044767e5f8b5d3cf12e550cc6..42a80fabb0888aecf5a0b5c4d2beeeea81e2c60b 100644 (file)
@@ -337,8 +337,8 @@ int main(int argc, char** argv)
 
    /* move onto another stack so we can play with the main one */
    jump_and_switch_stacks(
-      (Addr)stack + sizeof(stack),  /* stack */
-      main2                         /* where to */
+      (Addr) stack + sizeof(stack),  /* stack */
+      (Addr) main2                   /* where to */
    );
 
    /*NOTREACHED*/