Rizin
unix-like reverse engineering framework and cli tools
|
Go to the source code of this file.
Functions | |
static int | reg_offset_cmp (const void *value, const void *list_data) |
static void | reg_binding_item_fini (RzILRegBindingItem *item, void *unused) |
RZ_API RzILRegBinding * | rz_il_reg_binding_derive (RZ_NONNULL RzReg *reg) |
Calculate a new binding of IL variables against the profile of the given RzReg. More... | |
RZ_API RzILRegBinding * | rz_il_reg_binding_exactly (RZ_NONNULL RzReg *reg, size_t regs_count, RZ_NONNULL RZ_BORROW const char **regs) |
RZ_API void | rz_il_reg_binding_free (RzILRegBinding *rb) |
RZ_API void | rz_il_vm_setup_reg_binding (RZ_NONNULL RzILVM *vm, RZ_NONNULL RZ_BORROW RzILRegBinding *rb) |
RZ_API bool | rz_il_vm_sync_to_reg (RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILRegBinding *rb, RZ_NONNULL RzReg *reg) |
RZ_API void | rz_il_vm_sync_from_reg (RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILRegBinding *rb, RZ_NONNULL RzReg *reg) |
|
static |
Definition at line 12 of file il_reg.c.
References free(), and rz_il_reg_binding_item_t::name.
Referenced by rz_il_reg_binding_derive(), rz_il_reg_binding_exactly(), and rz_il_reg_binding_free().
Definition at line 8 of file il_reg.c.
References value.
Referenced by rz_il_reg_binding_derive().
RZ_API RzILRegBinding* rz_il_reg_binding_derive | ( | RZ_NONNULL RzReg * | reg | ) |
Calculate a new binding of IL variables against the profile of the given RzReg.
Because registers can overlap, not all registers may get a binding. Informally, only the "larger" ones, containing "smaller" ones are bound, except for 1-bit registers, which are always preferred.
More specifically, the set of registers to be bound is determined like this: First, bind all 1-bit registers (flags). Then, bind a (sub)set of the remaining registers like this:
If two registers have the same offset and size, the result is currently undefined.
Definition at line 35 of file il_reg.c.
References err, flags, free(), i, name, rz_il_reg_binding_item_t::name, rz_reg_item_t::name, NULL, rz_reg_item_t::offset, pc, reg, reg_binding_item_fini(), reg_offset_cmp(), regs, rz_il_reg_binding_t::regs, rz_il_reg_binding_t::regs_count, rz_list_free(), rz_list_new(), rz_list_push(), rz_list_sort(), RZ_NEW0, rz_reg_filter_items_covered(), rz_reg_get_name(), RZ_REG_NAME_PC, RZ_REG_TYPE_LAST, rz_return_val_if_fail, rz_vector_fini(), rz_vector_flush(), rz_vector_init(), rz_vector_len(), rz_vector_push(), rz_il_reg_binding_item_t::size, rz_reg_item_t::size, and strdup().
Referenced by setup_regs().
RZ_API RzILRegBinding* rz_il_reg_binding_exactly | ( | RZ_NONNULL RzReg * | reg, |
size_t | regs_count, | ||
RZ_NONNULL RZ_BORROW const char ** | regs | ||
) |
Create a new binding that binds exactly the given register names, querying reg
for any additionally needed info
regs | array of regs_count names of registers. Each of these must be part of reg and they must not overlap. |
Definition at line 154 of file il_reg.c.
References free(), i, rz_il_reg_binding_item_t::name, NULL, rz_reg_item_t::offset, reg, reg_binding_item_fini(), regs, rz_il_reg_binding_t::regs, rz_il_reg_binding_t::regs_count, RZ_NEW, RZ_NEWS, RZ_NEWS0, rz_reg_get(), RZ_REG_TYPE_ANY, rz_return_val_if_fail, rz_il_reg_binding_item_t::size, rz_reg_item_t::size, strdup(), type, and rz_reg_item_t::type.
Referenced by setup_regs().
RZ_API void rz_il_reg_binding_free | ( | RzILRegBinding * | rb | ) |
Definition at line 207 of file il_reg.c.
References free(), i, NULL, reg_binding_item_fini(), rz_il_reg_binding_t::regs, and rz_il_reg_binding_t::regs_count.
Referenced by rz_analysis_il_vm_free().
RZ_API void rz_il_vm_setup_reg_binding | ( | RZ_NONNULL RzILVM * | vm, |
RZ_NONNULL RZ_BORROW RzILRegBinding * | rb | ||
) |
Setup variables to bind against registers rb
the binding for which to create variables
Definition at line 222 of file il_reg.c.
References i, rz_il_sort_pure_bool(), rz_il_sort_pure_bv(), rz_il_vm_create_global_var(), and rz_return_if_fail.
Referenced by setup_regs().
RZ_API void rz_il_vm_sync_from_reg | ( | RZ_NONNULL RzILVM * | vm, |
RZ_NONNULL RzILRegBinding * | rb, | ||
RZ_NONNULL RzReg * | reg | ||
) |
Set the values of all variables in vm
that are bound to registers and PC to the respective contents from reg
. Contents of variables that are not bound to a register are left unchanged.
Definition at line 316 of file il_reg.c.
References b, i, rz_il_var_t::name, rz_il_reg_binding_item_t::name, NULL, pc, reg, rz_bv_copy_nbits(), rz_bv_free(), rz_bv_len(), rz_bv_new_zero, rz_bv_set_all(), rz_il_bool_new(), rz_il_value_new_bitv(), rz_il_value_new_bool(), RZ_IL_VAR_KIND_GLOBAL, rz_il_vm_get_var(), rz_il_vm_set_global_var(), RZ_LOG_ERROR, RZ_MIN, rz_reg_get(), rz_reg_get_bv(), rz_reg_get_name(), rz_reg_get_value(), RZ_REG_NAME_PC, RZ_REG_TYPE_ANY, rz_return_if_fail, and rz_il_reg_binding_item_t::size.
Referenced by rz_analysis_il_vm_sync_from_reg(), and setup_vm_init_state().
RZ_API bool rz_il_vm_sync_to_reg | ( | RZ_NONNULL RzILVM * | vm, |
RZ_NONNULL RzILRegBinding * | rb, | ||
RZ_NONNULL RzReg * | reg | ||
) |
Set the values of all bound regs in reg
to the respective variable or PC contents in vm
.
Contents of unbound registers are left unchanged (unless they overlap with bound registers).
If for example the register profile used for reg
does not match the one used to build the initial binding, different errors might happen, e.g. a register size might not match the variable's value size. In such cases, this function still applies everything it can, zero-extending or cropping values where necessary.
Definition at line 241 of file il_reg.c.
References i, rz_il_reg_binding_item_t::name, NULL, pc, reg, rz_bv_copy_nbits(), rz_bv_free(), rz_bv_is_zero_vector(), rz_bv_len(), rz_bv_new_one, rz_bv_new_zero, rz_bv_set_from_ut64(), RZ_IL_TYPE_PURE_BITVECTOR, RZ_IL_VAR_KIND_GLOBAL, rz_il_vm_get_var_value(), RZ_MIN, rz_reg_get(), rz_reg_get_name(), RZ_REG_NAME_PC, rz_reg_set_bv(), RZ_REG_TYPE_ANY, rz_return_val_if_fail, rz_reg_item_t::size, and val.
Referenced by rz_analysis_il_vm_setup(), and rz_analysis_il_vm_sync_to_reg().