From: Julian Seward Date: Tue, 22 Mar 2005 02:03:09 +0000 (+0000) Subject: Finally finish pissing around with jmp_with_stack. Now at least we X-Git-Tag: svn/VALGRIND_3_0_0~915 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=10d241c300e4cfd6552fda25c334bd92fc06bdaa;p=thirdparty%2Fvalgrind.git Finally finish pissing around with jmp_with_stack. Now at least we can get a startup on amd64. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3403 --- diff --git a/coregrind/amd64/jmp_with_stack.c b/coregrind/amd64/jmp_with_stack.c index 068b52450b..1b7033e5a8 100644 --- a/coregrind/amd64/jmp_with_stack.c +++ b/coregrind/amd64/jmp_with_stack.c @@ -45,24 +45,26 @@ " 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 */ diff --git a/coregrind/stage1.c b/coregrind/stage1.c index 6ab8c93cd4..42a80fabb0 100644 --- a/coregrind/stage1.c +++ b/coregrind/stage1.c @@ -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*/