authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2023-06-09 20:32:33-04:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-06-10 11:36:32+03:00
logc842deea757a3de7565b6b06f5e6c0b5cc883827
treec644349a804231edd0b065ba90dbf06d2263cf46
parent34d44e0c1c2cdfc5916dd5c56914f181f87e8d85

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.

1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/os/plan9/x86_64.zig+2-2
...@@ -9,8 +9,8 @@ pub fn syscall1(sys: plan9.SYS, arg0: usize) usize {...@@ -9,8 +9,8 @@ pub fn syscall1(sys: plan9.SYS, arg0: usize) usize {
9 \\pop %%r119 \\pop %%r11
10 \\pop %%r1110 \\pop %%r11
11 : [ret] "={rax}" (-> usize),11 : [ret] "={rax}" (-> usize),
12 : [syscall_number] "{rbp}" (@enumToInt(sys)),12 : [arg0] "{r8}" (arg0),
13 [arg0] "{r8}" (arg0),13 [syscall_number] "{rbp}" (@enumToInt(sys)),
14 : "rcx", "rax", "rbp", "r11", "memory"14 : "rcx", "rax", "rbp", "r11", "memory"
15 );15 );
16}16}