| ... | @@ -101,30 +101,32 @@ export nakedcc fn __aeabi_uidivmod() { | ... | @@ -101,30 +101,32 @@ export nakedcc fn __aeabi_uidivmod() { |
| 101 | export nakedcc fn __chkstk() { | 101 | export nakedcc fn __chkstk() { |
| 102 | @setDebugSafety(this, false); | 102 | @setDebugSafety(this, false); |
| 103 | | 103 | |
| 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 %%rcx | 106 | asm volatile ( |
| 107 | \\ cmp $0x1000,%%rax | 107 | \\ push %%rcx |
| 108 | \\ lea 16(%%rsp),%%rcx // rsp before calling this routine -> rcx | 108 | \\ cmp $0x1000,%%rax |
| 109 | \\ jb 1f | 109 | \\ lea 16(%%rsp),%%rcx // rsp before calling this routine -> rcx |
| 110 | \\ 2: | 110 | \\ jb 1f |
| 111 | \\ sub $0x1000,%%rcx | 111 | \\ 2: |
| 112 | \\ test %%rcx,(%%rcx) | 112 | \\ sub $0x1000,%%rcx |
| 113 | \\ sub $0x1000,%%rax | 113 | \\ test %%rcx,(%%rcx) |
| 114 | \\ cmp $0x1000,%%rax | 114 | \\ sub $0x1000,%%rax |
| 115 | \\ ja 2b | 115 | \\ cmp $0x1000,%%rax |
| 116 | \\ 1: | 116 | \\ ja 2b |
| 117 | \\ sub %%rax,%%rcx | 117 | \\ 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 rax | 120 | \\ |
| 121 | \\ mov %%rcx,%%rsp // install the new top of stack pointer into rsp | 121 | \\ lea 8(%%rsp),%%rax // load pointer to the return address into rax |
| 122 | \\ mov -8(%%rax),%%rcx // restore rcx | 122 | \\ mov %%rcx,%%rsp // install the new top of stack pointer into rsp |
| 123 | \\ push (%%rax) // push return address onto the stack | 123 | \\ mov -8(%%rax),%%rcx // restore rcx |
| 124 | \\ sub %%rsp,%%rax // restore the original value in rax | 124 | \\ push (%%rax) // push return address onto the stack |
| 125 | \\ ret | 125 | \\ sub %%rsp,%%rax // restore the original value in rax |
| 126 | ); | 126 | \\ ret |
| 127 | unreachable; | 127 | ); |
| | 128 | unreachable; |
| | 129 | } |
| 128 | } | 130 | } |
| 129 | | 131 | |
| 130 | @setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal); | 132 | @setGlobalLinkage(__chkstk, builtin.GlobalLinkage.Internal); |