capstone
capstone copied to clipboard
Very inefficient patching of Capstone register alias.
Capstone used different ARM register alias than the one from LLVM.
Back then I implemented some lazy patching if a flag was set in ARMMapping.c::patch_cs_reg_alias(). This one uses a lot of strstr() and has a best case runtime of O(|asm_text| * 7) (yes I feel bad about this in retrospect).
This is only called if the CS_OPT_SYNTAX_CS_REG_ALIAS flag is set. Which many people probably use, if they switched to v6, the tests break by default since Capstone no longer defaults to the old alias. So people probably use the flag to have less trouble.
This function must be made more efficient before the Beta.
Two options:
- Intermediate option: Check the details for any of the effected registers and only patch if they are present.
- The actual solution: Add the Capstone alias in the
tdfiles. The key words to search for are:RegAltNameIndicesand more generallyAltNameinARMRegisterInfo.td. And go from there to see how other alias are implemented.