| ... | @@ -2107,6 +2107,10 @@ static void construct_linker_job_wasm(LinkJob *lj) { | ... | @@ -2107,6 +2107,10 @@ static void construct_linker_job_wasm(LinkJob *lj) { |
| 2107 | lj->args.append("-z"); | 2107 | lj->args.append("-z"); |
| 2108 | lj->args.append(buf_ptr(buf_sprintf("stack-size=%" ZIG_PRI_usize, stack_size))); | 2108 | lj->args.append(buf_ptr(buf_sprintf("stack-size=%" ZIG_PRI_usize, stack_size))); |
| 2109 | | 2109 | |
| | 2110 | // put stack before globals so that stack overflow results in segfault immediately before corrupting globals |
| | 2111 | // see https://github.com/ziglang/zig/issues/4496 |
| | 2112 | lj->args.append("--stack-first"); |
| | 2113 | |
| 2110 | if (g->out_type != OutTypeExe) { | 2114 | if (g->out_type != OutTypeExe) { |
| 2111 | lj->args.append("--no-entry"); // So lld doesn't look for _start. | 2115 | lj->args.append("--no-entry"); // So lld doesn't look for _start. |
| 2112 | | 2116 | |