summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-05-08 17:56:23 -0700
committerGitHub <noreply@github.com>2017-05-08 17:56:23 -0700
commit47407e7f11a7cc4568b2901bf2dd36b8ebf91cec (patch)
tree6e652232264b5da42992faddf3508d3199ce3de9
parentea9cd441420da1d129271a669872bc444c35ad2f (diff)
downloadwabt-47407e7f11a7cc4568b2901bf2dd36b8ebf91cec.tar.gz
wabt-47407e7f11a7cc4568b2901bf2dd36b8ebf91cec.tar.bz2
wabt-47407e7f11a7cc4568b2901bf2dd36b8ebf91cec.zip
Add wasmdump support for start section (#420)
-rw-r--r--src/binary-reader-objdump.cc11
-rw-r--r--test/dump/start.txt82
2 files changed, 93 insertions, 0 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index 3c83e693..ebbec6da 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -447,6 +447,8 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase {
uint32_t item_index,
StringSlice name);
+ virtual Result OnStartFunction(uint32_t func_index);
+
virtual Result OnFunctionBodyCount(uint32_t count);
virtual Result OnElemSegmentCount(uint32_t count);
@@ -616,6 +618,15 @@ Result BinaryReaderObjdump::OnFunctionBodyCount(uint32_t count) {
return OnCount(count);
}
+Result BinaryReaderObjdump::OnStartFunction(uint32_t func_index) {
+ if (options->mode == ObjdumpMode::Headers) {
+ printf("start: %d\n", func_index);
+ } else {
+ PrintDetails(" - start function: %d\n", func_index);
+ }
+ return Result::Ok;
+}
+
Result BinaryReaderObjdump::OnImportCount(uint32_t count) {
return OnCount(count);
}
diff --git a/test/dump/start.txt b/test/dump/start.txt
new file mode 100644
index 00000000..af2a9658
--- /dev/null
+++ b/test/dump/start.txt
@@ -0,0 +1,82 @@
+;;; TOOL: run-wasmdump
+;;; FLAGS: -v --dump-verbose --headers
+(module
+ (func $a)
+ (func $b)
+ (func $start)
+ (start $start))
+(;; STDOUT ;;;
+0000000: 0061 736d ; WASM_BINARY_MAGIC
+0000004: 0100 0000 ; WASM_BINARY_VERSION
+; section "Type" (1)
+0000008: 01 ; section code
+0000009: 00 ; section size (guess)
+000000a: 01 ; num types
+; type 0
+000000b: 60 ; func
+000000c: 00 ; num params
+000000d: 00 ; num results
+0000009: 04 ; FIXUP section size
+; section "Function" (3)
+000000e: 03 ; section code
+000000f: 00 ; section size (guess)
+0000010: 03 ; num functions
+0000011: 00 ; function 0 signature index
+0000012: 00 ; function 1 signature index
+0000013: 00 ; function 2 signature index
+000000f: 04 ; FIXUP section size
+; section "Start" (8)
+0000014: 08 ; section code
+0000015: 00 ; section size (guess)
+0000016: 02 ; start func index
+0000015: 01 ; FIXUP section size
+; section "Code" (10)
+0000017: 0a ; section code
+0000018: 00 ; section size (guess)
+0000019: 03 ; num functions
+; function body 0
+000001a: 00 ; func body size (guess)
+000001b: 00 ; local decl count
+000001c: 0b ; end
+000001a: 02 ; FIXUP func body size
+; function body 1
+000001d: 00 ; func body size (guess)
+000001e: 00 ; local decl count
+000001f: 0b ; end
+000001d: 02 ; FIXUP func body size
+; function body 2
+0000020: 00 ; func body size (guess)
+0000021: 00 ; local decl count
+0000022: 0b ; end
+0000020: 02 ; FIXUP func body size
+0000018: 0a ; FIXUP section size
+
+start.wasm: file format wasm 0x1
+
+Sections:
+
+ Type start=0x0000000a end=0x0000000e (size=0x00000004) count: 1
+ Function start=0x00000010 end=0x00000014 (size=0x00000004) count: 3
+ Start start=0x00000016 end=0x00000017 (size=0x00000001) start: 2
+ Code start=0x00000019 end=0x00000023 (size=0x0000000a) count: 3
+
+Section Details:
+
+Type:
+ - [0] () -> nil
+Function:
+ - func[0] sig=0
+ - func[1] sig=0
+ - func[2] sig=0
+Start:
+ - start function: 2
+
+Code Disassembly:
+
+00001a func[0]:
+ 00001c: 0b | end
+00001d func[1]:
+ 00001f: 0b | end
+000020 func[2]:
+ 000022: 0b | end
+;;; STDOUT ;;)