re PR go/81393 (Bootstrap failure on s390x-linux while building libgo against recent glibc)

PR go/81393
syscall: don't use GETREGS/SETREGS on s390

They were removed in recent glibc.

This is a backport of https://golang.org/cl/48231 to earlier branches.
Define required type and constants in syscall package directly, don't
try to pull them from the system header files.

From-SVN: r250402
This commit is contained in:
Ian Lance Taylor 2017-07-20 22:03:26 +00:00
parent e1a9ef3f5c
commit c72684a4e7
2 changed files with 44 additions and 6 deletions

View File

@ -12,10 +12,29 @@ func (r *PtraceRegs) PC() uint64 { return uint64(r.Psw.Addr) }
func (r *PtraceRegs) SetPC(pc uint64) { r.Psw.Addr = uint32(pc) }
func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
const syscall_PTRACE_PEEKUSR_AREA = 0x5000
const syscall_PTRACE_POKEUSR_AREA = 0x5001
type syscall_ptrace_area struct {
len uint32
kernel_addr uint32
process_addr uint32
}
func PtraceGetRegs(pid int, regs *PtraceRegs) (err error) {
parea := syscall_ptrace_area{
12,
0,
uint32(uintptr(unsafe.Pointer(regs))),
}
return ptrace(syscall_PTRACE_PEEKUSR_AREA, pid, uintptr(unsafe.Pointer(&parea)), 0)
}
func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
parea := syscall_ptrace_area{
12,
0,
uint32(uintptr(unsafe.Pointer(regs))),
}
return ptrace(syscall_PTRACE_POKEUSR_AREA, pid, uintptr(unsafe.Pointer(&parea)), 0)
}

View File

@ -12,10 +12,29 @@ func (r *PtraceRegs) PC() uint64 { return r.Psw.Addr }
func (r *PtraceRegs) SetPC(pc uint64) { r.Psw.Addr = pc }
func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) {
return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))
const syscall_PTRACE_PEEKUSR_AREA = 0x5000
const syscall_PTRACE_POKEUSR_AREA = 0x5001
type syscall_ptrace_area struct {
len uint32
kernel_addr uint64
process_addr uint64
}
func PtraceGetRegs(pid int, regs *PtraceRegs) (err error) {
parea := syscall_ptrace_area{
24,
0,
uint64(uintptr(unsafe.Pointer(regs))),
}
return ptrace(syscall_PTRACE_PEEKUSR_AREA, pid, uintptr(unsafe.Pointer(&parea)), 0)
}
func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) {
return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))
parea := syscall_ptrace_area{
24,
0,
uint64(uintptr(unsafe.Pointer(regs))),
}
return ptrace(syscall_PTRACE_POKEUSR_AREA, pid, uintptr(unsafe.Pointer(&parea)), 0)
}