diff options
Diffstat (limited to 'src/binary-reader.c')
-rw-r--r-- | src/binary-reader.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/binary-reader.c b/src/binary-reader.c index 7af6dd63..e98def74 100644 --- a/src/binary-reader.c +++ b/src/binary-reader.c @@ -625,7 +625,6 @@ LOGGING_UINT32(on_function_names_count) LOGGING_UINT32_UINT32(on_local_names_count, "index", "count") LOGGING_END(names_section) LOGGING_BEGIN(reloc_section) -LOGGING_UINT32(on_reloc_count) LOGGING_END(reloc_section) LOGGING_UINT32_UINT32(on_init_expr_get_global_expr, "index", "global_index") @@ -983,6 +982,18 @@ static WasmResult logging_on_init_expr_i64_const_expr(uint32_t index, FORWARD(on_init_expr_i64_const_expr, index, value); } +static WasmResult logging_on_reloc_count(uint32_t count, + WasmBinarySection section_code, + WasmStringSlice section_name, + void* user_data) { + LoggingContext* ctx = user_data; + LOGF("on_reloc_count(count: %d, section: %s, section_name: " PRIstringslice + ")\n", + count, wasm_get_section_name(section_code), + WASM_PRINTF_STRING_SLICE_ARG(section_name)); + FORWARD(on_reloc_count, count, section_code, section_name); +} + static WasmBinaryReader s_logging_binary_reader = { .user_data = NULL, .on_error = logging_on_error, @@ -1694,12 +1705,15 @@ static void read_custom_section(Context* ctx, uint32_t section_size) { uint32_t i, num_relocs, section; in_u32_leb128(ctx, §ion, "section"); in_u32_leb128(ctx, &num_relocs, "relocation count count"); - CALLBACK(on_reloc_count, num_relocs); + WASM_ZERO_MEMORY(section_name); + if (section == WASM_BINARY_SECTION_CUSTOM) + in_str(ctx, §ion_name, "section name"); + CALLBACK(on_reloc_count, num_relocs, section, section_name); for (i = 0; i < num_relocs; ++i) { uint32_t reloc_type, offset; in_u32_leb128(ctx, &reloc_type, "relocation type"); in_u32_leb128(ctx, &offset, "offset"); - CALLBACK(on_reloc, reloc_type, section, offset); + CALLBACK(on_reloc, reloc_type, offset); } CALLBACK0(end_reloc_section); } else { @@ -1897,7 +1911,7 @@ static void read_export_section(Context* ctx, uint32_t section_size) { switch (external_kind) { case WASM_EXTERNAL_KIND_FUNC: RAISE_ERROR_UNLESS(item_index < num_total_funcs(ctx), - "invalid export func index"); + "invalid export func index: %d", item_index); break; case WASM_EXTERNAL_KIND_TABLE: RAISE_ERROR_UNLESS(item_index < num_total_tables(ctx), |