aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2019-05-07 00:49:49 +0200
committerAndrew Kelley <andrew@ziglang.org>2019-05-08 12:36:54 -0400
commitbe7cacfbbec8aed234a0316d11a9ae0e8cda0286 (patch)
tree65e070e9954eb8bfe7dbc95a4069d7f8fafe20ec /src/codegen.cpp
parent24ee7653184e6fbac0d05227723ddff2d716a28a (diff)
downloadzig-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.cpp11
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);