https://llvm.org/bugs/show_bug.cgi?id=30862
Bug ID: 30862 Summary: WebAssembly alias stack pointer not initialized Product: libraries Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: Backend: WebAssembly Assignee: unassignedb...@nondot.org Reporter: timo.sav...@iki.fi CC: llvm-bugs@lists.llvm.org Classification: Unclassified Created attachment 17529 --> https://llvm.org/bugs/attachment.cgi?id=17529&action=edit Small demo program LLVM seems to use the 32-bit value at WebAssembly linear memory offset 4 as __stack_pointer, which is used to access the secondary stack within the linear memory. However, while it's correctly maintained by function prologue and epilogue, it's not initialized at the start of the program. If the size of the WebAssembly memory would be constant, and indexing the linear memory would wrap according to the memory size, things would work by default. But neither of those is the case. Perhaps the memory location is supposed to be initialized by some WebAssembly C runtime library that needs to be linked to the program? Or is the WebAssembly runtime environment expected to set that up somehow (seems wrong)? I've managed to run LLVM-compiled WebAssembly programs (in a custom runtime) by initializing the stack pointer with the size of the initial memory limit (and thus assuming that the stack is located at the end of the initial linear memory). The attached test.c can be compiled to a valid WebAssembly program using LLVM/clang compiled with the experimental WebAssembly target and the tools from https://github.com/WebAssembly/binaryen and https://github.com/WebAssembly/wabt: $ clang --target=wasm32 -Os -S -o test.s test.c $ s2wasm --start=main test.s > test.wast $ wast2wasm -o test.wasm test.wast I located the stack management code in lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp, but could't find a place which attempts to initialize the __stack_pointer. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs