aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorNikhil Benesch <nikhil.benesch@gmail.com>2020-10-18 19:28:54 +0000
committerIan Lance Taylor <iant@golang.org>2020-10-21 22:29:04 -0700
commit439407aa2c678a96bd5b430ab9c335e65beb5751 (patch)
tree62868455b7c11523dfe8daaf93e178ecb7425167 /libgo
parentd5d9706f95378d40a8895616e167614b69dfe70a (diff)
downloadgcc-439407aa2c678a96bd5b430ab9c335e65beb5751.zip
gcc-439407aa2c678a96bd5b430ab9c335e65beb5751.tar.gz
gcc-439407aa2c678a96bd5b430ab9c335e65beb5751.tar.bz2
syscall: only compile ptrace varargs shim on Linux
Only compile the __go_ptrace varargs shim on Linux to avoid compilation failures on some other platforms. The C ptrace function is not entirely portable (e.g., NetBSD has `int data` instead of `void* data`), and so far Linux is the only platform that needs the varargs shim. Additionally, make the types in the ptrace and raw_ptrace function declarations match. This makes it more clear that the only difference between the two is that calls via the former are allowed to block while calls via the latter are not. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/263517
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/syscall/exec_bsd.go2
-rw-r--r--libgo/go/syscall/exec_linux.go2
-rw-r--r--libgo/go/syscall/exec_stubs.go2
-rw-r--r--libgo/go/syscall/libcall_aix.go2
-rw-r--r--libgo/go/syscall/libcall_glibc.go3
-rw-r--r--libgo/go/syscall/libcall_hurd.go2
-rw-r--r--libgo/go/syscall/libcall_irix.go2
-rw-r--r--libgo/go/syscall/libcall_linux.go5
-rw-r--r--libgo/go/syscall/libcall_solaris_386.go2
-rw-r--r--libgo/go/syscall/libcall_solaris_amd64.go2
-rw-r--r--libgo/go/syscall/libcall_solaris_sparc.go2
-rw-r--r--libgo/go/syscall/libcall_solaris_sparc64.go2
-rw-r--r--libgo/runtime/go-varargs.c7
13 files changed, 17 insertions, 18 deletions
diff --git a/libgo/go/syscall/exec_bsd.go b/libgo/go/syscall/exec_bsd.go
index 7e06943..ca7fdc0 100644
--- a/libgo/go/syscall/exec_bsd.go
+++ b/libgo/go/syscall/exec_bsd.go
@@ -93,7 +93,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr
// Enable tracing if requested.
if sys.Ptrace {
- err1 = raw_ptrace(_PTRACE_TRACEME, 0, nil, nil)
+ err1 = raw_ptrace(_PTRACE_TRACEME, 0, 0, 0)
if err1 != 0 {
goto childerror
}
diff --git a/libgo/go/syscall/exec_linux.go b/libgo/go/syscall/exec_linux.go
index 2f0a34f..3897581 100644
--- a/libgo/go/syscall/exec_linux.go
+++ b/libgo/go/syscall/exec_linux.go
@@ -538,7 +538,7 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att
// Do this right before exec so that we don't unnecessarily trace the runtime
// setting up after the fork. See issue #21428.
if sys.Ptrace {
- err1 = raw_ptrace(_PTRACE_TRACEME, 0, nil, nil)
+ err1 = raw_ptrace(_PTRACE_TRACEME, 0, 0, 0)
if err1 != 0 {
goto childerror
}
diff --git a/libgo/go/syscall/exec_stubs.go b/libgo/go/syscall/exec_stubs.go
index e95b415..c837cf7 100644
--- a/libgo/go/syscall/exec_stubs.go
+++ b/libgo/go/syscall/exec_stubs.go
@@ -30,6 +30,6 @@ func (w WaitStatus) Signal() int { return 0 }
func (w WaitStatus) StopSignal() int { return 0 }
func (w WaitStatus) TrapCause() int { return 0 }
-func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
+func raw_ptrace(request int, pid int, addr uintptr, data uintptr) Errno {
return ENOSYS
}
diff --git a/libgo/go/syscall/libcall_aix.go b/libgo/go/syscall/libcall_aix.go
index 27b469e..92c7f3c 100644
--- a/libgo/go/syscall/libcall_aix.go
+++ b/libgo/go/syscall/libcall_aix.go
@@ -19,7 +19,7 @@ const SYS_EXECVE = 0
//sys ptrace64(request int, id int64, addr int64, data int, buff uintptr) (err error)
//ptrace64(request _C_int, id int64, addr int64, data _C_int, buff *byte) _C_int
-func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
+func raw_ptrace(request int, pid int, addr uintptr, data uintptr) Errno {
if request == _PTRACE_TRACEME {
// Convert to AIX ptrace call.
err := ptrace64(_PT_TRACE_ME, 0, 0, 0, 0)
diff --git a/libgo/go/syscall/libcall_glibc.go b/libgo/go/syscall/libcall_glibc.go
index 823343d..a32d696 100644
--- a/libgo/go/syscall/libcall_glibc.go
+++ b/libgo/go/syscall/libcall_glibc.go
@@ -31,9 +31,6 @@ func Futimes(fd int, tv []Timeval) (err error) {
return Utimes("/proc/self/fd/"+itoa(fd), tv)
}
-//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
-//__go_ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
-
//sys accept4(fd int, sa *RawSockaddrAny, len *Socklen_t, flags int) (nfd int, err error)
//accept4(fd _C_int, sa *RawSockaddrAny, len *Socklen_t, flags _C_int) _C_int
diff --git a/libgo/go/syscall/libcall_hurd.go b/libgo/go/syscall/libcall_hurd.go
index f0e038c..44ff46d 100644
--- a/libgo/go/syscall/libcall_hurd.go
+++ b/libgo/go/syscall/libcall_hurd.go
@@ -7,7 +7,7 @@
package syscall
// Dummy function
-func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
+func raw_ptrace(request int, pid int, addr uintptr, data uintptr) Errno {
return ENOSYS
}
diff --git a/libgo/go/syscall/libcall_irix.go b/libgo/go/syscall/libcall_irix.go
index 9b6cdcc..9880766 100644
--- a/libgo/go/syscall/libcall_irix.go
+++ b/libgo/go/syscall/libcall_irix.go
@@ -6,5 +6,5 @@
package syscall
-//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno)
+//sysnb raw_ptrace(request int, pid int, addr uintptr, data uintptr) (err Errno)
//ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go
index 78fda0e..96974bd 100644
--- a/libgo/go/syscall/libcall_linux.go
+++ b/libgo/go/syscall/libcall_linux.go
@@ -10,7 +10,10 @@ import (
"unsafe"
)
-//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno)
+//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err Errno)
+//__go_ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
+
+//sysnb raw_ptrace(request int, pid int, addr uintptr, data uintptr) (err Errno)
//__go_ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
func ptracePeek(req int, pid int, addr uintptr, out []byte) (count int, err error) {
diff --git a/libgo/go/syscall/libcall_solaris_386.go b/libgo/go/syscall/libcall_solaris_386.go
index 20eba22..ef86f09 100644
--- a/libgo/go/syscall/libcall_solaris_386.go
+++ b/libgo/go/syscall/libcall_solaris_386.go
@@ -8,5 +8,5 @@ package syscall
//sysnb Uname(buf *Utsname) (err error)
//_nuname(buf *Utsname) _C_int
-//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno)
+//sysnb raw_ptrace(request int, pid int, addr uintptr, data uintptr) (err Errno)
//ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
diff --git a/libgo/go/syscall/libcall_solaris_amd64.go b/libgo/go/syscall/libcall_solaris_amd64.go
index 69b11ba..f44025e 100644
--- a/libgo/go/syscall/libcall_solaris_amd64.go
+++ b/libgo/go/syscall/libcall_solaris_amd64.go
@@ -5,6 +5,6 @@
package syscall
// 64-bit ptrace(3C) doesn't exist
-func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
+func raw_ptrace(request int, pid int, addr uintptr, data uintptr) Errno {
return ENOSYS
}
diff --git a/libgo/go/syscall/libcall_solaris_sparc.go b/libgo/go/syscall/libcall_solaris_sparc.go
index 50863fa..3d50309 100644
--- a/libgo/go/syscall/libcall_solaris_sparc.go
+++ b/libgo/go/syscall/libcall_solaris_sparc.go
@@ -4,5 +4,5 @@
package syscall
-//sysnb raw_ptrace(request int, pid int, addr *byte, data *byte) (err Errno)
+//sysnb raw_ptrace(request int, pid int, addr uintptr, data uintptr) (err Errno)
//ptrace(request _C_int, pid Pid_t, addr *byte, data *byte) _C_long
diff --git a/libgo/go/syscall/libcall_solaris_sparc64.go b/libgo/go/syscall/libcall_solaris_sparc64.go
index 69b11ba..f44025e 100644
--- a/libgo/go/syscall/libcall_solaris_sparc64.go
+++ b/libgo/go/syscall/libcall_solaris_sparc64.go
@@ -5,6 +5,6 @@
package syscall
// 64-bit ptrace(3C) doesn't exist
-func raw_ptrace(request int, pid int, addr *byte, data *byte) Errno {
+func raw_ptrace(request int, pid int, addr uintptr, data uintptr) Errno {
return ENOSYS
}
diff --git a/libgo/runtime/go-varargs.c b/libgo/runtime/go-varargs.c
index d8f7dc5..f848608 100644
--- a/libgo/runtime/go-varargs.c
+++ b/libgo/runtime/go-varargs.c
@@ -114,12 +114,11 @@ __go_syscall6(uintptr_t flag, uintptr_t a1, uintptr_t a2, uintptr_t a3,
#endif
-// AIX ptrace is really different from Linux ptrace. Let syscall
-// package handles it.
-#if defined(HAVE_SYS_PTRACE_H) && !defined(_AIX)
+
+#if defined(HAVE_SYS_PTRACE_H) && defined(__linux__)
// Despite documented appearances, this is actually implemented as
-// a variadic function within glibc.
+// a variadic function within glibc on Linux.
long
__go_ptrace(int request, pid_t pid, void *addr, void *data)