authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-18 02:21:59+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-18 11:16:31+02:00
log842de66db831e24476c381aeac625e340030c76b
treedd476d763e94c6135f00f56c25202659ed41c2b5
parentf3eacec226661c11357102dbca5d888817aafbd7
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.os.linux: fix some issues in x32 inline asm

ref https://github.com/ziglang/zig/issues/22189

1 files changed, 17 insertions(+), 19 deletions(-)

lib/std/os/linux/x32.zig+17-19
...@@ -1,5 +1,3 @@...@@ -1,5 +1,3 @@
1// TODO: A lot of this file is very likely wrong.
2
3const builtin = @import("builtin");1const builtin = @import("builtin");
4const std = @import("../../std.zig");2const std = @import("../../std.zig");
5const SYS = std.os.linux.SYS;3const SYS = std.os.linux.SYS;
...@@ -84,20 +82,20 @@ pub fn syscall6(...@@ -84,20 +82,20 @@ pub fn syscall6(
8482
85pub fn clone() callconv(.naked) u32 {83pub fn clone() callconv(.naked) u32 {
86 asm volatile (84 asm volatile (
87 \\ movl $56,%%eax // SYS_clone85 \\ movl $0x40000038,%%eax // SYS_clone
88 \\ movq %%rdi,%%r1186 \\ mov %%rdi,%%r11
89 \\ movq %%rdx,%%rdi87 \\ mov %%rdx,%%rdi
90 \\ movq %%r8,%%rdx88 \\ mov %%r8,%%rdx
91 \\ movq %%r9,%%r889 \\ mov %%r9,%%r8
92 \\ movq 8(%%rsp),%%r1090 \\ mov 8(%%rsp),%%r10
93 \\ movq %%r11,%%r991 \\ mov %%r11,%%r9
94 \\ andq $-16,%%rsi92 \\ and $-16,%%rsi
95 \\ subq $8,%%rsi93 \\ sub $8,%%rsi
96 \\ movq %%rcx,(%%rsi)94 \\ mov %%rcx,(%%rsi)
97 \\ syscall95 \\ syscall
98 \\ testq %%rax,%%rax96 \\ test %%eax,%%eax
99 \\ jz 1f97 \\ jz 1f
100 \\ retq98 \\ ret
101 \\99 \\
102 \\1:100 \\1:
103 );101 );
...@@ -105,12 +103,12 @@ pub fn clone() callconv(.naked) u32 {...@@ -105,12 +103,12 @@ pub fn clone() callconv(.naked) u32 {
105 \\ .cfi_undefined %%rip103 \\ .cfi_undefined %%rip
106 );104 );
107 asm volatile (105 asm volatile (
108 \\ xorl %%ebp,%%ebp106 \\ xor %%ebp,%%ebp
109 \\107 \\
110 \\ popq %%rdi108 \\ pop %%rdi
111 \\ callq *%%r9109 \\ call *%%r9
112 \\ movl %%eax,%%edi110 \\ mov %%eax,%%edi
113 \\ movl $60,%%eax // SYS_exit111 \\ movl $0x4000003c,%%eax // SYS_exit
114 \\ syscall112 \\ syscall
115 \\113 \\
116 );114 );