Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AArch64 compatibility header #2321

Merged
merged 6 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/CITest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ jobs:
cp libcapstone.* ../tests/
cp test_* ../tests/

- name: "Compatibility header test build"
run: |
cd "$(git rev-parse --show-toplevel)/suite/auto-sync/c_tests/"
clang -lcapstone src/test_arm64_compatibility_header.c -o test_arm64_compatibility_header
./test_arm64_compatibility_header

- name: cstool - reaches disassembler engine
run: |
sh suite/run_invalid_cstool.sh
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ set(HEADERS_ENGINE

set(HEADERS_COMMON
include/capstone/aarch64.h
include/capstone/arm64.h
include/capstone/arm.h
include/capstone/capstone.h
include/capstone/cs_operand.h
Expand Down
26 changes: 20 additions & 6 deletions docs/cs_v6_release_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,30 @@ With all that said, we hope you enjoy the new release!

`ARM64` was everywhere renamed to `AArch64`. This is a necessity to ensure that the update scripts stay reasonably simple.
Capstone was very inconsistent with the naming before (sometimes `AArch64` sometimes `ARM64`).
Because Capstone uses a huge amount of LLVM code, we renamed everything to `AArch64`. This reduces complexity enormously.
Because Capstone uses a huge amount of LLVM code, we renamed everything to `AArch64`. This reduces complexity enormously because it follows the naming of LLVM.

Because this would completely break maintaining Capstone `v6` and `pre-v6` in a project, we added macros for meta-programming.
Because this would completely break maintaining Capstone `v6` and `pre-v6` in a project, we added two solutions:

If you need to support the previous version of Capstone as well, you can use those macros (see below helper scripts).
Also, your can exclude/include code by checking `CS_NEXT_VERSION < 6`.
1. Make `arm64.h` a compatibility header which merely maps every member to the one in the `aarch64.h` header.
2. Macros for meta-programming which select the right name.

The following `sed` commands in a sh script should ease the renaming from `ARM64` to `AArch64` a lot.
We will continue to maintain both solutions.
So if you need to support the previous version of Capstone as well, you can use either of the solutions.

Replacing with version sensitive macros:
_Compatibility header_

If you want to use the compatibility header and stick with the `ARM64` naming, you can define `CAPSTONE_AARCH64_COMPAT_HEADER` before including `capstone.h`.

```c
#define CAPSTONE_AARCH64_COMPAT_HEADER
#include <capstone/capstone.h>

// Your code...
```

_Meta programming macros_

The following `sed` commands in a sh script should ease the replacement of `ARM64` with the macros a lot.

```sh
#!/bin/sh
Expand Down
Loading
Loading