From c842deea757a3de7565b6b06f5e6c0b5cc883827 Mon Sep 17 00:00:00 2001 From: Jacob G-W Date: Fri, 9 Jun 2023 20:32:33 -0400 Subject: [PATCH] os/plan9: fix order of register setting in syscall1 We need to set rbp last because the arguments are stored on the stack. If we clobber rbp first, then we will get a segfault when trying to access the function arguments. I believe I had already done this with the other syscall* functions, but not with syscall1, so this allows single argument syscalls like close to work. --- lib/std/os/plan9/x86_64.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/os/plan9/x86_64.zig b/lib/std/os/plan9/x86_64.zig index 83d0d35307..0f9263296f 100644 --- a/lib/std/os/plan9/x86_64.zig +++ b/lib/std/os/plan9/x86_64.zig @@ -9,8 +9,8 @@ pub fn syscall1(sys: plan9.SYS, arg0: usize) usize { \\pop %%r11 \\pop %%r11 : [ret] "={rax}" (-> usize), - : [syscall_number] "{rbp}" (@enumToInt(sys)), - [arg0] "{r8}" (arg0), + : [arg0] "{r8}" (arg0), + [syscall_number] "{rbp}" (@enumToInt(sys)), : "rcx", "rax", "rbp", "r11", "memory" ); }