From 7acb0d044695ca0fbedf94dca7abfdfd991bc69a Mon Sep 17 00:00:00 2001 From: qmuntal Date: Wed, 10 Sep 2025 16:34:22 +0200 Subject: runtime: fix syscall9 on darwin/arm64 The aarch64 ABI says that only the first 8 arguments should be passed as registers, subsequent arguments should be put on the stack. Syscall9 is not putting the 9th argument on the stack, and it should. The standard library hasn't hit this issue because it uses Syscall9 for functions that only require 7 or 8 parameters. Change-Id: I1fafca5b16f977ea856e3f08b4ff3d0a2a7a4dfe Reviewed-on: https://go-review.googlesource.com/c/go/+/702297 Reviewed-by: Michael Pratt Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI --- src/runtime/sys_darwin_arm64.s | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/runtime/sys_darwin_arm64.s') diff --git a/src/runtime/sys_darwin_arm64.s b/src/runtime/sys_darwin_arm64.s index 788fdf87b7..a3901bdb3b 100644 --- a/src/runtime/sys_darwin_arm64.s +++ b/src/runtime/sys_darwin_arm64.s @@ -724,13 +724,9 @@ TEXT runtime·syscall9(SB),NOSPLIT,$0 MOVD 56(R0), R6 // a7 MOVD 64(R0), R7 // a8 MOVD 72(R0), R8 // a9 + MOVD R8, 0(RSP) // the 9th arg and onwards must be passed on the stack MOVD 8(R0), R0 // a1 - // If fn is declared as vararg, we have to pass the vararg arguments on the stack. - // See syscall above. The only function this applies to is openat, for which the 4th - // arg must be on the stack. - MOVD R3, (RSP) - BL (R12) MOVD 8(RSP), R2 // pop structure pointer -- cgit v1.3-5-g9baa