Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def pc_actions_SBB(state, nbits, cc_dep1, cc_dep2, cc_ndep, platform=None):
old_c = cc_ndep[data[platform]['CondBitOffsets']['G_CC_SHIFT_C']].zero_extend(nbits-1)
arg_l = cc_dep1
arg_r = cc_dep2 ^ old_c
res = (arg_l - arg_r) - old_c
cf_c = claripy.If(claripy.ULE(arg_l, arg_r), claripy.BVV(1, 1), claripy.BVV(0, 1))
cf_noc = claripy.If(claripy.ULT(arg_l, arg_r), claripy.BVV(1, 1), claripy.BVV(0, 1))
cf = claripy.If(old_c == 1, cf_c, cf_noc)
pf = calc_paritybit(res)
af = (res ^ arg_l ^ arg_r)[data[platform]['CondBitOffsets']['G_CC_SHIFT_A']]
zf = calc_zerobit(res)
sf = res[nbits-1]
of = ((arg_l ^ arg_r) & (arg_l ^ res))[nbits-1]
return pc_make_rdata(data[platform]['size'], cf, pf, af, zf, sf, of, platform=platform)
def pc_actions_ADD(state, nbits, arg_l, arg_r, cc_ndep, platform=None):
data_mask, sign_mask = pc_preamble(nbits)
res = arg_l + arg_r
cf = claripy.If(claripy.ULT(res, arg_l), claripy.BVV(1, 1), claripy.BVV(0, 1))
pf = calc_paritybit(res)
af = (res ^ arg_l ^ arg_r)[data[platform]['CondBitOffsets']['G_CC_SHIFT_A']]
zf = calc_zerobit(res)
sf = res[nbits - 1:nbits - 1]
of = ((arg_l ^ arg_r ^ data_mask) & (arg_l ^ res))[nbits - 1:nbits - 1]
return pc_make_rdata(data[platform]['size'], cf, pf, af, zf, sf, of, platform=platform)
def pc_actions_SUB(state, nbits, arg_l, arg_r, cc_ndep, platform=None):
res = arg_l - arg_r
cf = claripy.If(claripy.ULT(arg_l, arg_r), claripy.BVV(1, 1), claripy.BVV(0, 1))
pf = calc_paritybit(res)
af = (res ^ arg_l ^ arg_r)[data[platform]['CondBitOffsets']['G_CC_SHIFT_A']]
zf = calc_zerobit(res)
sf = res[nbits - 1:nbits - 1]
of = ((arg_l ^ arg_r) & (arg_l ^ res))[nbits - 1:nbits - 1]
return pc_make_rdata(data[platform]['size'], cf, pf, af, zf, sf, of, platform=platform)
def _op_generic_CmpORD(self, args):
x = args[0]
y = args[1]
s = self._from_size
cond = x < y if self.is_signed else claripy.ULT(x, y)
return claripy.If(x == y, claripy.BVV(0x2, s), claripy.If(cond, claripy.BVV(0x8, s), claripy.BVV(0x4, s)))
def armg_calculate_flag_c(state, cc_op, cc_dep1, cc_dep2, cc_dep3):
concrete_op = op_concretize(cc_op)
flag = None
if concrete_op == ARMG_CC_OP_COPY:
flag = claripy.LShR(cc_dep1, ARMG_CC_SHIFT_C) & 1
elif concrete_op == ARMG_CC_OP_ADD:
res = cc_dep1 + cc_dep2
flag = boolean_extend(claripy.ULT, res, cc_dep1, 32)
elif concrete_op == ARMG_CC_OP_SUB:
flag = boolean_extend(claripy.UGE, cc_dep1, cc_dep2, 32)
elif concrete_op == ARMG_CC_OP_ADC:
res = cc_dep1 + cc_dep2 + cc_dep3
flag = claripy.If(cc_dep3 != 0, boolean_extend(claripy.ULE, res, cc_dep1, 32),
boolean_extend(claripy.ULT, res, cc_dep1, 32))
elif concrete_op == ARMG_CC_OP_SBB:
flag = claripy.If(cc_dep3 != 0, boolean_extend(claripy.UGE, cc_dep1, cc_dep2, 32),
boolean_extend(claripy.UGT, cc_dep1, cc_dep2, 32))
elif concrete_op == ARMG_CC_OP_LOGIC:
flag = cc_dep2
elif concrete_op == ARMG_CC_OP_MUL:
flag = (claripy.LShR(cc_dep3, 1)) & 1
elif concrete_op == ARMG_CC_OP_MULL:
flag = (claripy.LShR(cc_dep3, 1)) & 1
else:
try:
exponent_sol = solution(exponent)
except MultipleSolutionsError:
state.stack_push(exponent) # restore stack
state.stack_push(base)
self.add_for_fuzzing(state, exponent, EXP_EXPONENT_FUZZ)
return False
else:
state.stack_push(claripy.BVV(base_sol ** exponent_sol, 256))
elif op == opcode_values.LT:
s0, s1 = (
state.stack_pop(),
state.stack_pop(),
) # pylint:disable=invalid-name
state.stack_push(bool_to_bv(claripy.ULT(s0, s1)))
elif op == opcode_values.GT:
s0, s1 = (
state.stack_pop(),
state.stack_pop(),
) # pylint:disable=invalid-name
state.stack_push(bool_to_bv(claripy.UGT(s0, s1)))
elif op == opcode_values.SLT:
s0, s1 = (
state.stack_pop(),
state.stack_pop(),
) # pylint:disable=invalid-name
state.stack_push(bool_to_bv(claripy.SLT(s0, s1)))
elif op == opcode_values.SGT:
s0, s1 = (
state.stack_pop(),
state.stack_pop(),
def pc_actions_SUB_CondB(state, arg_l, arg_r, cc_ndep):
return _cond_flag(state, claripy.ULT(arg_l, arg_r))