Skip to content

Commit 7155702

Browse files
labogertklauser
authored andcommitted
unix: fix errors in syscalls when using -linkshared on ppc64x
When using -linkshared, the external linker on ppc64x cannot always handle the direct branch to syscall.Syscall and similar similar functions when the offset is too far. Instead it should be done as a BL which can then be called through a procedure linkage table entry. This change removes functions Syscall, Syscall6, RawSyscall, RawSyscall6 from asm_linux_ppc64x.s and instead creates Go functions which call their corresponding functions in the syscall package. As Go functions, they can be inlined with the help of CL 147361. Fixes golang/go#16662 Change-Id: Ibd2b6ec15b0781c3d7db25e249a3ffc9e1c2884b Reviewed-on: https://go-review.googlesource.com/c/146518 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
1 parent 9b800f9 commit 7155702

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

unix/asm_linux_ppc64x.s

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515
// Just jump to package syscall's implementation for all these functions.
1616
// The runtime may know about them.
1717

18-
TEXT ·Syscall(SB),NOSPLIT,$0-56
19-
BR syscall·Syscall(SB)
20-
21-
TEXT ·Syscall6(SB),NOSPLIT,$0-80
22-
BR syscall·Syscall6(SB)
23-
2418
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
2519
BL runtime·entersyscall(SB)
2620
MOVD a1+8(FP), R3
@@ -36,12 +30,6 @@ TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
3630
BL runtime·exitsyscall(SB)
3731
RET
3832

39-
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
40-
BR syscall·RawSyscall(SB)
41-
42-
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
43-
BR syscall·RawSyscall6(SB)
44-
4533
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
4634
MOVD a1+8(FP), R3
4735
MOVD a2+16(FP), R4

unix/syscall_unix_gc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// license that can be found in the LICENSE file.
44

55
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6-
// +build !gccgo
6+
// +build !gccgo,!ppc64le,!ppc64
77

88
package unix
99

unix/syscall_unix_gc_ppc64x.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2018 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build linux
6+
// +build ppc64le ppc64
7+
// +build !gccgo
8+
9+
package unix
10+
11+
import "syscall"
12+
13+
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
14+
return syscall.Syscall(trap, a1, a2, a3)
15+
}
16+
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
17+
return syscall.Syscall6(trap, a1, a2, a3, a4, a5, a6)
18+
}
19+
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
20+
return syscall.RawSyscall(trap, a1, a2, a3)
21+
}
22+
func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
23+
return syscall.RawSyscall6(trap, a1, a2, a3, a4, a5, a6)
24+
}

0 commit comments

Comments
 (0)