Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_types.h>
#include <rz_util.h>
#include <rz_lib.h>
#include <rz_bin.h>
#include "wasm.h"
Go to the source code of this file.
Typedefs | |
typedef size_t(* | ConsumeFcn) (const ut8 *p, const ut8 *max, ut32 *out_value) |
typedef void *(* | ParseEntryFcn) (RzBuffer *b, ut64 max) |
Definition at line 93 of file wasm.c.
References b, max, rz_buf_read8(), rz_buf_size(), and rz_buf_tell().
Referenced by parse_data_entry(), parse_element_entry(), and parse_global_entry().
|
static |
Definition at line 144 of file wasm.c.
References b, consume_u32_r(), consume_u7_r(), i, max, out, rz_buf_size(), and rz_buf_tell().
Referenced by parse_import_entry(), parse_memory_entry(), and parse_table_entry().
|
static |
Definition at line 114 of file wasm.c.
References b, consume_s7_r(), consume_u32_r(), count, max, out, rz_buf_size(), rz_buf_tell(), RZ_FREE, RZ_NEWS0, st8, and ut64().
Referenced by parse_code_entry().
|
static |
Definition at line 16 of file wasm.c.
References b, free(), max, n, rz_buf_read(), rz_buf_seek(), RZ_BUF_SET, rz_buf_size(), rz_buf_tell(), RZ_NEWS, rz_return_val_if_fail, autogen_x86imm::tmp, and ut64().
Referenced by consume_s7_r(), consume_u1_r(), consume_u32_r(), and consume_u7_r().
Definition at line 59 of file wasm.c.
References b, consume_r(), max, n, out, read_i32_leb128(), st8, and autogen_x86imm::tmp.
Referenced by consume_locals_r(), parse_import_entry(), parse_table_entry(), and parse_type_entry().
Definition at line 77 of file wasm.c.
References b, max, out, RZ_BIN_WASM_STRING_LENGTH, rz_buf_read(), rz_buf_size(), rz_buf_tell(), RZ_MIN, and ut64().
Referenced by parse_custom_name_entry(), parse_export_entry(), parse_import_entry(), parse_namemap(), and rz_bin_wasm_get_sections().
Definition at line 68 of file wasm.c.
References b, consume_r(), max, n, out, read_u32_leb128(), autogen_x86imm::tmp, and ut8.
Referenced by parse_global_entry(), parse_import_entry(), and parse_type_entry().
Definition at line 41 of file wasm.c.
References b, consume_r(), max, n, out, read_u32_leb128(), and autogen_x86imm::tmp.
Referenced by consume_limits_r(), consume_locals_r(), parse_code_entry(), parse_custom_name_entry(), parse_data_entry(), parse_element_entry(), parse_export_entry(), parse_import_entry(), parse_namemap(), parse_type_entry(), rz_bin_wasm_get_sections(), and rz_bin_wasm_get_start().
Definition at line 50 of file wasm.c.
References b, consume_r(), max, n, out, read_u32_leb128(), autogen_x86imm::tmp, and ut8.
Referenced by consume_limits_r(), parse_custom_name_entry(), parse_export_entry(), parse_global_entry(), parse_import_entry(), parse_type_entry(), and rz_bin_wasm_get_sections().
|
static |
Definition at line 236 of file wasm.c.
References b, bin::buf, count, max, rz_bin_wasm_section_t::name, NULL, rz_bin_wasm_section_t::payload_data, rz_bin_wasm_section_t::payload_len, r, rz_buf_seek(), RZ_BUF_SET, rz_buf_size(), rz_buf_tell(), rz_list_append(), rz_list_newf(), RZ_LOG_ERROR, rz_return_val_if_fail, and ut64().
Referenced by rz_bin_wasm_get_code_entries(), rz_bin_wasm_get_data_entries(), rz_bin_wasm_get_element_entries(), rz_bin_wasm_get_export_entries(), rz_bin_wasm_get_global_entries(), rz_bin_wasm_get_import_entries(), rz_bin_wasm_get_memory_entries(), rz_bin_wasm_get_table_entries(), and rz_bin_wasm_get_type_entries().
Definition at line 392 of file wasm.c.
References b, rz_bin_wasm_code_t::body_size, rz_bin_wasm_code_t::byte, rz_bin_wasm_code_t::code, consume_locals_r(), consume_u32_r(), rz_bin_wasm_code_t::len, rz_bin_wasm_code_t::local_count, max, NULL, RZ_BIN_WASM_END_OF_CODE, rz_bin_wasm_free_codes(), RZ_BUF_CUR, rz_buf_read(), rz_buf_seek(), rz_buf_tell(), and RZ_NEW0.
Referenced by rz_bin_wasm_get_code_entries().
Definition at line 485 of file wasm.c.
References b, consume_str_r(), consume_u32_r(), consume_u7_r(), rz_bin_wasm_custom_name_function_names_t::count, rz_bin_wasm_custom_name_local_names_t::count, free(), rz_bin_wasm_custom_name_entry_t::func, i, rz_bin_wasm_custom_name_local_name_t::index, rz_bin_wasm_name_t::len, rz_bin_wasm_custom_name_entry_t::local, rz_bin_wasm_custom_name_local_names_t::locals, max, rz_bin_wasm_custom_name_entry_t::mod_name, rz_bin_wasm_name_t::name, rz_bin_wasm_custom_name_function_names_t::names, rz_bin_wasm_custom_name_local_name_t::names, rz_bin_wasm_custom_name_local_name_t::names_count, NULL, parse_namemap(), RZ_BIN_WASM_NAMETYPE_Function, RZ_BIN_WASM_NAMETYPE_Local, RZ_BIN_WASM_NAMETYPE_Module, rz_id_storage_free(), rz_id_storage_new(), rz_list_append(), rz_list_free(), rz_list_new(), RZ_NEW0, rz_bin_wasm_custom_name_entry_t::size, rz_bin_wasm_custom_name_entry_t::type, and UT32_MAX.
Referenced by rz_bin_wasm_get_custom_name_entries().
Definition at line 424 of file wasm.c.
References b, consume_init_expr_r(), consume_u32_r(), rz_bin_wasm_data_t::data, free(), rz_bin_wasm_data_t::index, rz_bin_wasm_init_expr_t::len, max, NULL, rz_bin_wasm_data_t::offset, RZ_BIN_WASM_END_OF_CODE, RZ_BUF_CUR, rz_buf_seek(), rz_buf_tell(), RZ_NEW0, and rz_bin_wasm_data_t::size.
Referenced by rz_bin_wasm_get_data_entries().
Definition at line 643 of file wasm.c.
References b, consume_init_expr_r(), consume_u32_r(), free(), rz_bin_wasm_element_t::index, max, NULL, rz_bin_wasm_element_t::num_elem, RZ_BIN_WASM_END_OF_CODE, rz_buf_tell(), and RZ_NEW0.
Referenced by rz_bin_wasm_get_element_entries().
Definition at line 369 of file wasm.c.
References b, consume_str_r(), consume_u32_r(), consume_u7_r(), rz_bin_wasm_export_t::field_len, rz_bin_wasm_export_t::field_str, free(), rz_bin_wasm_export_t::index, rz_bin_wasm_export_t::kind, max, NULL, and RZ_NEW0.
Referenced by rz_bin_wasm_get_export_entries().
Definition at line 622 of file wasm.c.
References b, consume_init_expr_r(), consume_u1_r(), consume_u7_r(), rz_bin_wasm_global_t::content_type, free(), max, rz_bin_wasm_global_t::mutability, NULL, RZ_BIN_WASM_END_OF_CODE, and RZ_NEW0.
Referenced by rz_bin_wasm_get_global_entries().
Definition at line 312 of file wasm.c.
References b, consume_limits_r(), consume_s7_r(), consume_str_r(), consume_u1_r(), consume_u32_r(), consume_u7_r(), rz_bin_wasm_global_type_t::content_type, rz_bin_wasm_table_type_t::elem_type, rz_bin_wasm_import_t::field_len, rz_bin_wasm_import_t::field_str, free(), rz_bin_wasm_import_t::kind, rz_bin_wasm_table_type_t::limits, rz_bin_wasm_memory_type_t::limits, max, rz_bin_wasm_import_t::module_len, rz_bin_wasm_import_t::module_str, rz_bin_wasm_global_type_t::mutability, NULL, RZ_NEW0, st8, rz_bin_wasm_import_t::type_f, rz_bin_wasm_import_t::type_g, rz_bin_wasm_import_t::type_m, and rz_bin_wasm_import_t::type_t.
Referenced by rz_bin_wasm_get_import_entries().
Definition at line 589 of file wasm.c.
References b, consume_limits_r(), free(), rz_bin_wasm_memory_t::limits, max, NULL, and RZ_NEW0.
Referenced by rz_bin_wasm_get_memory_entries().
|
static |
Definition at line 447 of file wasm.c.
References b, consume_str_r(), consume_u32_r(), count, i, setup::idx, map(), max, name::name, RZ_FREE, rz_id_storage_add(), and RZ_NEW0.
Referenced by parse_custom_name_entry().
Definition at line 604 of file wasm.c.
References b, consume_limits_r(), consume_s7_r(), rz_bin_wasm_table_t::element_type, free(), rz_bin_wasm_table_t::limits, max, NULL, RZ_NEW0, and st8.
Referenced by rz_bin_wasm_get_table_entries().
Definition at line 268 of file wasm.c.
References b, consume_s7_r(), consume_u1_r(), consume_u32_r(), consume_u7_r(), count, rz_bin_wasm_type_t::form, max, NULL, rz_bin_wasm_type_t::param_count, rz_bin_wasm_type_t::param_types, rz_bin_wasm_type_t::return_count, rz_bin_wasm_type_t::return_type, rz_bin_wasm_free_types(), rz_buf_tell(), RZ_NEW0, RZ_NEWS0, and st8.
Referenced by rz_bin_wasm_get_type_entries().
void rz_bin_wasm_destroy | ( | RzBinFile * | bf | ) |
Definition at line 789 of file wasm.c.
References rz_bin_object_t::bin_obj, bin::buf, free(), rz_bin_wasm_custom_name_entry_t::func, rz_bin_wasm_custom_name_entry_t::local, local, rz_bin_wasm_custom_name_local_names_t::locals, rz_bin_wasm_custom_name_entry_t::mod_name, rz_bin_wasm_custom_name_function_names_t::names, NULL, rz_bin_file_t::o, RZ_BIN_WASM_NAMETYPE_Function, RZ_BIN_WASM_NAMETYPE_Local, RZ_BIN_WASM_NAMETYPE_Module, rz_buf_free(), rz_id_storage_free(), rz_list_free(), and rz_bin_wasm_custom_name_entry_t::type.
Referenced by destroy().
|
static |
Definition at line 228 of file wasm.c.
References free(), and rz_bin_wasm_code_t::locals.
Referenced by parse_code_entry(), and rz_bin_wasm_get_code_entries().
|
static |
Definition at line 221 of file wasm.c.
References free(), and rz_bin_wasm_type_t::param_types.
Referenced by parse_type_entry(), and rz_bin_wasm_get_type_entries().
|
static |
Definition at line 683 of file wasm.c.
References get_entries_from_section(), parse_code_entry(), and rz_bin_wasm_free_codes().
Referenced by rz_bin_wasm_get_codes().
RzList* rz_bin_wasm_get_codes | ( | RzBinWasmObj * | bin | ) |
Definition at line 1168 of file wasm.c.
References codes(), NULL, rz_bin_wasm_get_code_entries(), rz_bin_wasm_get_sections_by_id(), RZ_BIN_WASM_SECTION_CODE, rz_list_first(), rz_list_free(), and rz_list_new().
Referenced by entries(), rz_bin_wasm_init(), and symbols().
|
static |
Definition at line 730 of file wasm.c.
References bin::buf, max, NULL, parse_custom_name_entry(), rz_bin_wasm_section_t::payload_data, rz_bin_wasm_section_t::payload_len, rz_buf_seek(), RZ_BUF_SET, rz_buf_size(), rz_buf_tell(), rz_list_append(), rz_list_free(), rz_list_new(), and ut64().
Referenced by rz_bin_wasm_get_custom_names().
RzList* rz_bin_wasm_get_custom_names | ( | RzBinWasmObj * | bin | ) |
Definition at line 1215 of file wasm.c.
References rz_bin_wasm_section_t::name, NULL, rz_bin_wasm_get_custom_name_entries(), rz_bin_wasm_get_sections_by_id(), RZ_BIN_WASM_SECTION_CUSTOM, rz_list_first(), rz_list_free(), rz_list_new(), and rz_return_val_if_fail.
Referenced by rz_bin_wasm_init().
|
static |
Definition at line 687 of file wasm.c.
References free(), get_entries_from_section(), and parse_data_entry().
Referenced by rz_bin_wasm_get_datas().
RzList* rz_bin_wasm_get_datas | ( | RzBinWasmObj * | bin | ) |
Definition at line 1192 of file wasm.c.
References NULL, rz_bin_wasm_get_data_entries(), rz_bin_wasm_get_sections_by_id(), RZ_BIN_WASM_SECTION_DATA, rz_list_first(), rz_list_free(), and rz_list_new().
Referenced by rz_bin_wasm_init().
|
static |
Definition at line 726 of file wasm.c.
References free(), get_entries_from_section(), and parse_element_entry().
Referenced by rz_bin_wasm_get_elements().
RzList* rz_bin_wasm_get_elements | ( | RzBinWasmObj * | bin | ) |
Definition at line 1145 of file wasm.c.
References NULL, rz_bin_wasm_get_element_entries(), rz_bin_wasm_get_sections_by_id(), RZ_BIN_WASM_SECTION_ELEMENT, rz_list_first(), rz_list_free(), and rz_list_new().
ut32 rz_bin_wasm_get_entrypoint | ( | RzBinWasmObj * | bin | ) |
Definition at line 966 of file wasm.c.
References rz_bin_wasm_code_t::code, NULL, rz_bin_wasm_get_sections_by_id(), rz_bin_wasm_get_start(), RZ_BIN_WASM_SECTION_START, rz_list_first(), rz_list_free(), rz_list_get_n(), and start.
Referenced by entries(), and rz_bin_wasm_init().
|
static |
Definition at line 679 of file wasm.c.
References free(), get_entries_from_section(), and parse_export_entry().
Referenced by rz_bin_wasm_get_exports().
RzList* rz_bin_wasm_get_exports | ( | RzBinWasmObj * | bin | ) |
Definition at line 1026 of file wasm.c.
References NULL, rz_bin_wasm_get_export_entries(), rz_bin_wasm_get_sections_by_id(), RZ_BIN_WASM_SECTION_EXPORT, rz_list_first(), rz_list_free(), and rz_list_new().
Referenced by rz_bin_wasm_init(), and symbols().
const char* rz_bin_wasm_get_function_name | ( | RzBinWasmObj * | bin, |
ut32 | idx | ||
) |
Definition at line 1237 of file wasm.c.
References rz_bin_wasm_custom_name_entry_t::func, setup::idx, n, rz_bin_wasm_custom_name_function_names_t::names, NULL, RZ_BIN_WASM_NAMETYPE_Function, rz_id_storage_get(), and rz_bin_wasm_custom_name_entry_t::type.
Referenced by symbols().
|
static |
Definition at line 722 of file wasm.c.
References free(), get_entries_from_section(), and parse_global_entry().
Referenced by rz_bin_wasm_get_globals().
RzList* rz_bin_wasm_get_globals | ( | RzBinWasmObj * | bin | ) |
Definition at line 1122 of file wasm.c.
References NULL, rz_bin_wasm_get_global_entries(), rz_bin_wasm_get_sections_by_id(), RZ_BIN_WASM_SECTION_GLOBAL, rz_list_first(), rz_list_free(), and rz_list_new().
Referenced by rz_bin_wasm_init().
|
static |
Definition at line 675 of file wasm.c.
References free(), get_entries_from_section(), and parse_import_entry().
Referenced by rz_bin_wasm_get_imports().
RzList* rz_bin_wasm_get_imports | ( | RzBinWasmObj * | bin | ) |
Definition at line 1003 of file wasm.c.
References imports(), NULL, rz_bin_wasm_get_import_entries(), rz_bin_wasm_get_sections_by_id(), RZ_BIN_WASM_SECTION_IMPORT, rz_list_first(), rz_list_free(), and rz_list_new().
Referenced by imports(), rz_bin_wasm_init(), and symbols().
RzList* rz_bin_wasm_get_memories | ( | RzBinWasmObj * | bin | ) |
Definition at line 1095 of file wasm.c.
References NULL, rz_bin_wasm_get_memory_entries(), rz_bin_wasm_get_sections_by_id(), RZ_BIN_WASM_SECTION_MEMORY, rz_list_first(), rz_list_free(), and rz_list_new().
Referenced by rz_bin_wasm_init().
|
static |
Definition at line 714 of file wasm.c.
References free(), get_entries_from_section(), and parse_memory_entry().
Referenced by rz_bin_wasm_get_memories().
RzList* rz_bin_wasm_get_sections | ( | RzBinWasmObj * | bin | ) |
Definition at line 846 of file wasm.c.
References b, bin::buf, consume_str_r(), consume_u32_r(), consume_u7_r(), rz_bin_wasm_section_t::count, free(), rz_bin_wasm_section_t::id, max, rz_bin_wasm_section_t::name, rz_bin_wasm_section_t::name_len, NULL, rz_bin_wasm_section_t::offset, rz_bin_wasm_section_t::payload_data, rz_bin_wasm_section_t::payload_len, RZ_BIN_WASM_SECTION_CODE, RZ_BIN_WASM_SECTION_CUSTOM, RZ_BIN_WASM_SECTION_DATA, RZ_BIN_WASM_SECTION_ELEMENT, RZ_BIN_WASM_SECTION_EXPORT, RZ_BIN_WASM_SECTION_FUNCTION, RZ_BIN_WASM_SECTION_GLOBAL, RZ_BIN_WASM_SECTION_IMPORT, RZ_BIN_WASM_SECTION_MEMORY, RZ_BIN_WASM_SECTION_START, RZ_BIN_WASM_SECTION_TABLE, RZ_BIN_WASM_SECTION_TYPE, RZ_BUF_CUR, rz_buf_seek(), RZ_BUF_SET, rz_buf_size(), rz_buf_tell(), rz_list_append(), rz_list_newf(), RZ_LOG_ERROR, RZ_NEW0, rz_bin_wasm_section_t::size, and ut64().
Referenced by rz_bin_wasm_init(), and sections().
Definition at line 162 of file wasm.c.
References rz_bin_wasm_section_t::id, NULL, rz_list_append(), rz_list_newf(), and sections().
Referenced by rz_bin_wasm_get_codes(), rz_bin_wasm_get_custom_names(), rz_bin_wasm_get_datas(), rz_bin_wasm_get_elements(), rz_bin_wasm_get_entrypoint(), rz_bin_wasm_get_exports(), rz_bin_wasm_get_globals(), rz_bin_wasm_get_imports(), rz_bin_wasm_get_memories(), rz_bin_wasm_get_tables(), and rz_bin_wasm_get_types().
|
static |
Definition at line 691 of file wasm.c.
References b, bin::buf, consume_u32_r(), free(), rz_bin_wasm_start_t::index, max, NULL, rz_bin_wasm_section_t::payload_data, rz_bin_wasm_section_t::payload_len, rz_buf_seek(), RZ_BUF_SET, rz_buf_size(), rz_buf_tell(), RZ_LOG_ERROR, RZ_NEW0, and ut64().
Referenced by rz_bin_wasm_get_entrypoint().
|
static |
Definition at line 718 of file wasm.c.
References free(), get_entries_from_section(), and parse_table_entry().
Referenced by rz_bin_wasm_get_tables().
RzList* rz_bin_wasm_get_tables | ( | RzBinWasmObj * | bin | ) |
Definition at line 1072 of file wasm.c.
References NULL, rz_bin_wasm_get_sections_by_id(), rz_bin_wasm_get_table_entries(), RZ_BIN_WASM_SECTION_TABLE, rz_list_first(), rz_list_free(), and rz_list_new().
Referenced by rz_bin_wasm_init().
|
static |
Definition at line 671 of file wasm.c.
References get_entries_from_section(), parse_type_entry(), and rz_bin_wasm_free_types().
Referenced by rz_bin_wasm_get_types().
RzList* rz_bin_wasm_get_types | ( | RzBinWasmObj * | bin | ) |
Definition at line 1049 of file wasm.c.
References NULL, rz_bin_wasm_get_sections_by_id(), rz_bin_wasm_get_type_entries(), RZ_BIN_WASM_SECTION_TYPE, rz_list_first(), rz_list_free(), rz_list_new(), type, and types.
Referenced by rz_bin_wasm_init().
RzBinWasmObj* rz_bin_wasm_init | ( | RzBinFile * | bf, |
RzBuffer * | buf | ||
) |
Definition at line 761 of file wasm.c.
References rz_bin_file_t::buf, bin::buf, NULL, rz_bin_wasm_get_codes(), rz_bin_wasm_get_custom_names(), rz_bin_wasm_get_datas(), rz_bin_wasm_get_entrypoint(), rz_bin_wasm_get_exports(), rz_bin_wasm_get_globals(), rz_bin_wasm_get_imports(), rz_bin_wasm_get_memories(), rz_bin_wasm_get_sections(), rz_bin_wasm_get_tables(), rz_bin_wasm_get_types(), rz_buf_ref(), rz_buf_size(), and RZ_NEW0.
Referenced by load_buffer().