From: Ben Shi Date: Tue, 24 Jul 2018 03:47:39 +0000 (+0000) Subject: cmd/internal/obj/arm64: reject incorrect form of LDP/STP X-Git-Tag: go1.11beta3~60 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e351a1600514b6a4ae18c4b44e883b049c314ebd;p=gostls13.git cmd/internal/obj/arm64: reject incorrect form of LDP/STP "LDP (R0), (F0, F1)" and "STP (F1, F2), (R0)" are silently accepted by the arm64 assembler without any error message. And this CL fixes that bug. fixes #26556. Change-Id: Ib6fae81956deb39a4ffd95e9409acc8dad3ab2d2 Reviewed-on: https://go-review.googlesource.com/125637 Run-TryBot: Ben Shi TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- diff --git a/src/cmd/asm/internal/asm/testdata/arm64error.s b/src/cmd/asm/internal/asm/testdata/arm64error.s index be2251e442..01d23eb527 100644 --- a/src/cmd/asm/internal/asm/testdata/arm64error.s +++ b/src/cmd/asm/internal/asm/testdata/arm64error.s @@ -89,4 +89,6 @@ TEXT errors(SB),$0 CSEL LT, R1, R2 // ERROR "illegal combination" AND $0x22220000, R2, RSP // ERROR "illegal combination" ANDS $0x22220000, R2, RSP // ERROR "illegal combination" + LDP (R0), (F0, F1) // ERROR "invalid register pair" + STP (F2, F3), (R0) // ERROR "invalid register pair" RET diff --git a/src/cmd/internal/obj/arm64/asm7.go b/src/cmd/internal/obj/arm64/asm7.go index 192d65df96..ff4b1d7ec1 100644 --- a/src/cmd/internal/obj/arm64/asm7.go +++ b/src/cmd/internal/obj/arm64/asm7.go @@ -6160,6 +6160,16 @@ func (c *ctxt7) opldpstp(p *obj.Prog, o *Optab, vo int32, rbase, rl, rh, ldp uin default: c.ctxt.Diag("invalid instruction %v\n", p) } + switch p.As { + case ALDP, ALDPW, ALDPSW: + if rl < REG_R0 || REG_R30 < rl || rh < REG_R0 || REG_R30 < rh { + c.ctxt.Diag("invalid register pair %v\n", p) + } + case ASTP, ASTPW: + if rl < REG_R0 || REG_R31 < rl || rh < REG_R0 || REG_R31 < rh { + c.ctxt.Diag("invalid register pair %v\n", p) + } + } switch o.scond { case C_XPOST: ret |= 1 << 23