capstone
capstone copied to clipboard
arm: Sign of immediate is unclear
This issue was found during the discussion at: https://github.com/capstone-engine/capstone/pull/771#issuecomment-1594586622
Some instructions interpret immediates as signed while the others interpret them as unsigned. However, the imm member of cs_arm_op is typed as signed, which causes two problems:
- PC-relative addresses overflow when storing if the address is more than
INT32_MAXas they are computed as unsigned. - The code reading the
immmember ofcs_arm_opmay incorrectly think it is signed when it should be treated as unsigned.
It will be nice if we can change how to store and load immediate values in cs_arm_op depending on instructions.
Just as a note. LLVM saves immediate values in general as int64_t. We can think about doing just that. So we mimic LLVM as close as possible.