zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit bbb3403b5dff854b01989882a539b29a9e33d732 (tree)
parent da54e7cd00d81be7eb77a83474a734e4ce39eb98
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed, 16 Dec 2020 15:45:32 -0700

stage1: apply LLVM ssp attributes globally

instead of per-function. Otherwise LLVM asserts with:
"stack protected callee but caller requested no stack protector"

Diffstat:
Msrc/stage1/codegen.cpp | 12+++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp @@ -492,14 +492,12 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) { if (fn->body_node != nullptr) { maybe_export_dll(g, llvm_fn, linkage); - bool want_fn_safety = g->build_mode != BuildModeFastRelease && + bool want_ssp_attrs = g->build_mode != BuildModeFastRelease && g->build_mode != BuildModeSmallRelease && - !fn->def_scope->safety_off; - if (want_fn_safety) { - if (g->link_libc) { - addLLVMFnAttr(llvm_fn, "sspstrong"); - addLLVMFnAttrStr(llvm_fn, "stack-protector-buffer-size", "4"); - } + g->link_libc; + if (want_ssp_attrs) { + addLLVMFnAttr(llvm_fn, "sspstrong"); + addLLVMFnAttrStr(llvm_fn, "stack-protector-buffer-size", "4"); } if (g->have_stack_probing && !fn->def_scope->safety_off) { addLLVMFnAttrStr(llvm_fn, "probe-stack", "__zig_probe_stack");