From 55b11dcdae8194618ad245a452849aa95e461114 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 11 Jun 2023 08:50:10 -0700 Subject: [PATCH] unix: remove recently introduced debug/elf dependency CL 501795 added a dependency on debug/elf (and thus compress/gzip, debug/dwarf, hash/adler32) Add a copy of the const instead. Change-Id: I2c86094ef7de61b8dd0bdd727f6e547ac7f58527 Reviewed-on: https://go-review.googlesource.com/c/sys/+/502356 Reviewed-by: Tobias Klauser Reviewed-by: David Chase Run-TryBot: Brad Fitzpatrick Reviewed-by: Ian Lance Taylor Auto-Submit: Brad Fitzpatrick TryBot-Result: Gopher Robot --- unix/syscall_linux.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index ec24faea5..6de486bef 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -12,7 +12,6 @@ package unix import ( - "debug/elf" "encoding/binary" "strconv" "syscall" @@ -1700,18 +1699,23 @@ func PtracePokeUser(pid int, addr uintptr, data []byte) (count int, err error) { return ptracePoke(PTRACE_POKEUSR, PTRACE_PEEKUSR, pid, addr, data) } +// elfNT_PRSTATUS is a copy of the debug/elf.NT_PRSTATUS constant so +// x/sys/unix doesn't need to depend on debug/elf and thus +// compress/zlib, debug/dwarf, and other packages. +const elfNT_PRSTATUS = 1 + func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { var iov Iovec iov.Base = (*byte)(unsafe.Pointer(regsout)) iov.SetLen(int(unsafe.Sizeof(*regsout))) - return ptracePtr(PTRACE_GETREGSET, pid, uintptr(elf.NT_PRSTATUS), unsafe.Pointer(&iov)) + return ptracePtr(PTRACE_GETREGSET, pid, uintptr(elfNT_PRSTATUS), unsafe.Pointer(&iov)) } func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { var iov Iovec iov.Base = (*byte)(unsafe.Pointer(regs)) iov.SetLen(int(unsafe.Sizeof(*regs))) - return ptracePtr(PTRACE_SETREGSET, pid, uintptr(elf.NT_PRSTATUS), unsafe.Pointer(&iov)) + return ptracePtr(PTRACE_SETREGSET, pid, uintptr(elfNT_PRSTATUS), unsafe.Pointer(&iov)) } func PtraceSetOptions(pid int, options int) (err error) {