Skip to content

Wasm targets should append lld --stack-first #4496

Closed

Description

@fengb

By default, LLVM adopts this memory model:

|   Globals   |   <-- Stack   |   Heap -->  |++

This means when the stack runs out of space, it will start trampling over global memory before causing a stack overflow.

Appending --stack-first will flip where the stack and the globals are located, so stack overflow will error out immediately instead of corrupting globals.

Rust has made a similar decision: rustwasm/team#81 (comment)

Activity

  1. added
    arch-wasm32-bit and 64-bit WebAssembly
    proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.
    on Feb 18, 2020
  2. added this to the 0.7.0 milestone on Feb 18, 2020
  3. added
    acceptedThis proposal is planned.
    contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.
    on Feb 18, 2020
  4. zigazeljko commented on May 31, 2020

    @zigazeljko
    Contributor

    So the only change is adding lj->args.append("--stack-first"); to construct_linker_job_wasm?

    If so, I can prepare a pull request.

  5. fengb commented on Jun 1, 2020

    @fengb
    ContributorAuthor

    Yep that should be it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThis proposal is planned.arch-wasm32-bit and 64-bit WebAssemblycontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions