From 08c61614bede4ce0127d402ac1ed3045b4821685 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Mon, 16 Mar 2020 21:03:50 +0000 Subject: [PATCH] unix: only declare PtraceGetFsBase() on x86-based platforms Only x86-based CPUs have an FSBASE. The current code happens to build on FreeBSD/aarch64 and FreeBSD/arm, but that's only because we incorrectly declare PTRACE_GETFSBASE on those platforms. Change-Id: I128c91bcdb0704a210af13806c1cd285470b5eda GitHub-Last-Rev: 5e88573c0fde1b565d793948ee7ab54607c463b1 GitHub-Pull-Request: golang/sys#62 Reviewed-on: https://go-review.googlesource.com/c/sys/+/223697 Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot Reviewed-by: Tobias Klauser --- unix/syscall_freebsd.go | 4 ---- unix/syscall_freebsd_386.go | 4 ++++ unix/syscall_freebsd_amd64.go | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/unix/syscall_freebsd.go b/unix/syscall_freebsd.go index 6b2eca493..6932e7c2c 100644 --- a/unix/syscall_freebsd.go +++ b/unix/syscall_freebsd.go @@ -521,10 +521,6 @@ func PtraceGetFpRegs(pid int, fpregsout *FpReg) (err error) { return ptrace(PTRACE_GETFPREGS, pid, uintptr(unsafe.Pointer(fpregsout)), 0) } -func PtraceGetFsBase(pid int, fsbase *int64) (err error) { - return ptrace(PTRACE_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) -} - func PtraceGetRegs(pid int, regsout *Reg) (err error) { return ptrace(PTRACE_GETREGS, pid, uintptr(unsafe.Pointer(regsout)), 0) } diff --git a/unix/syscall_freebsd_386.go b/unix/syscall_freebsd_386.go index 0a5a66fab..72a506ddc 100644 --- a/unix/syscall_freebsd_386.go +++ b/unix/syscall_freebsd_386.go @@ -55,6 +55,10 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) +func PtraceGetFsBase(pid int, fsbase *int64) (err error) { + return ptrace(PTRACE_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) +} + func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)} err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) diff --git a/unix/syscall_freebsd_amd64.go b/unix/syscall_freebsd_amd64.go index 8025b22d0..d5e376aca 100644 --- a/unix/syscall_freebsd_amd64.go +++ b/unix/syscall_freebsd_amd64.go @@ -55,6 +55,10 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) +func PtraceGetFsBase(pid int, fsbase *int64) (err error) { + return ptrace(PTRACE_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) +} + func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)} err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0)