[llvm-bugs] [Bug 44297] New: --stack-first should be the default WASM memory layout

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Dec 13 11:56:26 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=44297

            Bug ID: 44297
           Summary: --stack-first should be the default WASM memory layout
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: wasm
          Assignee: unassignedbugs at nondot.org
          Reporter: bholley at mozilla.com
                CC: llvm-bugs at lists.llvm.org, sbc at chromium.org

At present, lldb defaults to locating global variables first in linear memory,
followed by the stack. This improves code-size by reducing the size of
instructions which load globals via constant offset, since smaller constants
can be represented with fewer bits. However, it also means that stack overflows
will clobber those globals before wrapping past address zero and faulting.

lld offers the --stack-first option, which rustc adopted [1] after struggling
with inexplicable memory corruption caused by stack overflows. I think this
should probably be the default, so that clang inherits the same behavior. Given
that stack overflows in native code generally fault rather than triggering
memory corruption, C/C++ developers tend not to work very hard to ensure they
never happen.

[1]
https://github.com/rust-lang/rust/blob/d825e35ee8325146e6c175a4c61bcb645b347d5e/src/librustc_target/spec/wasm32_base.rs#L25

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191213/c766fcc0/attachment.html>


More information about the llvm-bugs mailing list