diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/binary-reader-objdump.c | 18 | ||||
-rw-r--r-- | src/tools/wasmdump.c | 5 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/binary-reader-objdump.c b/src/binary-reader-objdump.c index 4633410a..4c2b4018 100644 --- a/src/binary-reader-objdump.c +++ b/src/binary-reader-objdump.c @@ -65,6 +65,11 @@ static WasmResult do_begin_section(Context* ctx, const char* name, size_t offset, size_t size) { + WasmBool section_match = !ctx->options->section_name || + !strcasecmp(ctx->options->section_name, name); + if (section_match) + ctx->section_found = WASM_TRUE; + switch (ctx->options->mode) { case WASM_DUMP_HEADERS: printf("%9s start=%#010" PRIzx " end=%#010" PRIzx " (size=%#010" PRIzx @@ -72,18 +77,19 @@ static WasmResult do_begin_section(Context* ctx, name, offset, offset + size, size); break; case WASM_DUMP_DETAILS: - if (!ctx->options->section_name || !strcasecmp(ctx->options->section_name, name)) { + if (section_match) { printf("%s:\n", name); ctx->print_details = WASM_TRUE; - ctx->section_found = WASM_TRUE; } else { ctx->print_details = WASM_FALSE; } break; case WASM_DUMP_RAW_DATA: - printf("\nContents of section %s:\n", name); - wasm_write_memory_dump(ctx->out_stream, ctx->data + offset, size, offset, - WASM_PRINT_CHARS, NULL, NULL); + if (section_match) { + printf("\nContents of section %s:\n", name); + wasm_write_memory_dump(ctx->out_stream, ctx->data + offset, size, + offset, WASM_PRINT_CHARS, NULL, NULL); + } break; case WASM_DUMP_DISASSEMBLE: break; @@ -151,7 +157,7 @@ static WasmResult begin_module(uint32_t version, void* user_data) { static WasmResult end_module(void *user_data) { Context* ctx = user_data; - if (ctx->options->mode == WASM_DUMP_DETAILS && ctx->options->section_name) { + if (ctx->options->section_name) { if (!ctx->section_found) { printf("Section not found: %s\n", ctx->options->section_name); return WASM_ERROR; diff --git a/src/tools/wasmdump.c b/src/tools/wasmdump.c index 9f58d524..9696473d 100644 --- a/src/tools/wasmdump.c +++ b/src/tools/wasmdump.c @@ -52,7 +52,8 @@ static WasmOption s_options[] = { {FLAG_HEADERS, 'h', "headers", NULL, NOPE, "print headers"}, {FLAG_SECTION, 'j', "section", NULL, YEP, "select just one section"}, {FLAG_RAW, 'r', "raw", NULL, NOPE, "print raw section contents"}, - {FLAG_DISASSEMBLE, 'd', "disassemble", NULL, NOPE, "disassemble function bodies"}, + {FLAG_DISASSEMBLE, 'd', "disassemble", NULL, NOPE, + "disassemble function bodies"}, {FLAG_DEBUG, '\0', "debug", NULL, NOPE, "disassemble function bodies"}, {FLAG_VERBOSE, 'v', "verbose", NULL, NOPE, "Verbose output"}, {FLAG_HELP, 'h', "help", NULL, NOPE, "print this help message"}, @@ -148,7 +149,7 @@ int main(int argc, char** argv) { s_objdump_options.print_header = 0; } // Pass 2: Print extra information based on section type - if (s_objdump_options.verbose || s_objdump_options.section_name) { + if (s_objdump_options.verbose) { s_objdump_options.mode = WASM_DUMP_DETAILS; result = wasm_read_binary_objdump(allocator, data, size, &s_objdump_options); if (WASM_FAILED(result)) |