From ed96240e2a8bc7a6dd504457c357d4dc557f69b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Mon, 29 Apr 2024 14:18:48 +0200 Subject: [PATCH] Fix extraction of shift value for immediate instructions The shift value must be treated as an unsigned integer otherwise a shift value such as '0b11111' would be interpreted as -1 instead of 31. --- angr_platforms/risc_v/instrs_riscv/instruction_patterns.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angr_platforms/risc_v/instrs_riscv/instruction_patterns.py b/angr_platforms/risc_v/instrs_riscv/instruction_patterns.py index 3cd866c..5370c08 100644 --- a/angr_platforms/risc_v/instrs_riscv/instruction_patterns.py +++ b/angr_platforms/risc_v/instrs_riscv/instruction_patterns.py @@ -94,8 +94,8 @@ def get_imm(self): return self.constant(data, Type.int_32) def get_shift_amount(self): - num = BitArray(bin=self.data['I']).int - return self.constant(num, Type.int_8) + num = BitArray(bin=self.data['I']) + return self.constant(num.uint, Type.int_8) def get_optional_func7(self): return self.data['i']