cmd/internal/objabi: extract shared functionality from obj

Now only cmd/asm and cmd/compile depend on cmd/internal/obj. Changing
the assembler backends no longer requires reinstalling cmd/link or
cmd/addr2line.

There's also now one canonical definition of the object file format in
cmd/internal/objabi/doc.go, with a warning to update all three
implementations.

objabi is still something of a grab bag of unrelated code (e.g., flag
and environment variable handling probably belong in a separate "tool"
package), but this is still progress.

Fixes #15165.
Fixes #20026.

Change-Id: Ic4b92fac7d0d35438e0d20c9579aad4085c5534c
Reviewed-on: https://go-review.googlesource.com/40972
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Matthew Dempsky 2017-04-18 12:53:25 -07:00
parent f71f32e5e1
commit 1e3570ac86
118 changed files with 2419 additions and 2407 deletions

View file

@ -18,13 +18,14 @@ import (
"cmd/internal/bio"
"cmd/internal/obj"
"cmd/internal/objabi"
)
func main() {
log.SetFlags(0)
log.SetPrefix("asm: ")
GOARCH := obj.GOARCH
GOARCH := objabi.GOARCH
architecture := arch.Set(GOARCH)
if architecture == nil {
@ -52,7 +53,7 @@ func main() {
defer bio.MustClose(out)
buf := bufio.NewWriter(bio.MustWriter(out))
fmt.Fprintf(buf, "go object %s %s %s\n", obj.GOOS, obj.GOARCH, obj.Version)
fmt.Fprintf(buf, "go object %s %s %s\n", objabi.GOOS, objabi.GOARCH, objabi.Version)
fmt.Fprintf(buf, "!\n")
var ok, diag bool