cmd/asm: add mode to collect symbol ABIs

This adds a -symabis flag that runs the assembler in a special mode
that outputs symbol definition and reference ABIs rather than
assembling the code. This uses a fast and somewhat lax parser because
the go_asm.h definitions may not be available.

For #27539.

Change-Id: I248ba0ebab7cc75dcb2a90e82a82eb445da7e88e
Reviewed-on: https://go-review.googlesource.com/c/147098
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Austin Clements 2018-10-19 16:24:59 -04:00
parent 52b2220559
commit ba2e8a629b
4 changed files with 140 additions and 7 deletions

View file

@ -53,8 +53,10 @@ func main() {
defer bio.MustClose(out)
buf := bufio.NewWriter(bio.MustWriter(out))
fmt.Fprintf(buf, "go object %s %s %s\n", objabi.GOOS, objabi.GOARCH, objabi.Version)
fmt.Fprintf(buf, "!\n")
if !*flags.SymABIs {
fmt.Fprintf(buf, "go object %s %s %s\n", objabi.GOOS, objabi.GOARCH, objabi.Version)
fmt.Fprintf(buf, "!\n")
}
var ok, diag bool
var failedFile string
@ -65,16 +67,22 @@ func main() {
diag = true
log.Printf(format, args...)
}
pList := new(obj.Plist)
pList.Firstpc, ok = parser.Parse()
if *flags.SymABIs {
ok = parser.ParseSymABIs(buf)
} else {
pList := new(obj.Plist)
pList.Firstpc, ok = parser.Parse()
// reports errors to parser.Errorf
if ok {
obj.Flushplist(ctxt, pList, nil, "")
}
}
if !ok {
failedFile = f
break
}
// reports errors to parser.Errorf
obj.Flushplist(ctxt, pList, nil, "")
}
if ok {
if ok && !*flags.SymABIs {
obj.WriteObjFile(ctxt, buf)
}
if !ok || diag {