How to use the pyvex.get_type_size function in pyvex

To help you get started, we’ve selected a few pyvex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angr / angr / angr / engines / vex / light / light.py View on Github external
def _ty_to_bytes(self, ty):
        return pyvex.get_type_size(ty) // getattr(getattr(getattr(self, 'state', None), 'arch', None), 'byte_width', 8)
github angr / angr / angr / engines / vex / heavy / actions.py View on Github external
def _perform_vex_expr_Load(self, addr_bundle, ty, end, **kwargs):
        addr, addr_deps = addr_bundle
        result = super()._perform_vex_expr_Load(addr, ty, end, **kwargs)

        if o.TRACK_MEMORY_ACTIONS in self.state.options:
            addr_ao = SimActionObject(addr, deps=addr_deps, state=self.state)
            r = SimActionData(self.state, self.state.memory.id, SimActionData.READ, addr=addr_ao, size=pyvex.get_type_size(ty), data=result)
            self.state.history.add_action(r)
            a = frozenset((r,))
        else:
            a = frozenset()
        return result, a
github angr / angr / angr / engines / vex / claripy / datalayer.py View on Github external
def symbol(ty, name):
    if ty == 'Ity_F32':
        return claripy.FPS(name, claripy.FSORT_FLOAT)
    elif ty == 'Ity_F64':
        return claripy.FPS(name, claripy.FSORT_DOUBLE)
    else:
        return claripy.BVS(name, pyvex.get_type_size(ty))
github angr / angr / angr / engines / vex / statements / llsc.py View on Github external
def SimIRStmt_LLSC(engine, state, stmt):
    #l.warning("LLSC is handled soundly but imprecisely.")
    with state.history.subscribe_actions() as addr_actions:
        addr = engine.handle_expression(state, stmt.addr)

    if stmt.storedata is None:
        # it's a load-linked
        load_size = get_type_size(state.scratch.tyenv.lookup(stmt.result))//state.arch.byte_width
        data = state.memory.load(addr, load_size, endness=stmt.endness)
        state.scratch.store_tmp(stmt.result, data, deps=addr_actions)
    else:
        # it's a store-conditional
        #result = state.solver.Unconstrained('llcd_result', 1)

        #new_data = self._translate_expr(stmt.storedata)
        #old_data = state.memory.load(addr, new_data.size_bytes(), endness=stmt.endness)

        #store_data = state.solver.If(result == 1, new_data, old_data)

        # for single-threaded programs, an SC will never fail. For now, we just assume it succeeded.
        with state.history.subscribe_actions() as data_actions:
            store_data = engine.handle_expression(state, stmt.storedata)

        # the action
github angr / angr / angr / engines / vex / claripy / datalayer.py View on Github external
def value(ty, val):
    if ty == 'Ity_F32':
        return claripy.FPV(float(val), claripy.FSORT_FLOAT)
    elif ty == 'Ity_F64':
        return claripy.FPV(float(val), claripy.FSORT_DOUBLE)
    else:
        return claripy.BVV(int(val), pyvex.get_type_size(ty))
github angr / angr / angr / engines / vex / heavy / actions.py View on Github external
def _perform_vex_expr_Get(self, offset_bundle, ty, **kwargs):
        offset, offset_deps = offset_bundle
        result = super()._perform_vex_expr_Get(offset, ty, **kwargs)

        if o.TRACK_REGISTER_ACTIONS in self.state.options:
            offset_ao = SimActionObject(offset, deps=offset_deps, state=self.state)
            r = SimActionData(self.state, self.state.registers.id, SimActionData.READ, addr=offset_ao,
                              size=pyvex.get_type_size(ty), data=result
                              )
            self.state.history.add_action(r)
            a = frozenset((r,))
        else:
            a = frozenset()
        return result, a