Skip to content

Very inefficient patching of Capstone register alias. #2664

@Rot127

Description

@Rot127

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 td files. The key words to search for are: RegAltNameIndices and more generally AltName in ARMRegisterInfo.td. And go from there to see how other alias are implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions