From 5b043abe1260d3ab0e5e27b6d312682149d321ba Mon Sep 17 00:00:00 2001 From: isharipo Date: Thu, 7 Sep 2017 13:30:43 +0300 Subject: [PATCH] cmd/asm: restrict x86 shift ops to 8bit args Change "yshl" and "yshb" immediate oclass from Yi32 to Yu8. This forbids: - negative shift counts - shift counts that not fit into 8bit Affects: RCL{B,L,Q,W} RCR{B,L,Q,W} ROL{B,L,Q,W} ROR{B,L,Q,W} SAL{B,L,Q,W} SAR{B,L,Q,W} SHL{B,L,Q,W} SHR{B,L,Q,W} Issue #21528 has some additional context about this change. Change-Id: I60884cb2b41a860820889fcd878ca6f564006b4a Reviewed-on: https://go-review.googlesource.com/62190 Run-TryBot: Iskander Sharipov TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox --- src/cmd/internal/obj/x86/asm6.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go index 760d8db475..f636d312d4 100644 --- a/src/cmd/internal/obj/x86/asm6.go +++ b/src/cmd/internal/obj/x86/asm6.go @@ -392,13 +392,13 @@ var ycmpl = []ytab{ var yshb = []ytab{ {Yi1, Ynone, Ymb, Zo_m, 2}, - {Yi32, Ynone, Ymb, Zibo_m, 2}, + {Yu8, Ynone, Ymb, Zibo_m, 2}, {Ycx, Ynone, Ymb, Zo_m, 2}, } var yshl = []ytab{ {Yi1, Ynone, Yml, Zo_m, 2}, - {Yi32, Ynone, Yml, Zibo_m, 2}, + {Yu8, Ynone, Yml, Zibo_m, 2}, {Ycl, Ynone, Yml, Zo_m, 2}, {Ycx, Ynone, Yml, Zo_m, 2}, } -- 2.50.0