diff options
author | Sam Clegg <sbc@chromium.org> | 2021-02-11 16:53:51 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-12 00:53:51 +0000 |
commit | 8369064c09964ab77eae2af6f0d8cce58e412e11 (patch) | |
tree | 2f12e2dd1e4ca21332d5f9e89a8c29382826204e /test/lit/wasm-emscripten-finalize/em_asm.wat | |
parent | e283300dbb8bf573584a811bdc973b3731b67486 (diff) | |
download | binaryen-8369064c09964ab77eae2af6f0d8cce58e412e11.tar.gz binaryen-8369064c09964ab77eae2af6f0d8cce58e412e11.tar.bz2 binaryen-8369064c09964ab77eae2af6f0d8cce58e412e11.zip |
finalize: strip segments that contain only EM_ASM/EM_JS data (#3557)
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.
See: https://github.com/emscripten-core/emscripten/pull/13443
Diffstat (limited to 'test/lit/wasm-emscripten-finalize/em_asm.wat')
-rw-r--r-- | test/lit/wasm-emscripten-finalize/em_asm.wat | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/lit/wasm-emscripten-finalize/em_asm.wat b/test/lit/wasm-emscripten-finalize/em_asm.wat new file mode 100644 index 000000000..43dbfb9ae --- /dev/null +++ b/test/lit/wasm-emscripten-finalize/em_asm.wat @@ -0,0 +1,29 @@ +;; Test that em_asm string are extracted correctly when the __start_em_asm +;; and __stop_em_asm globals are exported. + +;; RUN: wasm-emscripten-finalize %s -S | filecheck %s + +;; Check that the data segment that contains only EM_ASM strings resized to +;; zero, and that the string are extracted into the metadata. + +;; CHECK: (data (i32.const 100) "normal data") +;; CHECK-NEXT: (data (i32.const 512) "") +;; CHECK-NEXT: (data (i32.const 1024) "more data") + +;; CHECK: "asmConsts": { +;; CHECK-NEXT: "512": "{ console.log('JS hello'); }", +;; CHECK-NEXT: "541": "{ console.log('hello again'); }" +;; CHECK-NEXT: }, + +;; Check that the exports are removed +;; CHECK-NOT: export + +(module + (memory 1 1) + (global (export "__start_em_asm") i32 (i32.const 512)) + (global (export "__stop_em_asm") i32 (i32.const 573)) + + (data (i32.const 100) "normal data") + (data (i32.const 512) "{ console.log('JS hello'); }\00{ console.log('hello again'); }\00") + (data (i32.const 1024) "more data") +) |