Add comment explaining --stack-first option

This commit is contained in:
zigazeljko 2020-06-03 01:58:30 +08:00 committed by Andrew Kelley
parent fb9d5529da
commit bf273b7aec

View File

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