unix/linux: unify ppc64x syscall wrappers

CL 146518 (commit 7155702f) attempted to fix a linker
limitation by using native go. This resulted in some
very hard to uncover issues noted in golang/go#81981.

Reintroduce the asm, but use an indirect jump to avoid
linker generated trampolines.

Fixes golang/go#81981

Change-Id: If13d401712dc0294d66611546f879eebfdae59af
Reviewed-on: https://go-review.googlesource.com/c/sys/+/845125
Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
diff --git a/unix/asm_linux_ppc64x.s b/unix/asm_linux_ppc64x.s
index bdfc024..2e1f4c3 100644
--- a/unix/asm_linux_ppc64x.s
+++ b/unix/asm_linux_ppc64x.s
@@ -13,6 +13,16 @@
 // Just jump to package syscall's implementation for all these functions.
 // The runtime may know about them.
 
+TEXT ·Syscall(SB),NOSPLIT,$0-56
+	MOVD	$syscall·Syscall(SB), R31
+	MOVD	R31, CTR
+	JMP	(CTR)
+
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
+	MOVD	$syscall·Syscall6(SB), R31
+	MOVD	R31, CTR
+	JMP	(CTR)
+
 TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
 	BL	runtime·entersyscall(SB)
 	MOVD	a1+8(FP), R3
@@ -28,6 +38,16 @@
 	BL	runtime·exitsyscall(SB)
 	RET
 
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
+	MOVD	$syscall·RawSyscall(SB), R31
+	MOVD	R31, CTR
+	JMP	(CTR)
+
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
+	MOVD	$syscall·RawSyscall6(SB), R31
+	MOVD	R31, CTR
+	JMP	(CTR)
+
 TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
 	MOVD	a1+8(FP), R3
 	MOVD	a2+16(FP), R4
diff --git a/unix/syscall_unix_gc.go b/unix/syscall_unix_gc.go
index 05c95bc..60c0d16 100644
--- a/unix/syscall_unix_gc.go
+++ b/unix/syscall_unix_gc.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build (darwin || dragonfly || freebsd || (linux && !ppc64 && !ppc64le) || netbsd || openbsd || solaris) && gc
+//go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris) && gc
 
 package unix
 
diff --git a/unix/syscall_unix_gc_ppc64x.go b/unix/syscall_unix_gc_ppc64x.go
deleted file mode 100644
index 23f39b7..0000000
--- a/unix/syscall_unix_gc_ppc64x.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build linux && (ppc64le || ppc64) && gc
-
-package unix
-
-import "syscall"
-
-func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
-	return syscall.Syscall(trap, a1, a2, a3)
-}
-func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
-	return syscall.Syscall6(trap, a1, a2, a3, a4, a5, a6)
-}
-func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
-	return syscall.RawSyscall(trap, a1, a2, a3)
-}
-func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
-	return syscall.RawSyscall6(trap, a1, a2, a3, a4, a5, a6)
-}