From 06fa15fb9912dde92c61541a759dc217962967b3 Mon Sep 17 00:00:00 2001 From: Shinichiro Hamaji Date: Thu, 2 Apr 2009 01:40:00 +0900 Subject: [PATCH] x86-64: Save RDX and RCX before we use them as function parameters. When the function call is indirect, these registers may be broken to load a function pointer. --- x86_64-gen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x86_64-gen.c b/x86_64-gen.c index f3382aec..1cbe414c 100644 --- a/x86_64-gen.c +++ b/x86_64-gen.c @@ -582,6 +582,8 @@ void gfunc_call(int nb_args) vtop--; } + save_regs(0); /* save used temporary registers */ + /* Copy R10 and R11 into RDX and RCX, respectively */ if (nb_reg_args > 2) { o(0xd2894c); /* mov %r10, %rdx */ @@ -590,8 +592,6 @@ void gfunc_call(int nb_args) } } - save_regs(0); /* save used temporary registers */ - func_sym = vtop->type.ref; func_call = FUNC_CALL(func_sym->r); oad(0xb8, nb_sse_args < 8 ? nb_sse_args : 8); /* mov nb_sse_args, %eax */