Validate signed-26 PC-relative offset in B instruction.
authorTaylor R Campbell <campbell@mumble.net>
Fri, 1 Feb 2019 05:30:38 +0000 (05:30 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Wed, 21 Aug 2019 21:34:06 +0000 (21:34 +0000)
src/compiler/machines/aarch64/instr1.scm
src/compiler/machines/aarch64/insutl.scm

index 995d86cdecf2ad82a8e11c94ffae6d543eb766b6..791c65c79f70ffc4df44f990f80f480af2ca8369 100644 (file)
@@ -197,7 +197,7 @@ USA.
 ;; Branch unconditional to PC-relative.
 
 (define-instruction B
-  (((@PCO (* 4 (? offset))))
+  (((@PCO (* 4 (? offset signed-26))))
    (BITS (1 0)                          ;no link
          (5 #b00101)
          (26 offset SIGNED)))
index f1c37b53bc7d33151cebe96ca784fd1d69bce9b8..ad91370b925e51028ded59885b31e308e781e92b 100644 (file)
@@ -48,6 +48,11 @@ USA.
        (<= #x-100000 x #xfffff)
        x))
 
+(define (signed-26 x)
+  (and (exact-integer? x)
+       (<= #x-04000000 x #x03ffffff)
+       x))
+
 (define (signed-33 x)
   (and (exact-integer? x)
        (<= #x-100000000 x #xffffffff)