diff options
author | Ben Smith <binjimin@gmail.com> | 2018-08-27 11:31:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-27 11:31:02 -0700 |
commit | 3f574198cf65bca02f4eb657ed9652d006b6e690 (patch) | |
tree | f26346acb7f4ca9cb2d4077bcca925e33d043700 /test/strip | |
parent | 95f21b26ca861de6aabf4b2c3f0e824be643a07e (diff) | |
download | wabt-3f574198cf65bca02f4eb657ed9652d006b6e690.tar.gz wabt-3f574198cf65bca02f4eb657ed9652d006b6e690.tar.bz2 wabt-3f574198cf65bca02f4eb657ed9652d006b6e690.zip |
Add wasm-strip tool to strip custom sections (#902)
There's a lot more that this tool could do, but even this is helpful for
now.
Fixes issue #631.
Diffstat (limited to 'test/strip')
-rw-r--r-- | test/strip/basic.txt | 31 | ||||
-rw-r--r-- | test/strip/names.txt | 41 | ||||
-rw-r--r-- | test/strip/no-custom-sections.txt | 22 |
3 files changed, 94 insertions, 0 deletions
diff --git a/test/strip/basic.txt b/test/strip/basic.txt new file mode 100644 index 00000000..30368991 --- /dev/null +++ b/test/strip/basic.txt @@ -0,0 +1,31 @@ +;;; TOOL: run-gen-wasm-strip +magic +version +section("one") { "Lorem ipsum dolor sit amet," } +section(TYPE) { count[1] function params[0] results[1] i32 } +section("two") { "consectetur adipiscing elit," } +section(FUNCTION) { count[1] type[0] } +section("three") { "sed do eiusmod tempor incididunt" } +section(EXPORT) { count[1] str("main") func_kind func[0] } +section("four") { "ut labore et dolore magna aliqua." } +section(CODE) { + count[1] + func { + locals[0] + i32.const + leb_i32(-420) + return + } +} +section("five") { "Ut enim ad minim veniam," } +(;; STDOUT ;;; + +basic.wasm: file format wasm 0x1 + +Sections: + + Type start=0x0000000a end=0x0000000f (size=0x00000005) count: 1 + Function start=0x00000011 end=0x00000013 (size=0x00000002) count: 1 + Export start=0x00000015 end=0x0000001d (size=0x00000008) count: 1 + Code start=0x0000001f end=0x00000027 (size=0x00000008) count: 1 +;;; STDOUT ;;) diff --git a/test/strip/names.txt b/test/strip/names.txt new file mode 100644 index 00000000..dbd375bb --- /dev/null +++ b/test/strip/names.txt @@ -0,0 +1,41 @@ +;;; TOOL: run-gen-wasm-strip +magic +version +section(TYPE) { count[1] function params[0] results[1] i32 } +section(FUNCTION) { count[1] type[0] } +section(CODE) { + count[1] + func { + locals[decl_count[1] i32_count[1] i32] + get_local 0 + } +} +section("name") { + section(NAME_MODULE) { + str("M0") + } + + section(NAME_FUNCTION) { + func_count[1] + index[0] + str("F0") + } + + section(NAME_LOCALS) { + func_count[1] + index[0] + local_count[1] + index[0] + str("L0") + } +} +(;; STDOUT ;;; + +names.wasm: file format wasm 0x1 + +Sections: + + Type start=0x0000000a end=0x0000000f (size=0x00000005) count: 1 + Function start=0x00000011 end=0x00000013 (size=0x00000002) count: 1 + Code start=0x00000015 end=0x0000001d (size=0x00000008) count: 1 +;;; STDOUT ;;) diff --git a/test/strip/no-custom-sections.txt b/test/strip/no-custom-sections.txt new file mode 100644 index 00000000..c2e3703f --- /dev/null +++ b/test/strip/no-custom-sections.txt @@ -0,0 +1,22 @@ +;;; TOOL: run-gen-wasm-strip +magic +version +section(TYPE) { count[1] function params[0] results[1] i32 } +section(FUNCTION) { count[1] type[0] } +section(CODE) { + count[1] + func { + locals[decl_count[1] i32_count[1] i32] + get_local 0 + } +} +(;; STDOUT ;;; + +no-custom-sections.wasm: file format wasm 0x1 + +Sections: + + Type start=0x0000000a end=0x0000000f (size=0x00000005) count: 1 + Function start=0x00000011 end=0x00000013 (size=0x00000002) count: 1 + Code start=0x00000015 end=0x0000001d (size=0x00000008) count: 1 +;;; STDOUT ;;) |