public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Daney <ddaney@caviumnetworks.com>
To: Ian Lance Taylor <iant@google.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [Patch] libgo support for mips{,64}-linux-gnu
Date: Mon, 25 Apr 2011 18:15:00 -0000	[thread overview]
Message-ID: <4DB5B636.4050007@caviumnetworks.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 694 bytes --]

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 <ddaney@caviumnetworks.com)

	* mksysinfo.sh: Add handling for MIPS/Linux.
	* syscalls/syscall_linux_mipsn32.go: New file.
	* syscalls/syscall_linux_mipsn64.go: New file.
	* syscalls/syscall_linux_mipso32.go: New file.
	* go/debug/proc/regs_linux_mipsn32.go: New file.
	* go/debug/proc/regs_linux_mipso32.go: New file.
	* go/debug/proc/regs_linux_mipsn64.go: New file.

[-- Attachment #2: libgo-mips-linux.patch --]
[-- Type: text/plain, Size: 9007 bytes --]

Index: mksysinfo.sh
===================================================================
--- mksysinfo.sh	(revision 172872)
+++ mksysinfo.sh	(working copy)
@@ -261,6 +261,16 @@ if test "$regs" != ""; then
   echo "type PtraceRegs struct {$nregs }" >> ${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
+}

                 reply	other threads:[~2011-04-25 17:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DB5B636.4050007@caviumnetworks.com \
    --to=ddaney@caviumnetworks.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iant@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).