diff options
| author | LemonBoy <thatlemon@gmail.com> | 2019-05-07 00:49:49 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-05-08 12:36:54 -0400 |
| commit | be7cacfbbec8aed234a0316d11a9ae0e8cda0286 (patch) | |
| tree | 65e070e9954eb8bfe7dbc95a4069d7f8fafe20ec /src/codegen.cpp | |
| parent | 24ee7653184e6fbac0d05227723ddff2d716a28a (diff) | |
| download | zig-be7cacfbbec8aed234a0316d11a9ae0e8cda0286.tar.gz zig-be7cacfbbec8aed234a0316d11a9ae0e8cda0286.zip | |
Implement stack probes for x86/x86_64
Enabled on non-Windows systems only since it already requires stack
probes.
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 7dfdf71725..396dfb1f88 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -399,6 +399,15 @@ static void add_uwtable_attr(CodeGen *g, LLVMValueRef fn_val) { } } +static void add_probe_stack_attr(CodeGen *g, LLVMValueRef fn_val) { + // Windows already emits its own stack probes + if (g->zig_target->os != OsWindows && + (g->zig_target->arch == ZigLLVM_x86 || + g->zig_target->arch == ZigLLVM_x86_64)) { + addLLVMFnAttrStr(fn_val, "probe-stack", "__zig_probe_stack"); + } +} + static LLVMLinkage to_llvm_linkage(GlobalLinkageId id) { switch (id) { case GlobalLinkageIdInternal: @@ -587,6 +596,8 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, ZigFn *fn_table_entry) { addLLVMFnAttr(fn_table_entry->llvm_value, "sspstrong"); addLLVMFnAttrStr(fn_table_entry->llvm_value, "stack-protector-buffer-size", "4"); } + + add_probe_stack_attr(g, fn_table_entry->llvm_value); } } else { maybe_import_dll(g, fn_table_entry->llvm_value, linkage); |
