It will be used for doing null checks with instruction "test (%reg),%reg". If %reg equals 0 then SIGSEGV will be triggered and NullPointerException will be thrown from signal handler.
Signed-off-by: Tomek Grabiec <[email protected]> --- arch/x86/emit-code_32.c | 7 +++++++ arch/x86/include/arch/instruction.h | 1 + arch/x86/lir-printer.c | 6 ++++++ 3 files changed, 14 insertions(+), 0 deletions(-) diff --git a/arch/x86/emit-code_32.c b/arch/x86/emit-code_32.c index 2a9d29d..f5e2ad7 100644 --- a/arch/x86/emit-code_32.c +++ b/arch/x86/emit-code_32.c @@ -818,6 +818,12 @@ static void emit_xor_imm_reg(struct buffer *buf, struct operand * src, __emit_xor_imm_reg(buf, src->imm, mach_reg(&dest->reg)); } +static void emit_test_membase_reg(struct buffer *buf, struct operand *src, + struct operand *dest) +{ + emit_membase_reg(buf, 0x85, src, dest); +} + enum emitter_type { NO_OPERANDS = 1, SINGLE_OPERAND, @@ -885,6 +891,7 @@ static struct emitter emitters[] = { DECL_EMITTER(INSN_SUB_IMM_REG, emit_sub_imm_reg, TWO_OPERANDS), DECL_EMITTER(INSN_SUB_MEMBASE_REG, emit_sub_membase_reg, TWO_OPERANDS), DECL_EMITTER(INSN_SUB_REG_REG, emit_sub_reg_reg, TWO_OPERANDS), + DECL_EMITTER(INSN_TEST_MEMBASE_REG, emit_test_membase_reg, TWO_OPERANDS), DECL_EMITTER(INSN_XOR_MEMBASE_REG, emit_xor_membase_reg, TWO_OPERANDS), DECL_EMITTER(INSN_XOR_IMM_REG, emit_xor_imm_reg, TWO_OPERANDS), }; diff --git a/arch/x86/include/arch/instruction.h b/arch/x86/include/arch/instruction.h index 6dd0a75..f28fd81 100644 --- a/arch/x86/include/arch/instruction.h +++ b/arch/x86/include/arch/instruction.h @@ -105,6 +105,7 @@ enum insn_type { INSN_SUB_IMM_REG, INSN_SUB_MEMBASE_REG, INSN_SUB_REG_REG, + INSN_TEST_MEMBASE_REG, INSN_XOR_MEMBASE_REG, INSN_XOR_IMM_REG, }; diff --git a/arch/x86/lir-printer.c b/arch/x86/lir-printer.c index 9707abd..0ff08e5 100644 --- a/arch/x86/lir-printer.c +++ b/arch/x86/lir-printer.c @@ -446,6 +446,11 @@ static int print_sub_reg_reg(struct string *str, struct insn *insn) return print_reg_reg(str, insn); } +static int print_test_membase_reg(struct string *str, struct insn *insn) +{ + print_func_name(str); + return print_membase_reg(str, insn); +} static int print_xor_membase_reg(struct string *str, struct insn *insn) { @@ -513,6 +518,7 @@ static print_insn_fn insn_printers[] = { [INSN_SUB_IMM_REG] = print_sub_imm_reg, [INSN_SUB_MEMBASE_REG] = print_sub_membase_reg, [INSN_SUB_REG_REG] = print_sub_reg_reg, + [INSN_TEST_MEMBASE_REG] = print_test_membase_reg, [INSN_XOR_MEMBASE_REG] = print_xor_membase_reg, [INSN_XOR_IMM_REG] = print_xor_imm_reg, }; -- 1.6.0.6 ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com _______________________________________________ Jatovm-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jatovm-devel
