From: Julian Seward Date: Thu, 12 Jan 2006 13:34:20 +0000 (+0000) Subject: Make function wrapping work on amd64-linux. X-Git-Tag: svn/VALGRIND_3_2_0~390 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8576ec23a643f0b40e285b32900dc796c3c3400c;p=thirdparty%2Fvalgrind.git Make function wrapping work on amd64-linux. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5521 --- diff --git a/coregrind/m_dispatch/dispatch-amd64-linux.S b/coregrind/m_dispatch/dispatch-amd64-linux.S index 5a0d07e802..64a35000aa 100644 --- a/coregrind/m_dispatch/dispatch-amd64-linux.S +++ b/coregrind/m_dispatch/dispatch-amd64-linux.S @@ -36,7 +36,10 @@ /*------------------------------------------------------------*/ -/*--- The dispatch loop. ---*/ +/*--- ---*/ +/*--- The dispatch loop. VG_(run_innerloop) is used to ---*/ +/*--- run all translations except no-redir ones. ---*/ +/*--- ---*/ /*------------------------------------------------------------*/ /*----------------------------------------------------*/ @@ -272,13 +275,55 @@ run_innerloop_exit_REALLY: ret - -/* Other ways of getting out of the inner loop. Placed out-of-line to - make it look cleaner. -*/ - +/*------------------------------------------------------------*/ +/*--- ---*/ +/*--- A special dispatcher, for running no-redir ---*/ +/*--- translations. Just runs the given translation once. ---*/ +/*--- ---*/ +/*------------------------------------------------------------*/ +/* signature: +void VG_(run_a_noredir_translation) ( UWord* argblock ); +*/ +/* Run a no-redir translation. argblock points to 4 UWords, 2 to carry args + and 2 to carry results: + 0: input: ptr to translation + 1: input: ptr to guest state + 2: output: next guest PC + 3: output: guest state pointer afterwards (== thread return code) +*/ +.align 16 +.global VG_(run_a_noredir_translation) +VG_(run_a_noredir_translation): + /* Save callee-saves regs */ + pushq %rbx + pushq %rbp + pushq %r12 + pushq %r13 + pushq %r14 + pushq %r15 + + pushq %rdi /* we will need it after running the translation */ + movq 8(%rdi), %rbp + jmp *0(%rdi) + /*NOTREACHED*/ + ud2 + /* If the translation has been correctly constructed, we + should resume at the the following label. */ +.global VG_(run_a_noredir_translation__return_point) +VG_(run_a_noredir_translation__return_point): + popq %rdi + movq %rax, 16(%rdi) + movq %rbp, 24(%rdi) + + popq %r15 + popq %r14 + popq %r13 + popq %r12 + popq %rbp + popq %rbx + ret /* Let the linker know we don't need an executable stack */ .section .note.GNU-stack,"",@progbits diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index 32a042ae33..d07cced138 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -657,33 +657,6 @@ static UInt run_noredir_translation ( Addr hcode, ThreadId tid ) extern UWord run_a_translation ( UWord* argblock ); #if defined(VGP_x86_linux) #elif defined(VGP_amd64_linux) -asm("\n" -".text\n" -"run_a_translation:\n" -" pushq %rbx\n" -" pushq %rbp\n" -" pushq %r12\n" -" pushq %r13\n" -" pushq %r14\n" -" pushq %r15\n" - -" pushq %rdi\n" /* we will need it after running the translation */ -" movq 8(%rdi), %rbp\n" -" call *0(%rdi)\n" - -" popq %rdi\n" -" movq %rax, 16(%rdi)\n" -" movq %rbp, 24(%rdi)\n" - -" popq %r15\n" -" popq %r14\n" -" popq %r13\n" -" popq %r12\n" -" popq %rbp\n" -" popq %rbx\n" -" ret\n" -".previous\n" -); #elif defined(VGP_ppc32_linux) asm("\n" ".text\n"