cmd/asm: reject foo(SB)(AX) instead of silently treating as foo(SB)

Add test for assembly errors, to verify fix.
Make sure invalid instruction errors are printed just once
(was printing them once per span iteration, so typically twice).

Fixes #13282.

Change-Id: Id5f66f80a80b3bc4832e00084b0a91f1afec7f8f
Reviewed-on: https://go-review.googlesource.com/18858
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Russ Cox 2016-01-24 01:33:16 -05:00
parent 544f28a25e
commit 9d6427d899
6 changed files with 135 additions and 7 deletions

View file

@ -604,12 +604,13 @@ type Link struct {
Autosize int32
Armsize int32
Pc int64
Diag func(string, ...interface{})
DiagFunc func(string, ...interface{})
Mode int
Cursym *LSym
Version int
Textp *LSym
Etextp *LSym
Errors int
// state for writing objects
Text *LSym
@ -618,6 +619,11 @@ type Link struct {
Edata *LSym
}
func (ctxt *Link) Diag(format string, args ...interface{}) {
ctxt.Errors++
ctxt.DiagFunc(format, args...)
}
// The smallest possible offset from the hardware stack pointer to a local
// variable on the stack. Architectures that use a link register save its value
// on the stack in the function prologue and so always have a pointer between