]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/arm64: reject incorrect form of LDP/STP
authorBen Shi <powerman1st@163.com>
Tue, 24 Jul 2018 03:47:39 +0000 (03:47 +0000)
committerCherry Zhang <cherryyz@google.com>
Mon, 30 Jul 2018 15:31:06 +0000 (15:31 +0000)
"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 <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/asm/internal/asm/testdata/arm64error.s
src/cmd/internal/obj/arm64/asm7.go

index be2251e442e0c6794542f06a1534af181702acf0..01d23eb527a7c7a6a99c47e299e67f5af2963d0e 100644 (file)
@@ -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
index 192d65df96c8423e544885603a8d1d7b720c2bfa..ff4b1d7ec11a3c0974f47572ec8a9dd1cb3991aa 100644 (file)
@@ -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