gigahorse-toolchain
gigahorse-toolchain copied to clipboard
prevent symbolic_value from saturating integers
This tackles a miss-optimization from Solidity that generates code like this:
0xa50x31: va5V31 = MLOAD va3V31(0x40)
0xa60x31: va6V31(0x1f) = CONST
0xa80x31: va8V31(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0) = NOT va6V31(0x1f)
0xa90x31: va9V31 = ADD va8V31(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0), va5V31
0xaa0x31: vaaV31 = MLOAD va9V31
with the intention of dereferring (ptr - 0x20). This causes Variable_SymbolicValue to saturate the integer instead of returning the right offsets.
The proposed modification to gigahorse is detecting if the integer gets saturated and make the number negative. Open to other potential solutions.
Hi @snf, Thanks for the PR, will check it out and let you know what I think.
Can you point me to the contract you're looking at? I know its a frequently seen code pattern, I just want to be working on a common example.
Thanks for having a look, I'm on leave but I'll get a testcase as my current one is too big to use as such.