Skip to content

Commit

Permalink
AArch64 compatibility header (#2321)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 authored May 31, 2024
1 parent 3a6331b commit 1a6921f
Show file tree
Hide file tree
Showing 13 changed files with 4,833 additions and 15 deletions.
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 @@ -157,6 +157,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

0 comments on commit 1a6921f

Please sign in to comment.