1
0
mirror of https://github.com/golang/go synced 2024-10-02 04:28:33 -06:00

cmd/internal/obj/arm64: fix assemble VLD1/VST1 bug

The current code misassembles VLD1/VST1 instruction with non-zero
offset. The offset is dropped silently without any error message.
The cause of the misassembling is the current code treats argument
(Rn)(Rm) as ZOREG type.

The fix changes the matching rules and considers (Rn)(Rm) as ROFF
type. The fix will report error information when assembles VLD1/VST1
(R8)(R13), [V1.16B].
The fix enables the ARM64Errors test.

Fixes #23448

Change-Id: I3dd518b91e9960131ffb8efcb685cb8df84b70eb
Reviewed-on: https://go-review.googlesource.com/87956
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
fanzha02 2018-01-16 03:00:04 +00:00 committed by Cherry Zhang
parent 4a2f28f51e
commit cafb36bf11
3 changed files with 28 additions and 3 deletions

View File

@ -385,6 +385,10 @@ func TestARM64Encoder(t *testing.T) {
testEndToEnd(t, "arm64", "arm64enc")
}
func TestARM64Errors(t *testing.T) {
testErrors(t, "arm64", "arm64error")
}
func TestAMD64EndToEnd(t *testing.T) {
testEndToEnd(t, "amd64", "amd64")
}

View File

@ -0,0 +1,13 @@
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
TEXT errors(SB),$0
MOVD.P 300(R2), R3 // ERROR "offset out of range [-255,254]"
MOVD.P R3, 344(R2) // ERROR "offset out of range [-255,254]"
VLD1 (R8)(R13), [V2.B16] // ERROR "illegal combination"
VLD1 8(R9), [V2.B16] // ERROR "illegal combination"
VST1 [V1.B16], (R8)(R13) // ERROR "illegal combination"
VST1 [V1.B16], 9(R2) // ERROR "illegal combination"
VLD1 8(R8)(R13), [V2.B16] // ERROR "illegal combination"
RET

View File

@ -584,6 +584,7 @@ var optab = []Optab{
{AVADD, C_VREG, C_NONE, C_VREG, 89, 4, 0, 0, 0},
{AVLD1, C_ZOREG, C_NONE, C_LIST, 81, 4, 0, 0, 0},
{AVLD1, C_LOREG, C_NONE, C_LIST, 81, 4, 0, 0, C_XPOST},
{AVLD1, C_ROFF, C_NONE, C_LIST, 81, 4, 0, 0, C_XPOST},
{AVMOV, C_ELEM, C_NONE, C_REG, 73, 4, 0, 0, 0},
{AVMOV, C_REG, C_NONE, C_ARNG, 82, 4, 0, 0, 0},
{AVMOV, C_ARNG, C_NONE, C_ARNG, 83, 4, 0, 0, 0},
@ -592,6 +593,7 @@ var optab = []Optab{
{AVREV32, C_ARNG, C_NONE, C_ARNG, 83, 4, 0, 0, 0},
{AVST1, C_LIST, C_NONE, C_ZOREG, 84, 4, 0, 0, 0},
{AVST1, C_LIST, C_NONE, C_LOREG, 84, 4, 0, 0, C_XPOST},
{AVST1, C_LIST, C_NONE, C_ROFF, 84, 4, 0, 0, C_XPOST},
{AVDUP, C_ELEM, C_NONE, C_ARNG, 79, 4, 0, 0, 0},
{AVADDV, C_ARNG, C_NONE, C_VREG, 85, 4, 0, 0, 0},
{AVMOVI, C_ADDCON, C_NONE, C_ARNG, 86, 4, 0, 0, 0},
@ -1268,6 +1270,12 @@ func (c *ctxt7) aclass(a *obj.Addr) int {
return autoclass(c.instoffset)
case obj.NAME_NONE:
if a.Index != 0 {
if a.Offset != 0 {
return C_GOK
}
return C_ROFF
}
c.instoffset = a.Offset
return oregclass(c.instoffset)
}
@ -1417,7 +1425,7 @@ func (c *ctxt7) oplook(p *obj.Prog) *Optab {
}
}
c.ctxt.Diag("illegal combination %v %v %v %v, %d %d", p, DRconv(a1), DRconv(a2), DRconv(a3), p.From.Type, p.To.Type)
c.ctxt.Diag("illegal combination: %v %v %v %v, %d %d", p, DRconv(a1), DRconv(a2), DRconv(a3), p.From.Type, p.To.Type)
if ops == nil {
ops = optab
}
@ -2523,7 +2531,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
v := int32(p.From.Offset)
if v < -256 || v > 255 {
c.ctxt.Diag("offset out of range\n%v", p)
c.ctxt.Diag("offset out of range [-255,254]: %v", p)
}
o1 = c.opldrpp(p, p.As)
if o.scond == C_XPOST {
@ -2537,7 +2545,7 @@ func (c *ctxt7) asmout(p *obj.Prog, o *Optab, out []uint32) {
v := int32(p.To.Offset)
if v < -256 || v > 255 {
c.ctxt.Diag("offset out of range\n%v", p)
c.ctxt.Diag("offset out of range [-255,254]: %v", p)
}
o1 = LD2STR(c.opldrpp(p, p.As))
if o.scond == C_XPOST {