本文整理汇总了Python中claripy.If方法的典型用法代码示例。如果您正苦于以下问题:Python claripy.If方法的具体用法?Python claripy.If怎么用?Python claripy.If使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类claripy
的用法示例。
在下文中一共展示了claripy.If方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: amd64g_check_ldmxcsr
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def amd64g_check_ldmxcsr(state, mxcsr):
rmode = state.solver.LShR(mxcsr, 13) & 3
ew = state.solver.If(
(mxcsr & 0x1F80) != 0x1F80,
state.solver.BVV(EmWarn_X86_sseExns, 64),
state.solver.If(
mxcsr & (1 << 15) != 0,
state.solver.BVV(EmWarn_X86_fz, 64),
state.solver.If(
mxcsr & (1 << 6) != 0,
state.solver.BVV(EmWarn_X86_daz, 64),
state.solver.BVV(EmNote_NONE, 64)
)
)
)
return (ew << 32) | rmode, ()
# see canonical implementation of this in guest_amd64_helpers.c
示例2: x86g_dirtyhelper_loadF80le
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def x86g_dirtyhelper_loadF80le(state, addr):
tbyte = state.memory.load(addr, size=10, endness='Iend_LE')
sign = tbyte[79]
exponent = tbyte[78:64]
mantissa = tbyte[62:0]
normalized_exponent = exponent[10:0] - 16383 + 1023
zero_exponent = state.solver.BVV(0, 11)
inf_exponent = state.solver.BVV(-1, 11)
final_exponent = claripy.If(exponent == 0, zero_exponent, claripy.If(exponent == -1, inf_exponent, normalized_exponent))
normalized_mantissa = tbyte[62:11]
zero_mantissa = claripy.BVV(0, 52)
inf_mantissa = claripy.BVV(-1, 52)
final_mantissa = claripy.If(exponent == 0, zero_mantissa, claripy.If(exponent == -1, claripy.If(mantissa == 0, zero_mantissa, inf_mantissa), normalized_mantissa))
qword = claripy.Concat(sign, final_exponent, final_mantissa)
assert len(qword) == 64
return qword, []
示例3: x86g_dirtyhelper_storeF80le
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def x86g_dirtyhelper_storeF80le(state, addr, qword):
sign = qword[63]
exponent = qword[62:52]
mantissa = qword[51:0]
normalized_exponent = exponent.zero_extend(4) - 1023 + 16383
zero_exponent = state.solver.BVV(0, 15)
inf_exponent = state.solver.BVV(-1, 15)
final_exponent = claripy.If(exponent == 0, zero_exponent, claripy.If(exponent == -1, inf_exponent, normalized_exponent))
normalized_mantissa = claripy.Concat(claripy.BVV(1, 1), mantissa, claripy.BVV(0, 11))
zero_mantissa = claripy.BVV(0, 64)
inf_mantissa = claripy.BVV(-1, 64)
final_mantissa = claripy.If(exponent == 0, zero_mantissa, claripy.If(exponent == -1, claripy.If(mantissa == 0, zero_mantissa, inf_mantissa), normalized_mantissa))
tbyte = claripy.Concat(sign, final_exponent, final_mantissa)
assert len(tbyte) == 80
state.memory.store(addr, tbyte, endness='Iend_LE')
return None, []
示例4: pc_actions_ADC
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def pc_actions_ADC(state, nbits, cc_dep1, cc_dep2, cc_ndep, platform=None):
old_c = cc_ndep & data[platform]['CondBitMasks']['G_CC_MASK_C']
arg_l = cc_dep1
arg_r = cc_dep2 ^ old_c
res = (arg_l + arg_r) + old_c
cf = claripy.If(
old_c != 0,
claripy.If(res <= arg_l, claripy.BVV(1, 1), claripy.BVV(0, 1)),
claripy.If(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]
of = ((arg_l ^ arg_r ^ -1) & (arg_l ^ res))[nbits-1]
return pc_make_rdata(data[platform]['size'], cf, pf, af, zf, sf, of, platform=platform)
示例5: amd64g_check_ldmxcsr
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def amd64g_check_ldmxcsr(state, mxcsr):
rmode = claripy.LShR(mxcsr, 13) & 3
ew = claripy.If(
(mxcsr & 0x1F80) != 0x1F80,
claripy.BVV(EmWarn_X86_sseExns, 64),
claripy.If(
mxcsr & (1<<15) != 0,
claripy.BVV(EmWarn_X86_fz, 64),
claripy.If(
mxcsr & (1<<6) != 0,
claripy.BVV(EmWarn_X86_daz, 64),
claripy.BVV(EmNote_NONE, 64)
)
)
)
return (ew << 32) | rmode
#################
### ARM Flags ###
#################
示例6: generic_compare
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def generic_compare(self, args, comparison):
if self._vector_size is not None:
res_comps = []
for i in reversed(range(self._vector_count)):
a_comp = claripy.Extract((i+1) * self._vector_size - 1,
i * self._vector_size,
args[0])
b_comp = claripy.Extract((i+1) * self._vector_size - 1,
i * self._vector_size,
args[1])
res_comps.append(claripy.If(comparison(a_comp, b_comp),
claripy.BVV(-1, self._vector_size),
claripy.BVV(0, self._vector_size)))
return claripy.Concat(*res_comps)
else:
return claripy.If(comparison(args[0], args[1]), claripy.BVV(1, 1), claripy.BVV(0, 1))
示例7: _op_generic_QSub
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def _op_generic_QSub(self, args):
"""
Saturating subtract.
"""
components = []
for a, b in self.vector_args(args):
top_a = a[self._vector_size-1]
top_b = b[self._vector_size-1]
res = a - b
top_r = res[self._vector_size-1]
if self.is_signed:
big_top_r = (~top_r).zero_extend(self._vector_size-1)
cap = (claripy.BVV(-1, self._vector_size)//2) + big_top_r
cap_cond = ((top_a ^ top_b) & (top_a ^ top_r)) == 1
else:
cap = claripy.BVV(0, self._vector_size)
cap_cond = claripy.UGT(res, a)
components.append(claripy.If(cap_cond, cap, res))
return claripy.Concat(*components)
示例8: test_if_stuff
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def test_if_stuff():
x = claripy.BVS('x', 32)
#y = claripy.BVS('y', 32)
c = claripy.If(x > 10, (claripy.If(x > 10, x*3, x*2)), x*4) + 2
cc = claripy.If(x > 10, x*3, x*4) + 2
ccc = claripy.If(x > 10, x*3+2, x*4+2)
cccc = x*claripy.If(x > 10, claripy.BVV(3, 32), claripy.BVV(4, 32)) + 2
nose.tools.assert_is(c, cc)
nose.tools.assert_is(c.ite_excavated, ccc)
nose.tools.assert_is(ccc.ite_burrowed, cccc)
i = c + c
ii = claripy.If(x > 10, (x*3+2)+(x*3+2), (x*4+2)+(x*4+2))
nose.tools.assert_is(i.ite_excavated, ii)
cn = claripy.If(x <= 10, claripy.BVV(0x10, 32), 0x20)
iii = c + cn
iiii = claripy.If(x > 10, (x*3+2)+0x20, (x*4+2)+0x10)
nose.tools.assert_is(iii.ite_excavated, iiii)
示例9: test_canonical
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def test_canonical():
x1 = claripy.BVS('x', 32)
b1 = claripy.BoolS('b')
c1 = claripy.BoolS('c')
x2 = claripy.BVS('x', 32)
b2 = claripy.BoolS('b')
c2 = claripy.BoolS('c')
assert x1.canonicalize()[-1] is x2.canonicalize()[-1]
y1 = claripy.If(claripy.And(b1, c1), x1, ((x1+x1)*x1)+1)
y2 = claripy.If(claripy.And(b2, c2), x2, ((x2+x2)*x2)+1)
one_names = frozenset.union(x1.variables, b1.variables, c1.variables)
two_names = frozenset.union(x2.variables, b2.variables, c2.variables)
assert frozenset.union(*[a.variables for a in y1.recursive_leaf_asts]) == one_names
assert frozenset.union(*[a.variables for a in y2.recursive_leaf_asts]) == two_names
assert y1.canonicalize()[-1] is y2.canonicalize()[-1]
示例10: calc_zerobit
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def calc_zerobit(p):
return claripy.If(p == 0, claripy.BVV(1, 1), claripy.BVV(0, 1))
示例11: boolean_extend
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def boolean_extend(O, a, b, size):
return claripy.If(O(a, b), claripy.BVV(1, size), claripy.BVV(0, size))
示例12: pc_actions_ADD
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
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)
示例13: pc_actions_SUB
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
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)
示例14: pc_actions_DEC
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def pc_actions_DEC(state, nbits, res, _, cc_ndep, platform=None):
arg_l = res + 1
arg_r = 1
cf = (cc_ndep & data[platform]['CondBitMasks']['G_CC_MASK_C'])[data[platform]['CondBitOffsets']['G_CC_SHIFT_C']]
pf = calc_paritybit(res)
af = (res ^ arg_l ^ 1)[data[platform]['CondBitOffsets']['G_CC_SHIFT_A']]
zf = calc_zerobit(res)
sf = res[nbits-1]
of = claripy.If(sf == arg_l[nbits-1], claripy.BVV(0, 1), claripy.BVV(1, 1))
return pc_make_rdata(data[platform]['size'], cf, pf, af, zf, sf, of, platform=platform)
示例15: pc_actions_ADCX
# 需要导入模块: import claripy [as 别名]
# 或者: from claripy import If [as 别名]
def pc_actions_ADCX(state, nbits, cc_dep1, cc_dep2, cc_ndep, is_adc, platform=None):
pf = (cc_ndep & data[platform]['CondBitMasks']['G_CC_MASK_P'])[data[platform]['CondBitOffsets']['G_CC_SHIFT_P']]
af = (cc_ndep & data[platform]['CondBitMasks']['G_CC_MASK_A'])[data[platform]['CondBitOffsets']['G_CC_SHIFT_A']]
zf = (cc_ndep & data[platform]['CondBitMasks']['G_CC_MASK_Z'])[data[platform]['CondBitOffsets']['G_CC_SHIFT_Z']]
sf = (cc_ndep & data[platform]['CondBitMasks']['G_CC_MASK_S'])[data[platform]['CondBitOffsets']['G_CC_SHIFT_S']]
if is_adc:
carry = claripy.LShR(cc_ndep, data[platform]['CondBitOffsets']['G_CC_SHIFT_C']) & 1
of = (cc_ndep & data[platform]['CondBitMasks']['G_CC_MASK_O'])[data[platform]['CondBitOffsets']['G_CC_SHIFT_O']]
else:
carry = claripy.LShR(cc_ndep, data[platform]['CondBitOffsets']['G_CC_SHIFT_O']) & 1
cf = (cc_ndep & data[platform]['CondBitMasks']['G_CC_MASK_C'])[data[platform]['CondBitOffsets']['G_CC_SHIFT_C']]
arg_l = cc_dep1
arg_r = cc_dep2 ^ carry
res = (arg_l + arg_r) + carry
carry = claripy.If(
carry != 0,
claripy.If(res <= arg_l, claripy.BVV(1, 1), claripy.BVV(0, 1)),
claripy.If(res < arg_l, claripy.BVV(1, 1), claripy.BVV(0, 1))
)
if is_adc:
cf = carry
else:
of = carry
return pc_make_rdata(data[platform]['size'], cf, pf, af, zf, sf, of, platform=platform)