diff options
author | Sam Clegg <sbc@chromium.org> | 2020-05-18 12:15:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 09:15:41 -0700 |
commit | b3275eb89f086b3a2b0effbafa3b38b4f6ce4ef6 (patch) | |
tree | fc016cc4cafd1961381139bf7af20c72859d5fec /test/lld/basic_safe_stack.s | |
parent | c451ca33ce6609d8fac0529a84c8396c80fdbfa1 (diff) | |
download | binaryen-b3275eb89f086b3a2b0effbafa3b38b4f6ce4ef6.tar.gz binaryen-b3275eb89f086b3a2b0effbafa3b38b4f6ce4ef6.tar.bz2 binaryen-b3275eb89f086b3a2b0effbafa3b38b4f6ce4ef6.zip |
Add additional test for --check-stack-overflow (#2857)
This test verifies that functions in the llvm input source that
do stack pointer manipulation get correctly handled by
`wasm-emscripten-finalize --check-stack-overflow` (StackLimitEnforcer)
Diffstat (limited to 'test/lld/basic_safe_stack.s')
-rw-r--r-- | test/lld/basic_safe_stack.s | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/lld/basic_safe_stack.s b/test/lld/basic_safe_stack.s new file mode 100644 index 000000000..74614e798 --- /dev/null +++ b/test/lld/basic_safe_stack.s @@ -0,0 +1,38 @@ +# Test that wasm-binaryen-finalize --check-stack-overflow correctly +# inserts stack chekc handlers. + +.globl stackRestore +.globl stackAlloc + +.globaltype __stack_pointer, i32 + +stackRestore: + .functype stackRestore(i32) -> () + local.get 0 + global.set __stack_pointer + end_function + +stackAlloc: + .functype stackAlloc(i32) -> (i32) + .local i32, i32 + global.get __stack_pointer + # Get arg 0 -> number of bytes to allocate + local.get 0 + # Stack grows down. Subtract arg0 from __stack_pointer + i32.sub + # Align result by anding with ~15 + i32.const 0xfffffff0 + i32.and + local.tee 1 + global.set __stack_pointer + local.get 1 + end_function + +.globl main +main: + .functype main () -> () + end_function + +.export_name stackAlloc, stackAlloc +.export_name stackSave, stackSave +.export_name stackRestore, stackRestore |