Commit graph

813 commits

Author SHA1 Message Date
Chen
21ce362438
Use cs_ac_type for operand access mode in all arches and use cs_xtensa_op_type for Xtensa operand type (#2721)
* Xtensa: use cs_xtensa_op_type for operand type, and use cs_ac_type for operand access mode

To explicitly tell the user the possible values of the operand
type/access mode.

Also drop the unused XTENSA_OP_MEM_REG and XTENSA_OP_MEM_IMM.

* Use cs_ac_type for operand access mode in all arches

Currently, some arches use uint8_t for operand access mode, while others
use cs_ac_type. Use cs_ac_type uniformly.

* M680X: use cs_ac_type directly, instead of adding another e_access type

* Change access type to c_uint to follow c-side changes to cs_ac_type

* Document operand access type change to enum
2025-06-05 11:49:20 +08:00
Rot127
87908ece5b
Add flag for the SoftFail case of the LLVM disassembler. (#2707) 2025-05-26 21:39:17 +08:00
Rot127
fc525c7326
Apple AArch64 proprietary (#2692)
* Fix: In case of combat header AArhc64 should be defined by ARM64

* Add Apple proprietary AMX extension.

* Refine docs about Auto-Sync update

* Add Mul53 instructions.

* Fix accidentially removed memory information.

* Add gexit, genter, wkdmd, wkdmc instructions.

* Add sdsb and at_as1elx

* Update Python bindings.

* Fix typo.
2025-05-06 12:14:13 +08:00
Leon Hwang
2607d0f39a
Remove undefined constants in riscv_const.py (#2660) (#2661)
The following constants are undefined in `capstone/include/capstone/riscv.h`.

So, remove them as those were commented in `riscv.h`.

Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
2025-04-02 19:20:35 +08:00
Rot127
bb2f657973
Enhance shift value and types of shift instructions. (#2638)
* Enhance shift value and types of shift instructions.

Shifts via registers now save the register id in cs_arch64_op.shift.value
and set the shift type accordingly.

* Sort table
2025-03-09 22:11:53 +08:00
Rot127
cd282ef593
Update operand type enums of all arch modules to the one in capstone.h (#2633)
* Set all operand types to the main CS_OP_ types from capstone.h.

* Add test cases from issue.
2025-03-03 11:59:24 +08:00
@Antelox
cd8dd20ccf
- Added missing files for sdist archive (#2624) 2025-03-01 22:35:59 +08:00
Giovanni
1bea3fab15
Add checks for MIPS details on cstest_py (#2640) 2025-02-27 17:19:21 +08:00
Giovanni
ace8056ca8
Add aliases mapping for MIPS & test for id, alias_id (#2635) 2025-02-26 23:42:31 +08:00
Wu ChenXu
8ac2843b9b
chore(version): Update Version to 6.0.0-Alpha3 (#2616)
* chore(version): Update Version to 6.0.0-RC1

* chore(version): change version name to 6.0.0-alpha3
2025-01-29 00:59:30 +08:00
Rot127
d7ef910bc6
Rebased #2570 (#2614)
* Add ARC files

* Added ARC files for successful compilation

* Refactor ARC files

* Add ARC c/cs tests

* Add ARC python test/bindings

* Add ARC to CI/CD

* Avoid omitting parameter names

* Update cs files

* Fix ARC bugs

* Update ARC python bindings

* Refactor and update ARC test files

* Add detail flag to arc test

* Fix ARC test problems

* Fix ARCMapping compile error

* Replace __CHAR_BIT__ to CHAR_BIT

* Add credits and ARC info

* Update ARC to match the latest next

* Python formatting

* Remove asserts on 'Unknown condition code passed'

* Add ARC to some more documentation

* Add ARC to Targets constants

* Add ARC support to llvm-tblgen

* Replace asserts & add Expr handling

* Check DecodeGPR32RegisterClass return value

* Fix fieldFromInstruction patch

* Refactor ARC

* Reformat python files

* Fix incorrect import

* Update inc files and insn names

* Update python files

* Disable AArch64 Linux wheel build due to https://github.com/capstone-engine/capstone/issues/2615.

---------

Co-authored-by: R33v0LT <sibirtsevdl@gmail.com>
2025-01-28 22:34:24 +08:00
Andelf
3060117630
Apply new EVM opcode updates (#2602)
* evm: apply new opcode updates and add test cases

* evm: use predefined invalid opcode 0xfe

* python: add CsInsn.is_invalid_insn to bypass evm issue
2025-01-28 20:51:43 +08:00
Changqing Jing
3c4d7fc8d6
Add tricore tc1.8 instructions (#2595)
* Add tricore tc1.8 instructions:
add.df
sub.df
madd.df
msub.df
mul.df
div.df
cmp.df
max.df
min.df
min.f
max.f
dftoi
dftoiz
dftoin
ftoin
dftou
dftouz
dftol
dftoul
dftoulz
abs.f
abs.df
dftolz
neg.df
neg.f
qseed.df
itodf
utodf
ltodf
ultodf
dftof
ftodf

* Fix python binding

* Fix python binding

* add tricore tc1.8 instructions
div64
div64.u
rem64
rem64.u

* add tricore tc1.8 instruction to tests/details

* Fix review
2025-01-28 20:50:43 +08:00
Giovanni
8629313600
Fix LoongArch aliases and CS_OPT_SYNTAX_NO_DOLLAR support (#2594)
* Fix CS_OPT_DETAIL_REAL & CS_OPT_SYNTAX_NO_DOLLAR support in LoongArch

* Fix comment
2025-01-06 18:12:44 +08:00
Roee Toledano
812e654c85
Update BPF arch (#2568) 2024-12-15 20:46:45 +08:00
Rot127
2c4b05f635
Clean up the cstest documentation and build instructions. (#2580) 2024-12-15 14:07:47 +08:00
peace-maker
89aee40003
Add arm64 and sysz compatibility layer to Python bindings (#2559)
* Add arm64.py and sysz_const.py compatibility layer to the Python bindings

When importing `capstone.arm64` before doing other capstone imports the ARM64 constants get monkey patched into the exports.
Same with `capstone.sysz_const` for the SYSZ constants.

* Add SPDX-License comments

* Access an instruction detail in compatibility test

* Fail python tests on error instead of just ERROR output

Include the test_iter.py in the test_all.py too.

* Improve python compatibility docs

Co-authored-by: Rot127 <45763064+Rot127@users.noreply.github.com>

* Test for ARM_CC_* constants presence

---------

Co-authored-by: Rot127 <45763064+Rot127@users.noreply.github.com>
2024-12-05 19:35:18 +08:00
Rot127
93a104c009
PPC LLVM 18 (#2540)
* Update PPC module to LLVM 18.

**New**

(According to LLVM changelog)

- Added DFP instruction.
- Added the SCV instruction.

**Changes**

- Memory decoder were simplified by decoding disponent and base reg separately.
- `DFORM` -> `DFORM_BASE`
- Use inverted `MCInstDesc` table.
- Replace the many declared printer in PPCInstPrinter with `static inlines`.
- Renamed groups to upper case.
- Switched to `ARCH_add_cs_detail_X()` function names.
- Remove `PPCInstPrinter.h` because it is no longer used.

* Fix: Use correct directory name.

* Fix segfaults and add asserts for these NULL cases.

* Allow to map a single LLVM option to multiple CS options

* Add default endian option to the MCUpdater

* Fix setter for Little endian

* Add SPE option to cstool

* Fix QPX instructions.

Due to 4b43ef3e5c
the names of the operands were matched.
Because FRT dosn't exist in the XForm_1 class,
the generated tables didn't decoded them.

* Fix: AbsAddr should be printed as unsigned.

* Fix S12 immediate printing for PC memory operands

* Fix MCUpdater tests

* Update PPCRegisterInfo_stripRegisterPrefix

* Add support for selection of Power versions

* Run clang-format

* Fix feature check

* Allow to overwrite in multi-mode

* Add some more flags

* Fix order and map name

* Add new test files.

* Fix checks for features.

Only enables PowerX feature checks of a Power architecture is enabled
and the feature is in the list of it.

* Print byte sequence with space between comma.

This helps with copy and search of the byte string in the test files.

* Fix tests broken due to feature toggles

* Shorten generated names.

* Update bindings
2024-12-05 19:26:33 +08:00
Wu ChenXu
b295cf57c5
Prepare for update (#2552)
* Bindings(chore): Fix DeprecationWarning

* Version(upgrade): update bindings const

* Fix(chore): Fix ARMCC_Invalid is not defined
2024-11-24 23:11:38 +08:00
Rot127
7d01d7e7a9
Auto-Sync reproducability + ARM update (#2532) 2024-11-22 00:31:27 +08:00
@Antelox
6ad2608dcb
Python package building rework (#2538)
* - Refactored setup.py to remove hacks regarding packaging of wheels for different platforms, improve and cleanup the code
- Updated README.txt
- Removed old Makefile and build_wheel.sh scripts
- Created a new workflow that takes care of building and testing python packages for different platforms/architectures/python versions

* Added SPDX headers to the setup.py

* - cstest_py: Fixed positional argument since it doesn't accept a `required` flag. It turns to have a mandatory tests folder path
- integration_tests.py: Use pathlib to determine the required path
- GitHub action: Simplified the tests execution command

* GitHub Actions: Run python 3.8 (lowest) and 3.13 (current highest) for native runners only during testings and the rest during tag release

* GitHub Action:
- Fixed the cibw_build matrix element
- Added a step to prepare artifact name

* GitHub Action: Added run_tests.py script to run all tests during CI workflow

* - Added SPDX headers to the run_tests.py script and to the build-wheels-publish.yml workflow file
- Minor fixes to the workflow as pointed out in the PR review
- Updated MANIFEST.in to reflect the actual libraries built during python wheel creation process
- Use subprocess.run in place of os.system in run_tests.py script

* GitHub Action:
- Run qemu step only if non-native Linux runner
- Added arch:universal2 matrix element for macos-latest runner

* Python bindings: Refreshed the list of files needed to be copied for sdist archive

* GitHub Action: Commented out arch:x86 matrix elements

* GitHub Action: Run qemu step only if non-native Linux runner

* GitHub Action: Minor fixes

* Python bindings: Added missing .in pattern when collecting src files for sdist archive
2024-11-18 19:10:27 +08:00
billow
1ecfb5b042
xtensa: update to espressif/llvm-project (#2533) 2024-11-10 21:55:40 +08:00
Rot127
379e2a4114
Rename build arguments: (#2534)
- BUILD_SHARED_LIBS -> CAPSTONE_BUILD_SHARED_LIBS
- BUILD_STATIC_LIBS -> CAPSTONE_BUILD_STATIC_LIBS
- BUILD_STATIC_LIBS -> CAPSTONE_BUILD_STATIC_MSVC_RUNTIME
2024-11-09 15:05:30 +08:00
Andrew
d7be5f9f9f
Change CI to create Debian Package to Release (#2521)
* Updating CI to create Debian package and version is assigned by tag
version. Also updating release CI to not use end-of-life workflows

* Clear up usage of static libraries.

- Python bindings only use the dynamic lib. But built and copied the static ones sometimes nonetheless.
- Add toggles to build only static, static/dyn or only dynamic.

---------

Co-authored-by: Rot127 <unisono@quyllur.org>
2024-11-04 20:32:53 +08:00
Rot127
09f35961cb
This time actually fix big endian issue. (#2530) 2024-10-29 12:02:37 +08:00
Wu ChenXu
a424e709e8
Be ready for V6-Alpha1 (#2492)
* update version to v6-alpha1

* update bindings const values
2024-09-30 22:48:08 +08:00
billow
21f7bc85f9
Xtensa Support (#2380)
* Fix leaks

* Remove unnecessary new lines

* Add checks for actual buffer length before attempting reading it.

* Xtensa: add xtensa support

* Xtensa fixes

- fix MCExpr
- fix Xtensa_add_cs_detail
- add `add_cs_detail`
- add `MCExpr *MCOperand_getExpr(const MCOperand *MC)` `void printExpr(const MCExpr *E, SStream *O)`

autosync fix

- fix StreamOperation.py
- replace `report_fatal_error` with `CS_ASSERT`
- fix patch StreamOperation.py
- replace `assert` with `CS_ASSERT`
- fix AddCSDetail.py
- fix QualifiedIdentifier

* Xtensa fix

* Xtensa fix .py

* add Xtensa to the fuzzer

* Xtensa `LITBASE`: add a basic implementation

* Xtensa `LITBASE`: add a integration test

* Xtensa: fix cs_v6_release_guide.md

* Xtensa: fix `XTENSA_OP_GROUP_MEMOPERAND`

* Xtensa: fix

* Xtensa: fix Targets.py

* Use isUint and isInt all over Xtensa

* Add documentation about LITBASE functionality

* Fix typo

* Replace hard with Capstone assert

* Xtensa: fix arch_config.json

* Xtensa: fix

---------

Co-authored-by: Rot127 <unisono@quyllur.org>
2024-09-30 11:35:51 +08:00
Rot127
29d8773417
Several small fixups (#2489)
* Remove internal code from API

* Fix compatibility headers and test the generation of them

* Cancel all previous test workflows on new push.

* Add valgrind test
2024-09-30 11:33:31 +08:00
Rot127
1014864d3f
Rename CS_OPT_NO_BRANCH_OFFSET and corresponding flag to better name. (#2482) 2024-09-25 15:33:45 +08:00
Rot127
0c90fe13f5
Replace assert with CS_ASSERT in modules (#2478)
* Replace asserts with macros for AArch64, Alpha, LoongArch, Mips, SystemZ inc files.

* Add missing clearing of MCInst

* Ensure correct dir name is used.

* Replace asserts in inc files for PPC, ARM, TriCore

* Replace all asserts in modules with CS_ASSERT.

Also enable the CS_ASSERTs if CMAKE_BUILD_TYPE=Debug

* Formatting
2024-09-25 14:58:06 +08:00
Rot127
823bfd53e3
AArch64 issues (#2473)
* Fix Pn was printed as register, not predicate.

* Fix: is_alias must be an int to allow for -1 as false.

* Fix, shift immediate was casted to incorrect width.

* Store theexact float also in fp field for convenience.

* Fix: MRS has no implicit write of NCVZ

* Fix signs of Imm8 shifted operands.

* Fix another MRS test

* Fix: Src operand of CASAL had write flag set.

* Fix sysop access in Python data structures.
2024-09-24 12:32:10 +08:00
Rot127
5430745e96
ARM fixes (#2477)
* Fix #2381

* Fix #2382

* Fix post-index correction only for pop with single register

* Fix missing memory index register scale

* Remove faulty and duplicated lshift field.

* Add shift information to shift alias instructions and add several tests.

* Fix scale tests

---------

Co-authored-by: Wu ChenXu <kabeor00@gmail.com>
2024-09-23 11:30:33 +08:00
Rot127
3a2cd3c331
Coverity defects (#2469)
* Fix CID 508418 - Uninitialized struct

* Fix CID 509089 - Fix OOB read and write

* Fix CID 509088 - OOB.

Also adds tests and to ensure no OOB access.

* Fix CID 509085 - Resource leak.

* Fix CID 508414 and companions - Using undefined values.

* Fix CID 508405 - Use of uninitialized value

* Remove unnecessary and badly implemented dev fuzz code.

* Fix CID 508396 - Uninitialzied variable.

* Fix CID 508393, 508365 -- OOB read.

* Fix CID 432207 - OVerlapping memory access.

* Remove unused functions

* Fix CID 432170 - Overlapping memory access.

* Fix CID 166022 - Check for negative index

* Let strncat not depend n src operand.

* Fix 509083 and 509084 - NULL dereference

* Remove duplicated code.

* Initialize sysop

* Fix resource leak

* Remove unreachable code.

* Remove duplicate code.

* Add assert to check return value of cmoack

* Fixed: d should be a signed value, since it is checked against < 0

* Add missing break.

* Add NULL check

* Fix signs of binary search comparisons.

* Add explicit cast of or result

* Fix correct scope of case.

* Handle invalid integer type.

* Return UINT_MAX instead of implicitly casted -1

* Remove dead code

* Fix type of im

* Fix type of d

* Remove duplicated code.

* Add returns after CS_ASSERTS

* Check for len == 0 case.

* Ensure shift operates on uint64

* Replace strcpy with strncpy.

* Handle edge cases for 32bit rotate

* Fix some out of enum warnings

* Replace a strcpy with strncpy.

* Fix increment of address

* Skip some linting

* Fix: set instruction id

* Remove unused enum

* Replace the last usages of strcpy with SStream functions.

* Increase number of allowed AArch64 operands.

* Check safety of incrementing t the next operand.

* Fix naming of operand

* Update python constants

* Fix option setup of CS_OPT_DETAIL_REAL

* Document DETAIL_REAL has to be used with CS_OPT_ON.

* Run Coverity scan every Monday.

* Remove dead code

* Fix OOB read

* Rename macro to reflect it is only used with sstreams

* Fix rebase issues
2024-09-18 21:19:42 +08:00
Rot127
af1ed2fb3d
SystemZ Auto-Sync refactor (#2462) 2024-09-14 16:57:54 +08:00
Giovanni
6a7fef60ea
Auto-Sync Mips (#2410) 2024-09-07 22:30:47 +08:00
Rot127
191db14531
Modern Testing (#2456) 2024-08-31 21:33:38 +08:00
Rot127
42d3acf5ec
[next] Wheel build fixes: manylinux1, trigger upload on release, Linux AArch64... (#2444)
* Add AArch64 linux build again.

* Enable package build also for PRs and pushes.

* Fix: don't append python version to injected platform name.

* Add musllinux build to wheel checking script

* Trigger wheel upload only on published full-releases.

* Remove duplicate workflow file

* Ensure all artifacts are moved to the same directory 'dist'

* Enable verbose twine upload.

* Add step to show downloaded artifacts for debugging.
2024-08-19 16:33:08 +08:00
Mario Haustein
78eee139f4
Fix 'make check' for python tests (#2439) 2024-08-19 10:50:29 +08:00
Rot127
5e6807bab9
[next] Updates and fixes to the Python wheel builder workflow (#2441) 2024-08-15 20:57:23 +08:00
david942j
c666fbdb74
Fix typo in AArch64 Python binding (#2413) 2024-08-01 11:58:47 +08:00
Kevin Phoenix
8ddb2b971f Update setup.py to reflect minimum python 3.8 2024-07-16 12:26:15 -07:00
Kevin Phoenix
f9949e567c Remove cython bindings 2024-07-15 12:16:13 -07:00
Kevin Phoenix
6f96163adc Seperate cython bindings into seperate bindings package 2024-07-15 12:14:03 -07:00
Kevin Phoenix
add1659f32 Move python tests to test directory 2024-07-15 12:14:03 -07:00
Kevin Phoenix
19ce4baaf5 Disable zip_safe 2024-07-15 12:14:03 -07:00
Kevin Phoenix
16d56703a3 Cast resources path to str 2024-07-15 12:14:03 -07:00
Kevin Phoenix
95f82446c1 Remove PurePath() call breaking .join() 2024-07-15 12:14:03 -07:00
Kevin Phoenix
f23d862b03 Use importlib_resources on python<3.9 2024-07-15 12:14:03 -07:00
Pyrox
0acbec877a Fix cython bindings 2024-07-15 12:14:03 -07:00
Pyrox
b555844526 Remove distutils
Removes distutils from the setup.py script for the python bindings, as
it is removed in Python 3.12 onwards.
2024-07-15 12:14:03 -07:00