summaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj/util.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-02-05 03:57:44 -0500
committerRuss Cox <rsc@golang.org>2015-02-05 19:13:12 +0000
commit1fc330d8fe0ce6cbc6fd1f47c1cf035119566fc7 (patch)
tree5436d1070b778506897f77f44706f1f30f1d0980 /src/cmd/internal/obj/util.go
parent8db173b85e1a151b61b38a15c9a4c97beac74191 (diff)
downloadgo-git-1fc330d8fe0ce6cbc6fd1f47c1cf035119566fc7.tar.gz
[dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256. - Brings in new, more regular Prog, Addr definitions - Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion. - Update objwriter for change in TEXT size encoding. - Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand). - Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm. They need to be updated for the changes. - Reenable verifyAsm in cmd/go. - Reenable GOOBJ=2 mode by default in liblink. All architectures build successfully again. Change-Id: I2c845c5d365aa484b570476898171bee657b626d Reviewed-on: https://go-review.googlesource.com/3963 Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/cmd/internal/obj/util.go')
-rw-r--r--src/cmd/internal/obj/util.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/cmd/internal/obj/util.go b/src/cmd/internal/obj/util.go
index 14f2271cb2..de7197e0ba 100644
--- a/src/cmd/internal/obj/util.go
+++ b/src/cmd/internal/obj/util.go
@@ -25,10 +25,19 @@ func Cputime() float64 {
type Biobuf struct {
unget int
haveUnget bool
+ f *os.File
r *bufio.Reader
w *bufio.Writer
}
+func Bopenw(name string) (*Biobuf, error) {
+ f, err := os.Open(name)
+ if err != nil {
+ return nil, err
+ }
+ return &Biobuf{f: f, w: bufio.NewWriter(f)}, nil
+}
+
func Binitw(w io.Writer) *Biobuf {
return &Biobuf{w: bufio.NewWriter(w)}
}
@@ -75,6 +84,15 @@ func Bflush(b *Biobuf) error {
return b.w.Flush()
}
+func Bterm(b *Biobuf) error {
+ err := b.w.Flush()
+ err1 := b.f.Close()
+ if err == nil {
+ err = err1
+ }
+ return err
+}
+
func envOr(key, value string) string {
if x := os.Getenv(key); x != "" {
return x
@@ -108,7 +126,7 @@ func Atoi(s string) int {
}
func (p *Prog) Line() string {
- return linklinefmt(p.Ctxt, int(p.Lineno), false, false)
+ return Linklinefmt(p.Ctxt, int(p.Lineno), false, false)
}
func (p *Prog) String() string {
@@ -119,7 +137,11 @@ func (p *Prog) String() string {
}
func (ctxt *Link) NewProg() *Prog {
- p := ctxt.Arch.Prg() // should be the only call to this; all others should use ctxt.NewProg
+ p := new(Prog) // should be the only call to this; all others should use ctxt.NewProg
p.Ctxt = ctxt
return p
}
+
+func (ctxt *Link) Line(n int) string {
+ return Linklinefmt(ctxt, n, false, false)
+}