def set_value(self, state, val, size=None, endness=None, **kwargs): if size == 4: if state.arch.register_endness == 'IEnd_LE' and endness == 'IEnd_BE': val = claripy.fpToFP(claripy.fp.RM_RNE, val.reversed.raw_to_fp(), claripy.FSORT_DOUBLE).reversed else: val = claripy.fpToFP(claripy.fp.RM_RNE, val.raw_to_fp(), claripy.FSORT_DOUBLE) if endness and endness != state.args.register_endness: val = val.reversed setattr(state.regs, self.reg_name, val)
def set_value(self, state, val, size=None, endness=None, **kwargs): if size == 4: if state.arch.register_endness == 'IEnd_LE' and endness == 'IEnd_BE': # pylint: disable=no-member val = claripy.fpToFP(claripy.fp.RM_RNE, val.reversed.raw_to_fp(), claripy.FSORT_DOUBLE).reversed else: val = claripy.fpToFP(claripy.fp.RM_RNE, val.raw_to_fp(), claripy.FSORT_DOUBLE) if endness and endness != state.args.register_endness: val = val.reversed setattr(state.regs, self.reg_name, val)
def _op_fgeneric_Round(self, args): if self._vector_size is not None: rm = { 'RM': claripy.fp.RM.RM_TowardsNegativeInf, 'RP': claripy.fp.RM.RM_TowardsPositiveInf, 'RN': claripy.fp.RM.RM_NearestTiesEven, 'RZ': claripy.fp.RM.RM_TowardsZero, }[self._rounding_mode] rounded = [] for i in reversed(range(self._vector_count)): #pylint:disable=no-member left = claripy.Extract((i + 1) * self._vector_size - 1, i * self._vector_size, args[0]).raw_to_fp() rounded.append(claripy.fpToSBV(rm, left, self._vector_size)) return claripy.Concat(*rounded) else: # note: this a bad solution because it will cut off high values # TODO: look into fixing this rm = self._translate_rm(args[0]) rounded_bv = claripy.fpToSBV(rm, args[1].raw_to_fp(), args[1].length) return claripy.fpToFP(claripy.fp.RM.RM_NearestTiesEven, rounded_bv, claripy.fp.FSort.from_size(args[1].length))
def get_value(self, state, size=None, endness=None, **kwargs): #val = super(SimLyingRegArg, self).get_value(state, **kwargs) val = getattr(state.regs, self.reg_name) if endness and endness != state.args.register_endness: val = val.reversed if size == 4: val = claripy.fpToFP(claripy.fp.RM_RNE, val.raw_to_fp(), claripy.FSORT_FLOAT) return val
def _op_fgeneric_Round(self, args): if self._vector_size is not None: rm = { 'RM': claripy.fp.RM_RTN, 'RP': claripy.fp.RM_RTP, 'RN': claripy.fp.RM_RNE, 'RZ': claripy.fp.RM_RTZ, }[self._rounding_mode] rounded = [] for i in reversed(range(self._vector_count)): left = claripy.Extract((i+1) * self._vector_size - 1, i * self._vector_size, args[0]).raw_to_fp() rounded.append(claripy.fpToSBV(rm, left, self._vector_size)) return claripy.Concat(*rounded) else: # note: this a bad solution because it will cut off high values # TODO: look into fixing this rm = self._translate_rm(args[0]) rounded_bv = claripy.fpToSBV(rm, args[1].raw_to_fp(), args[1].length) return claripy.fpToFP(claripy.fp.RM_RNE, rounded_bv, claripy.FSort.from_size(args[1].length))
def _op_fgeneric_Round(self, args): if self._vector_size is not None: rm = { 'RM': claripy.fp.RM_RTN, 'RP': claripy.fp.RM_RTP, 'RN': claripy.fp.RM_RNE, 'RZ': claripy.fp.RM_RTZ, }[self._rounding_mode] rounded = [] for i in reversed(range(self._vector_count)): left = claripy.Extract((i + 1) * self._vector_size - 1, i * self._vector_size, args[0]).raw_to_fp() rounded.append(claripy.fpToSBV(rm, left, self._vector_size)) return claripy.Concat(*rounded) else: # note: this a bad solution because it will cut off high values # TODO: look into fixing this rm = self._translate_rm(args[0]) rounded_bv = claripy.fpToSBV(rm, args[1].raw_to_fp(), args[1].length) return claripy.fpToFP(claripy.fp.RM_RNE, rounded_bv, claripy.FSort.from_size(args[1].length))
def extract(self, state, addr, concrete=False): itype = claripy.fpToFP( super(SimTypeFloat, self).extract(state, addr, False), self.sort) if concrete: return state.solver.eval(itype) return itype
def extract(self, state, addr, concrete=False): itype = claripy.fpToFP(super(SimTypeFloat, self).extract(state, addr, False), self.sort) if concrete: return state.solver.eval(itype) return itype