diff options
| author | James Johnson <jjohnsonjj1251@gmail.com> | 2025-10-20 21:09:29 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-11-17 17:54:57 -0500 |
| commit | 89e76e22de16e873e676c93713866236035dc7fd (patch) | |
| tree | ae674602de3294e6a64896389f8f37c75a8e2da3 /rust | |
| parent | 33d04c64f4dd6577345dac14b564539ca37b3fee (diff) | |
Fix calculation of mask for constant values
This fixes an error when a constant is being loaded into a flag.
The constants associated with a flag value have their size set to zero.
That causes the mask for the constant value to be all zeros. Due to that,
getting the value of a zero sized constant will always return 0 even if
it should be 1.
This commit special cases the size of zero to create a mask of 1 which
will correctly mask off the lowest byte and return that as the constant.
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/src/low_level_il/operation.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/rust/src/low_level_il/operation.rs b/rust/src/low_level_il/operation.rs index 419a0dcd..fa320060 100644 --- a/rust/src/low_level_il/operation.rs +++ b/rust/src/low_level_il/operation.rs @@ -1754,12 +1754,14 @@ where } } - let mut mask = -1i64 as u64; - - if self.op.size < mem::size_of::<u64>() { - mask <<= self.op.size * 8; - mask = !mask; - } + let mask: u64 = if self.op.size == 0 { + 1 + } else if self.op.size < mem::size_of::<u64>() { + let m = -1i64 << (self.op.size * 8); + !m as u64 + } else { + (-1i64) as u64 + }; self.op.operands[0] & mask } |
