Skip to content

Commit

Permalink
unix: remove recently introduced debug/elf dependency
Browse files Browse the repository at this point in the history
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 <tobias.klauser@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
bradfitz authored and gopherbot committed Jun 12, 2023
1 parent 5059a07 commit 55b11dc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions unix/syscall_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package unix

import (
"debug/elf"
"encoding/binary"
"strconv"
"syscall"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 55b11dc

Please sign in to comment.