authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2021-09-14 02:42:27-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-09-15 20:41:58-04:00
logf83a4b444c4c2fca7086fe6dbdaccc7b6d8f35ca
tree748091a43a50a0bf72a2ca870d14f476f006ea90
parent19691c0b174f283ffe5b6c3fe8533ef458736064

fix __chkstk on aarch64


1 files changed, 18 insertions(+), 14 deletions(-)

lib/std/special/compiler_rt/stack_probe.zig+18-14
......@@ -53,19 +53,6 @@ pub fn zig_probe_stack() callconv(.Naked) void {
5353 },
5454 else => {},
5555 }
56 if (comptime native_arch.isAARCH64()) {
57 asm volatile (
58 \\ lsl x16, x15, #4
59 \\ mov x17, sp
60 \\1:
61 \\ sub x17, x17, #PAGE_SIZE
62 \\ subs x16, x16, #PAGE_SIZE
63 \\ ldr xzr, [x17]
64 \\ b.gt 1b
65 \\
66 \\ ret
67 );
68 }
6956
7057 unreachable;
7158}
......@@ -118,6 +105,21 @@ fn win_probe_stack_only() void {
118105 },
119106 else => {},
120107 }
108 if (comptime native_arch.isAARCH64()) {
109 // NOTE: page size hardcoded to 4096 for now
110 asm volatile (
111 \\ lsl x16, x15, #4
112 \\ mov x17, sp
113 \\1:
114 \\
115 \\ sub x17, x17, 4096
116 \\ subs x16, x16, 4096
117 \\ ldr xzr, [x17]
118 \\ b.gt 1b
119 \\
120 \\ ret
121 );
122 }
121123
122124 unreachable;
123125}
......@@ -199,7 +201,9 @@ pub fn _chkstk() callconv(.Naked) void {
199201}
200202pub fn __chkstk() callconv(.Naked) void {
201203 @setRuntimeSafety(false);
202 switch (native_arch) {
204 if (comptime native_arch.isAARCH64()) {
205 @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{});
206 } else switch (native_arch) {
203207 .i386 => @call(.{ .modifier = .always_inline }, win_probe_stack_adjust_sp, .{}),
204208 .x86_64 => @call(.{ .modifier = .always_inline }, win_probe_stack_only, .{}),
205209 else => unreachable,