Add arm64 and sysz compatibility layer to Python bindings #2559
+123
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Your checklist for this pull request
Detailed description
To allow Python scripts to work with ARM64 and SYSZ constants on capstone v5 as well as v6, provide a compatibility layer similar to the compatibility headers in the C API. Script authors can choose to keep the old constant names around to avoid forcing the update to capstone v6 right away.
The idea is to introduce something in a similar fashion to the C API
CAPSTONE_AARCH64_COMPAT_HEADER
defines, which defines the oldARM64_*
constants. Instead of a#define
before including capstone, Python scripts should explicitly import the architecture by their old name before their usual capstone imports:SystemZ follows a similar pattern:
This is achieved by monkey-patching the modules to define all exports expected by scripts supporting older versions of capstone using
setattr(capstone, name, value)
.This compatibility layer only handles constant values. The ctypes structures aren't reexposed with old names and the
_cs_arch
doesn't contain thearm64
arch, so code usinginsn.detail.arm64.cc
or similar still fails. I don't know how to rename those in a transparent manner.Test plan
Added test script which uses the old constants.
Closing issues
closes #2536