From c367007e133a53b0d821c0423bc6bc860afd799e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 7 Sep 2015 15:30:36 +0200 Subject: [PATCH] executor: fix load of parameters smaller than 64 bits Parameters less than 64 bits are passed in just one param register. Fixes crashes on ldresnearb and friends in emulated code. --- orc/orcexecutor.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/orc/orcexecutor.c b/orc/orcexecutor.c index 6fe296d..6306d34 100644 --- a/orc/orcexecutor.c +++ b/orc/orcexecutor.c @@ -295,10 +295,15 @@ orc_executor_emulate (OrcExecutor *ex) } else if (var->vartype == ORC_VAR_TYPE_PARAM) { opcode_ex[j].src_ptrs[k] = tmpspace[insn->src_args[k]]; /* FIXME hack */ - load_constant (tmpspace[insn->src_args[k]], 8, - (orc_uint64)(orc_uint32)ex->params[insn->src_args[k]] | - (((orc_uint64)(orc_uint32)ex->params[insn->src_args[k] + - (ORC_VAR_T1 - ORC_VAR_P1)])<<32)); + if (var->size == 8) { + load_constant (tmpspace[insn->src_args[k]], 8, + (orc_uint64)(orc_uint32)ex->params[insn->src_args[k]] | + (((orc_uint64)(orc_uint32)ex->params[insn->src_args[k] + + (ORC_VAR_T1 - ORC_VAR_P1)])<<32)); + } else { + load_constant (tmpspace[insn->src_args[k]], 8, + ex->params[insn->src_args[k]]); + } } else if (var->vartype == ORC_VAR_TYPE_TEMP) { opcode_ex[j].src_ptrs[k] = tmpspace[insn->src_args[k]]; } else if (var->vartype == ORC_VAR_TYPE_SRC) { -- 2.7.4