diff options
author | Sam Clegg <sbc@chromium.org> | 2017-01-10 06:21:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-10 06:21:34 -0800 |
commit | 6f4df52f245c2aee9d9d071065d38e200bc2bac5 (patch) | |
tree | bd0a79f1bf1f98882d5f609bf09c3b7576c50b4b /src/binary-reader-objdump.c | |
parent | 38d03ba65882ed929e12986d6ee8202a2751ab62 (diff) | |
download | wabt-6f4df52f245c2aee9d9d071065d38e200bc2bac5.tar.gz wabt-6f4df52f245c2aee9d9d071065d38e200bc2bac5.tar.bz2 wabt-6f4df52f245c2aee9d9d071065d38e200bc2bac5.zip |
wasmdump: allow raw dump of specific section (#270)
Diffstat (limited to 'src/binary-reader-objdump.c')
-rw-r--r-- | src/binary-reader-objdump.c | 18 |
1 files changed, 12 insertions, 6 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; |