authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-31 20:10:24-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-08-31 20:10:24-04:00
log06b64d82bf4baad296ff7c37d7c8ff08ce2bdc69
treea6154a7bbc5cbf6eb8945dc84ebfe689c7a4f41a
parente93ece7514dc9199523f71efe0ac480ef143985e

only export __chkstk for windows

it's a windows only function anyway

1 files changed, 26 insertions(+), 24 deletions(-)

std/special/compiler_rt/index.zig+26-24
...@@ -101,30 +101,32 @@ export nakedcc fn __aeabi_uidivmod() {...@@ -101,30 +101,32 @@ export nakedcc fn __aeabi_uidivmod() {
101export nakedcc fn __chkstk() {101export nakedcc fn __chkstk() {
102 @setDebugSafety(this, false);102 @setDebugSafety(this, false);
103103
104 if (comptime builtin.arch == builtin.Arch.x86_64) {104 if (comptime builtin.os == builtin.Os.windows) {
105 asm volatile (105 if (comptime builtin.arch == builtin.Arch.x86_64) {
106 \\ push %%rcx106 asm volatile (
107 \\ cmp $0x1000,%%rax107 \\ push %%rcx
108 \\ lea 16(%%rsp),%%rcx // rsp before calling this routine -> rcx108 \\ cmp $0x1000,%%rax
109 \\ jb 1f109 \\ lea 16(%%rsp),%%rcx // rsp before calling this routine -> rcx
110 \\ 2:110 \\ jb 1f
111 \\ sub $0x1000,%%rcx111 \\ 2:
112 \\ test %%rcx,(%%rcx)112 \\ sub $0x1000,%%rcx
113 \\ sub $0x1000,%%rax113 \\ test %%rcx,(%%rcx)
114 \\ cmp $0x1000,%%rax114 \\ sub $0x1000,%%rax
115 \\ ja 2b115 \\ cmp $0x1000,%%rax
116 \\ 1:116 \\ ja 2b
117 \\ sub %%rax,%%rcx117 \\ 1:
118 \\ test %%rcx,(%%rcx)118 \\ sub %%rax,%%rcx
119 \\ 119 \\ test %%rcx,(%%rcx)
120 \\ lea 8(%%rsp),%%rax // load pointer to the return address into rax120 \\
121 \\ mov %%rcx,%%rsp // install the new top of stack pointer into rsp121 \\ lea 8(%%rsp),%%rax // load pointer to the return address into rax
122 \\ mov -8(%%rax),%%rcx // restore rcx122 \\ mov %%rcx,%%rsp // install the new top of stack pointer into rsp
123 \\ push (%%rax) // push return address onto the stack123 \\ mov -8(%%rax),%%rcx // restore rcx
124 \\ sub %%rsp,%%rax // restore the original value in rax124 \\ push (%%rax) // push return address onto the stack
125 \\ ret125 \\ sub %%rsp,%%rax // restore the original value in rax
126 );126 \\ ret
127 unreachable;127 );
128 unreachable;
129 }
128 }130 }
129131
130 @setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal);132 @setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal);