From patchwork Mon Apr 25 17:58:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 92766 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id EB2B2B6F3A for ; Tue, 26 Apr 2011 03:58:39 +1000 (EST) Received: (qmail 18547 invoked by alias); 25 Apr 2011 17:58:36 -0000 Received: (qmail 18535 invoked by uid 22791); 25 Apr 2011 17:58:34 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail3.caviumnetworks.com (HELO mail3.caviumnetworks.com) (12.108.191.235) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 25 Apr 2011 17:58:19 +0000 Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,7,2,8378) id ; Mon, 25 Apr 2011 10:59:19 -0700 Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 25 Apr 2011 10:58:19 -0700 Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 25 Apr 2011 10:58:19 -0700 Message-ID: <4DB5B636.4050007@caviumnetworks.com> Date: Mon, 25 Apr 2011 10:58:14 -0700 From: David Daney User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Fedora/3.0.10-1.fc12 Thunderbird/3.0.10 MIME-Version: 1.0 To: Ian Lance Taylor CC: GCC Patches Subject: [Patch] libgo support for mips{,64}-linux-gnu X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Ian, This is the patch I am using to be able to build libgo in GCC. See: http://gcc.gnu.org/ml/gcc-testresults/2011-04/msg02325.html MIPS/Linux support is not perfect, but this is a start. I'm not sure what the mechanics of applying the patch are, but I think you need to do something with it. 2011-04-25 David Daney > ${OUT} fi +# MIPS/Linux is special with respect to PTRACE_GETREGS. +if grep -q -e '^const _mips ' gen-sysinfo.go \ + && grep -q -e '^const _linux ' gen-sysinfo.go ; then + if grep -q -e '__MIPS_SIM = __ABIO32' gen-sysinfo.go ; then + echo "type PtraceRegs [EF_SIZE / 4]uint32" >> ${OUT} + else + echo "type PtraceRegs [EF_SIZE / 8]uint64" >> ${OUT} + fi +fi + # Some basic types. echo 'type Size_t _size_t' >> ${OUT} echo "type Ssize_t _ssize_t" >> ${OUT} Index: syscalls/syscall_linux_mipsn32.go =================================================================== --- syscalls/syscall_linux_mipsn32.go (revision 0) +++ syscalls/syscall_linux_mipsn32.go (revision 0) @@ -0,0 +1,15 @@ +// syscall_linux_mipsn32.go -- GNU/Linux MIPS n32 ABI specific support + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall + +func (r *PtraceRegs) PC() uint64 { + return r[EF_CP0_EPC]; +} + +func (r *PtraceRegs) SetPC(pc uint64) { + r[EF_CP0_EPC] = pc; +} Index: syscalls/syscall_linux_mipsn64.go =================================================================== --- syscalls/syscall_linux_mipsn64.go (revision 0) +++ syscalls/syscall_linux_mipsn64.go (revision 0) @@ -0,0 +1,15 @@ +// syscall_linux_mipsn64.go -- GNU/Linux MIPS n64 ABI specific support + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall + +func (r *PtraceRegs) PC() uint64 { + return r[EF_CP0_EPC]; +} + +func (r *PtraceRegs) SetPC(pc uint64) { + r[EF_CP0_EPC] = pc; +} Index: syscalls/syscall_linux_mipso32.go =================================================================== --- syscalls/syscall_linux_mipso32.go (revision 0) +++ syscalls/syscall_linux_mipso32.go (revision 0) @@ -0,0 +1,15 @@ +// syscall_linux_mipso32.go -- GNU/Linux MIPS o32 ABI specific support + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall + +func (r *PtraceRegs) PC() uint64 { + return uint64(r[EF_CP0_EPC]); +} + +func (r *PtraceRegs) SetPC(pc uint64) { + r[EF_CP0_EPC] = uint32(pc); +} Index: go/debug/proc/regs_linux_mipsn32.go =================================================================== --- go/debug/proc/regs_linux_mipsn32.go (revision 0) +++ go/debug/proc/regs_linux_mipsn32.go (revision 0) @@ -0,0 +1,100 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package proc + +import ( + "os" + "strconv" + "syscall" +) + +type _MipsRegs struct { + regs syscall.PtraceRegs + setter func(*syscall.PtraceRegs) os.Error +} + +var names = []string{ + "zero", + "at", + "v0", + "v1", + "a0", + "a1", + "a2", + "a3", + "a4", + "a5", + "a6", + "a7", + "t0", + "t1", + "t2", + "t3", + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "t8", + "t9", + "k0", + "k1", + "gp", + "sp", + "s8", + "ra", + "lo", + "hi", + "pc", +} + +func (r *_MipsRegs) PC() Word { return Word(r.regs[syscall.EF_CP0_EPC]) } + +func (r *_MipsRegs) SetPC(val Word) os.Error { + r.regs[syscall.EF_CP0_EPC] = uint64(int64(int32(val))) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Link() Word { return Word(r.regs[syscall.EF_REG31]) } + +func (r *_MipsRegs) SetLink(val Word) os.Error { + r.regs[syscall.EF_REG31] = uint64(int64(int32(val))) + return r.setter(&r.regs) +} + + +func (r *_MipsRegs) SP() Word { return Word(r.regs[syscall.EF_REG29]) } + +func (r *_MipsRegs) SetSP(val Word) os.Error { + r.regs[syscall.EF_REG29] = uint64(val) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Names() []string { return names } + +func (r *_MipsRegs) Get(i int) Word { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + return Word(r.regs[i]) +} + +func (r *_MipsRegs) Set(i int, val Word) os.Error { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + r.regs[i] = uint64(val) + return r.setter(&r.regs) +} + +func newRegs(regs *syscall.PtraceRegs, setter func(*syscall.PtraceRegs) os.Error) Regs { + res := _MipsRegs{} + res.regs = *regs + res.setter = setter + return &res +} Index: go/debug/proc/regs_linux_mipso32.go =================================================================== --- go/debug/proc/regs_linux_mipso32.go (revision 0) +++ go/debug/proc/regs_linux_mipso32.go (revision 0) @@ -0,0 +1,100 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package proc + +import ( + "os" + "strconv" + "syscall" +) + +type _MipsRegs struct { + regs syscall.PtraceRegs + setter func(*syscall.PtraceRegs) os.Error +} + +var names = []string{ + "zero", + "at", + "v0", + "v1", + "a0", + "a1", + "a2", + "a3", + "t0", + "t1", + "t2", + "t3", + "t4", + "t5", + "t6", + "t7", + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "t8", + "t9", + "k0", + "k1", + "gp", + "sp", + "s8", + "ra", + "lo", + "hi", + "pc", +} + +func (r *_MipsRegs) PC() Word { return Word(r.regs[syscall.EF_CP0_EPC]) } + +func (r *_MipsRegs) SetPC(val Word) os.Error { + r.regs[syscall.EF_CP0_EPC] = uint32(val) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Link() Word { return Word(r.regs[syscall.EF_REG31]) } + +func (r *_MipsRegs) SetLink(val Word) os.Error { + r.regs[syscall.EF_REG31] = uint32(val) + return r.setter(&r.regs) +} + + +func (r *_MipsRegs) SP() Word { return Word(r.regs[syscall.EF_REG29]) } + +func (r *_MipsRegs) SetSP(val Word) os.Error { + r.regs[syscall.EF_REG29] = uint32(val) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Names() []string { return names } + +func (r *_MipsRegs) Get(i int) Word { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + return Word(r.regs[i]) +} + +func (r *_MipsRegs) Set(i int, val Word) os.Error { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + r.regs[i] = uint32(val) + return r.setter(&r.regs) +} + +func newRegs(regs *syscall.PtraceRegs, setter func(*syscall.PtraceRegs) os.Error) Regs { + res := _MipsRegs{} + res.regs = *regs + res.setter = setter + return &res +} Index: go/debug/proc/regs_linux_mipsn64.go =================================================================== --- go/debug/proc/regs_linux_mipsn64.go (revision 0) +++ go/debug/proc/regs_linux_mipsn64.go (revision 0) @@ -0,0 +1,100 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package proc + +import ( + "os" + "strconv" + "syscall" +) + +type _MipsRegs struct { + regs syscall.PtraceRegs + setter func(*syscall.PtraceRegs) os.Error +} + +var names = []string{ + "zero", + "at", + "v0", + "v1", + "a0", + "a1", + "a2", + "a3", + "a4", + "a5", + "a6", + "a7", + "t0", + "t1", + "t2", + "t3", + "s0", + "s1", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "t8", + "t9", + "k0", + "k1", + "gp", + "sp", + "s8", + "ra", + "lo", + "hi", + "pc", +} + +func (r *_MipsRegs) PC() Word { return Word(r.regs[syscall.EF_CP0_EPC]) } + +func (r *_MipsRegs) SetPC(val Word) os.Error { + r.regs[syscall.EF_CP0_EPC] = uint64(int64(int32(val))) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Link() Word { return Word(r.regs[syscall.EF_REG31]) } + +func (r *_MipsRegs) SetLink(val Word) os.Error { + r.regs[syscall.EF_REG31] = uint64(int64(int32(val))) + return r.setter(&r.regs) +} + + +func (r *_MipsRegs) SP() Word { return Word(r.regs[syscall.EF_REG29]) } + +func (r *_MipsRegs) SetSP(val Word) os.Error { + r.regs[syscall.EF_REG29] = uint64(val) + return r.setter(&r.regs) +} + +func (r *_MipsRegs) Names() []string { return names } + +func (r *_MipsRegs) Get(i int) Word { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + return Word(r.regs[i]) +} + +func (r *_MipsRegs) Set(i int, val Word) os.Error { + if i < 0 || i > syscall.EF_CP0_EPC { + panic("invalid register index " + strconv.Itoa(i)) + } + r.regs[i] = uint64(val) + return r.setter(&r.regs) +} + +func newRegs(regs *syscall.PtraceRegs, setter func(*syscall.PtraceRegs) os.Error) Regs { + res := _MipsRegs{} + res.regs = *regs + res.setter = setter + return &res +}