Skip to content

Add capstone 6 compatibility for ARM64 and S390X architectures - #353

Merged
twizmwazin merged 3 commits into
angr:masterfrom
kripticni:fix/capstone-v6-compat
Jun 24, 2026
Merged

Add capstone 6 compatibility for ARM64 and S390X architectures#353
twizmwazin merged 3 commits into
angr:masterfrom
kripticni:fix/capstone-v6-compat

Conversation

@kripticni

Copy link
Copy Markdown
Contributor

Capstone 6 renamed CS_ARCH_ARM64 -> CS_ARCH_AARCH64 and CS_ARCH_SYSZ -> CS_ARCH_SYSTEMZ
in its Python bindings (old names removed entirely).

This adds try/except fallback so archinfo works with both capstone 5.x and 6.x.
The new constant name is tried first, with a fallback to the old name for older
capstone versions.

@kripticni

Copy link
Copy Markdown
Contributor Author

Thanks for taking a look. I'll be more active tomorrow to address any feedback — appreciate your time reviewing this.

@ltfish

ltfish commented Jun 23, 2026

Copy link
Copy Markdown
Member

@rhelmot what if we bump our capstone minimum version requirement to 6.0?

@rhelmot

rhelmot commented Jun 23, 2026

Copy link
Copy Markdown
Member

The world would be a better place

@kripticni

Copy link
Copy Markdown
Contributor Author

@rhelmot I could do my best to bump it and fix any emergent issues?

@rhelmot

rhelmot commented Jun 23, 2026

Copy link
Copy Markdown
Member

Yes please!

@kripticni

Copy link
Copy Markdown
Contributor Author

I'll be on it later today and tomorrow! Happy to help!

@kripticni

Copy link
Copy Markdown
Contributor Author

@ltfish @rhelmot, Is it okay to drop the capstone <6.0 fallbacks and require capstone >=6.0? And should capstone remain an optional dependency?

@kripticni

Copy link
Copy Markdown
Contributor Author

@ltfish @rhelmot, Is anything else needed from my side to get this exact pr merged?

pyright does not understand try/except AttributeError for module-level
attribute access. Using getattr() tells the type checker that both
the new and old constant names are valid paths.
getattr(obj, name, default) evaluates all arguments before the call.
On capstone 6, the fallback _capstone.CS_ARCH_ARM64 raises
AttributeError during argument evaluation even though CS_ARCH_AARCH64
exists. Same issue for CS_ARCH_SYSZ on capstone 6.

hasattr() short-circuits with a ternary if/else, so the fallback
branch is never evaluated when the new name exists. pyright
understands hasattr for type narrowing.
@twizmwazin
twizmwazin force-pushed the fix/capstone-v6-compat branch from fdb1890 to 691c6a8 Compare June 24, 2026 15:55
@twizmwazin
twizmwazin merged commit 9d5abb3 into angr:master Jun 24, 2026
18 of 19 checks passed
@ltfish

ltfish commented Jun 24, 2026

Copy link
Copy Markdown
Member

Thanks, @kripticni !

@kripticni

Copy link
Copy Markdown
Contributor Author

@ltfish please respond to the 6.0.0 questions I posted here, I'm still planning to try to bump capstone in seperate pr and I need the info, thanks!

@twizmwazin

Copy link
Copy Markdown
Member

@kripticni If bumping capstone to 6.0, please do remove the compat code for capstone<6. It should remain an optional dependency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants