Commit 24dfaba6 authored by Russ Cox's avatar Russ Cox

[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/3141Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Reviewed-by: 's avatarRob Pike <r@golang.org>
parent a8e5e803
...@@ -37,7 +37,7 @@ func linklinefmt(ctxt *Link, lno0 int, showAll, showFullPath bool) string { ...@@ -37,7 +37,7 @@ func linklinefmt(ctxt *Link, lno0 int, showAll, showFullPath bool) string {
if lno < h.Line { if lno < h.Line {
break break
} }
if h.Name != "<no name>" { if h.Name != "<pop>" {
if h.Offset > 0 { if h.Offset > 0 {
// #line directive // #line directive
if n > 0 && n < int(HISTSZ) { if n > 0 && n < int(HISTSZ) {
...@@ -148,7 +148,7 @@ func linkgetline(ctxt *Link, line int32, f **LSym, l *int32) { ...@@ -148,7 +148,7 @@ func linkgetline(ctxt *Link, line int32, f **LSym, l *int32) {
if lno < h.Line { if lno < h.Line {
break break
} }
if h.Name != "<no name>" { if h.Name != "<pop>" {
if h.Offset > 0 { if h.Offset > 0 {
// #line directive // #line directive
if n > 0 && n < HISTSZ { if n > 0 && n < HISTSZ {
...@@ -214,7 +214,7 @@ func linkgetline(ctxt *Link, line int32, f **LSym, l *int32) { ...@@ -214,7 +214,7 @@ func linkgetline(ctxt *Link, line int32, f **LSym, l *int32) {
*l = lno *l = lno
} }
func linklinehist(ctxt *Link, lineno int, f string, offset int) { func Linklinehist(ctxt *Link, lineno int, f string, offset int) {
var h *Hist var h *Hist
if false { // debug['f'] if false { // debug['f']
...@@ -247,7 +247,7 @@ func linklinehist(ctxt *Link, lineno int, f string, offset int) { ...@@ -247,7 +247,7 @@ func linklinehist(ctxt *Link, lineno int, f string, offset int) {
ctxt.Ehist = h ctxt.Ehist = h
} }
func linkprfile(ctxt *Link, line int) { func Linkprfile(ctxt *Link, line int) {
l := int32(line) l := int32(line)
var i int var i int
var n int var n int
...@@ -259,7 +259,7 @@ func linkprfile(ctxt *Link, line int) { ...@@ -259,7 +259,7 @@ func linkprfile(ctxt *Link, line int) {
if l < h.Line { if l < h.Line {
break break
} }
if h.Name != "<no name>" { if h.Name != "<pop>" {
if h.Offset == 0 { if h.Offset == 0 {
if n >= 0 && n < HISTSZ { if n >= 0 && n < HISTSZ {
a[n] = *h a[n] = *h
...@@ -296,7 +296,7 @@ func linkprfile(ctxt *Link, line int) { ...@@ -296,7 +296,7 @@ func linkprfile(ctxt *Link, line int) {
/* /*
* start a new Prog list. * start a new Prog list.
*/ */
func linknewplist(ctxt *Link) *Plist { func Linknewplist(ctxt *Link) *Plist {
var pl *Plist var pl *Plist
......
...@@ -7,7 +7,6 @@ package obj ...@@ -7,7 +7,6 @@ package obj
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"go/build"
"io" "io"
"os" "os"
"strconv" "strconv"
...@@ -76,16 +75,31 @@ func Bflush(b *Biobuf) error { ...@@ -76,16 +75,31 @@ func Bflush(b *Biobuf) error {
return b.w.Flush() return b.w.Flush()
} }
func envOr(key, value string) string {
if x := os.Getenv(key); x != "" {
return x
}
return value
}
func Getgoroot() string { func Getgoroot() string {
return build.Default.GOROOT return envOr("GOROOT", defaultGOROOT)
} }
func Getgoarch() string { func Getgoarch() string {
return build.Default.GOARCH return envOr("GOARCH", defaultGOARCH)
} }
func Getgoos() string { 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 { func Atoi(s string) int {
...@@ -93,14 +107,6 @@ func Atoi(s string) int { ...@@ -93,14 +107,6 @@ func Atoi(s string) int {
return i return i
} }
func Getgoarm() string {
env := os.Getenv("GOARM")
if env != "" {
return env
}
return "5"
}
func (p *Prog) Line() string { func (p *Prog) Line() string {
return linklinefmt(p.Ctxt, int(p.Lineno), false, false) return linklinefmt(p.Ctxt, int(p.Lineno), false, false)
} }
......
...@@ -328,7 +328,7 @@ printhist(Link *ctxt, Biobuf *bw, Hist *h) ...@@ -328,7 +328,7 @@ printhist(Link *ctxt, Biobuf *bw, Hist *h)
printptr(ctxt, bw, h); printptr(ctxt, bw, h);
printptr(ctxt, bw, h->link); printptr(ctxt, bw, h->link);
if(h->name == nil) if(h->name == nil)
printstr(ctxt, bw, "<no name>"); printstr(ctxt, bw, "<pop>");
else else
printstr(ctxt, bw, h->name); printstr(ctxt, bw, h->name);
printint(ctxt, bw, h->line); printint(ctxt, bw, h->line);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment