Example #1
0
    def lift_tst(il: LowLevelILFunction, insn: SHInsn):
        assert len(insn.opcode["args"]
                   ) == 2, f"Invalid instruction at: 0x{insn.addr:x}"

        op_1 = insn.opcode["args"][0]
        op_2 = insn.opcode["args"][1]

        t = LowLevelILLabel()
        f = LowLevelILLabel()
        next_insn = LowLevelILLabel()

        il.append(
            il.if_expr(
                il.compare_equal(
                    RSIZE,
                    il.and_expr(RSIZE, Lifter._lift_op(il, insn, op_1),
                                Lifter._lift_op(il, insn, op_2)),
                    il.const(RSIZE, 0)), t, f))

        il.mark_label(t)
        il.append(il.set_flag('t', il.const(0, 1)))
        il.append(il.goto(next_insn))

        il.mark_label(f)
        il.append(il.set_flag('t', il.const(0, 0)))

        il.mark_label(next_insn)
Example #2
0
    def lift_bf(il: LowLevelILFunction, insn: SHInsn):
        assert len(insn.opcode["args"]
                   ) == 1, f"Invalid instruction at: 0x{insn.addr:x}"

        op_1 = insn.opcode["args"][0]

        t = il.get_label_for_address(Architecture["superh"], op_1.val)

        if t is None:
            t = LowLevelILLabel()
            indirect = True
        else:
            indirect = False

        f = LowLevelILLabel()

        il.append(
            il.if_expr(il.compare_equal(0, il.flag("t"), il.const(0, 0)), t,
                       f))

        if indirect:
            il.mark_label(t)

            il.append(il.jump(il.const(RSIZE, op_1.val)))

        il.mark_label(f)
Example #3
0
    def lift_cmp_eq(il: LowLevelILFunction, insn: SHInsn):
        assert len(insn.opcode["args"]
                   ) == 2, f"Invalid instruction at: 0x{insn.addr:x}"

        op_1 = insn.opcode["args"][0]
        op_2 = insn.opcode["args"][1]

        extend = False
        if op_1.type == OpType.IMM:
            extend = True

        t = LowLevelILLabel()
        f = LowLevelILLabel()
        next_insn = LowLevelILLabel()

        il.append(
            il.if_expr(
                il.compare_equal(
                    RSIZE, Lifter._lift_op(il, insn, op_1, sign_ext=extend),
                    Lifter._lift_op(il, insn, op_2)), t, f))

        il.mark_label(t)
        il.append(il.set_flag('t', il.const(0, 1)))
        il.append(il.goto(next_insn))

        il.mark_label(f)
        il.append(il.set_flag('t', il.const(0, 0)))

        il.mark_label(next_insn)