Commit 36edf48a authored by Russ Cox's avatar Russ Cox

cmd/asm: report more than one instruction encoding error

Also, remove output file if there are encoding errors.
The extra reports are convenient.
Removing the output file is very important.
Noticed while testing.

Change-Id: I0fab17d4078f93c5a0d6d1217d8d9a63ac789696
Reviewed-on: https://go-review.googlesource.com/18845Reviewed-by: default avatarRob Pike <r@golang.org>
parent a5ba581a
......@@ -47,21 +47,28 @@ func main() {
}
ctxt.Bso = obj.Binitw(os.Stdout)
defer ctxt.Bso.Flush()
ctxt.Diag = log.Fatalf
output := obj.Binitw(fd)
fmt.Fprintf(output, "go object %s %s %s\n", obj.Getgoos(), obj.Getgoarch(), obj.Getgoversion())
fmt.Fprintf(output, "!\n")
lexer := lex.NewLexer(flag.Arg(0), ctxt)
parser := asm.NewParser(ctxt, architecture, lexer)
diag := false
ctxt.Diag = func(format string, args ...interface{}) {
diag = true
log.Printf(format, args...)
}
pList := obj.Linknewplist(ctxt)
var ok bool
pList.Firstpc, ok = parser.Parse()
if !ok {
if ok {
// reports errors to parser.Errorf
obj.Writeobjdirect(ctxt, output)
}
if !ok || diag {
log.Printf("asm: assembly of %s failed", flag.Arg(0))
os.Remove(*flags.OutputFile)
os.Exit(1)
}
obj.Writeobjdirect(ctxt, output)
output.Flush()
}
......@@ -4274,7 +4274,8 @@ bad:
}
}
ctxt.Diag("doasm: notfound ft=%d tt=%d %v %d %d", p.Ft, p.Tt, p, oclass(ctxt, p, &p.From), oclass(ctxt, p, &p.To))
ctxt.Diag("invalid instruction: %v", p)
// ctxt.Diag("doasm: notfound ft=%d tt=%d %v %d %d", p.Ft, p.Tt, p, oclass(ctxt, p, &p.From), oclass(ctxt, p, &p.To))
return
}
......
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