[dev.cc] cmd/internal/obj: reconvert from liblink

Using rsc.io/c2go repo revision 60c9302.

- Export a few symbols needed by assemblers.
- Implement Getgoroot etc directly, and add Getgoversion.
- Removes dependency on Go 1.4 go/build.
- Change magic history name <no name> to <pop>

The <pop> change requires adjustment to the liblink serializer.

Change-Id: If5fb52ac9e91d50805263070b3fc5cc05d8b7632
Reviewed-on: https://go-review.googlesource.com/3141
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Russ Cox 2015-01-21 12:27:36 -05:00
parent a8e5e803e6
commit 24dfaba6d1
3 changed files with 25 additions and 19 deletions

View file

@ -7,7 +7,6 @@ package obj
import (
"bufio"
"fmt"
"go/build"
"io"
"os"
"strconv"
@ -76,16 +75,31 @@ func Bflush(b *Biobuf) error {
return b.w.Flush()
}
func envOr(key, value string) string {
if x := os.Getenv(key); x != "" {
return x
}
return value
}
func Getgoroot() string {
return build.Default.GOROOT
return envOr("GOROOT", defaultGOROOT)
}
func Getgoarch() string {
return build.Default.GOARCH
return envOr("GOARCH", defaultGOARCH)
}
func Getgoos() string {
return build.Default.GOOS
return envOr("GOOS", defaultGOOS)
}
func Getgoarm() string {
return envOr("GOARM", defaultGOARM)
}
func Getgoversion() string {
return version
}
func Atoi(s string) int {
@ -93,14 +107,6 @@ func Atoi(s string) int {
return i
}
func Getgoarm() string {
env := os.Getenv("GOARM")
if env != "" {
return env
}
return "5"
}
func (p *Prog) Line() string {
return linklinefmt(p.Ctxt, int(p.Lineno), false, false)
}