Commit Graph

5175 Commits

Author SHA1 Message Date
Kevin Phoenix
9a8f189a0a Remove pkg_resources 2024-07-15 12:14:03 -07:00
Kevin Phoenix
7aca280b7d Create pyproject.toml and add python 3.12 to CI 2024-07-15 12:14:03 -07:00
wxrdnx
404912f068
Add access support for RISC-V (#2393)
* resolve conflict for loongarch and RISCV in Mapping.c and Mapping.h

* Use RISCV_get_detail for simplicity

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

* Use detail_is_set for simplicity

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

* Change comment style

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

* remove redundant add_str

* fix bug for RISCV_add_detail

* fix operands for csr instructions

* add python binding and tester for RISC-V

* add more test cases for RISC-V (M,A,F,D,C instructions)

* fix incorrect operand and access for sc.w and sc.d

* fix incorrect operand for fence and sfence.vma

* assert -> CS_ASSERT

* some instructions in test_riscv.c should be RISCV64

* add cs details test

* update python testers

---------

Co-authored-by: Rot127 <45763064+Rot127@users.noreply.github.com>
2024-07-10 11:36:39 +08:00
Rot127
9c5b48b57f
AArch64 update to LLVM 18 (#2298)
* Run clang-format

* Remove arm.h header from AArch64 files

* Update all AArch64 module files to LLVM-18.

* Add check if the differs save file is up-to-date with the current files.

* Add new generator for MC test trnaslation.

* Fix warnings

* Update generated AsmWriter files

* Remove unused variable

* Change MCPhysReg type to int16_t as LLVM 18 dictates.

With LLVM 18 the MCPhysReg value's type is changed to int16_t.
If we update modules to LLVM 18, they will generate
compiler warnings that uint16_t* should not be casted to int16_t*.

This makes changing the all tables to int16_t necessary, because the alternative is
to duplicate all MCPhysReg related code. Which is even worse.

* Assign enum values to raw_struct member

* Add printAdrAdrpLabel def

* Add header to regression test files.

* Write files to build dir and ignore more parsing errors.

* Fix parsing of MC test files.

* Reset parser after every block

* Add write and patch header step.

* Add and update MC tests for AArch64

* Fix clang-tidy warnings

* Don't warn about padding issues.

They break automatically initialized structs we can not change easily.

* Fix: Incorrect access of LLVM instruction descriptions.

* Initialize DecoderComplete flag

* Add more mapping and flag details

* Add function to get MCInstDesc from table

* Fix incorrect memory operand access types.

* Fix test where memory was not written, ut only read.

* Attempt to fix Windows build

* Fix 2268

The enum values were different and hence lead to different decoding.

* Refactor SME operands.

- Splits SME operands in Matrix and Predicate operands.
- Fixes general problems of incorrect detections with
the vector select/index operands of predicate registers.
- Simplifies code.

* Fix up typo in WRITE

* Print actual path to struct fields

* Add Registers of SME operands to the reg-read list

* Add tests for SME operands.

* Use Capstone reg enum for comparison

* Fix tests: 'Vector arra...' to 'operands[x].vas'

* Add the developer fuzz option.

* Fix Python bindings for SME operands

* Fix variable shadowing.

* Fix clang-tidy warnings

* Add missing break.

* Fix varg usage

* Brackets for case

* Handle AArch64_OP_GROUP_AdrAdrpLabel

* Fix endian issue with fuzzing start bytes

* Move previous sme.pred to it's own operand type.

* Fix calculation for imm ranges

* Print list member flag

* Fix up operand strings for cstest

* Do only a shallow clone of the cmocka stable branch

* Fix: Don't categorize ZT0 as a SME matrix operand.

* Remove unused code.

* Add flag to distinguish Vn and Qn registers.

* Add all registers to detail struct, even if emitted in the asm text

* Fix: Increment op count after each list member is added.

* Remove implicit write to NZCV for MSR Imm instructions.

* Handle several alias operands.

* Add details for zero alias with za0.h

* Add SME tile to write list if written

* Add write access flags to operands which are zeroed.

* Add SME tests of #2285

* Fix tests with latest syntax changes.

* Fix segfault if memory operand is only a label without register.

* Fix python bindings

* Attempt to fix clang-tidy warning for some configurations.

* Add missing test file (accidentially blocked by gitignore.)

* Print clang-tidy version before linting.

* Update differ save file

* Formatting

* Use clang-tidy-15 as if possible.

* Remove search patterns for MC tests, since they need to be reworked anyways.

* Enum to upper case change

* Add information to read the OSS fuzz result.

* Fix special case of SVE2 operands.

Apparently ZT0 registers can an index attached,
get which is BOUND to it. We have no "index for reg" field.
So it is simply saved as an immediate.

* Handle LLVM expressions without asserts.

* Ensure choices are always saved.

* OP_GROUP enums can't be all upper case because they contain type information.

* Fix compatibility header patching

* Update saved_choices.json

* Allow mode == None in test_corpus
2024-07-08 10:28:54 +08:00
Kevin Phoenix
8ce088bf58
Python2 leftovers v2 (#2395)
* Remove python2 leftovers
* Remove python2 references from BUILDING.txt
* Remove some leftover install3 references
* Update shebangs to python3
* Delete suite/test_corpus.py
2024-07-01 14:10:12 +08:00
Chen
95966a1393
Initial auto-sync LoongArch support (#2349)
* Initial auto-sync LoongArch support

- Accompanied llvm changes: https://github.com/capstone-engine/llvm-capstone/pull/45
- MC Tests are generated from llvm
- Instruction groups are implemented
- Register accesses are implemented
- Memory operands are handled for memory instructions
- Code are formatted using clang-format of LLVM 17
- Import tests from LLVM MC
- Collect operand type and access
- Collect registers read/modified
---------
Co-authored-by: CoA <1109673069@qq.com>

* Ensure same indent for all patched lines.
* Emit upper case OP_GROUP enum
* Spell all enum values in capital letters.
* Capticalize enums in loongarch_detail.c
* Add test which contains now a tab.
* Run clang-format on test_loongarch.c
---------
Co-authored-by: CoA <1109673069@qq.com>
Co-authored-by: Rot127 <unisono@quyllur.org>
2024-06-26 14:47:44 +08:00
Wu ChenXu
a3fd6ac3a4
Revert "Remove python2 leftovers (#2378)" (#2391)
This reverts commit 60d5b7ec2f.
2024-06-24 16:42:27 +08:00
RainRat
33f24cd074
fix typos (#2387) 2024-06-19 18:54:05 +08:00
Rot127
1adc45f265
Use python3 as default interpreter for all python scripts (#2390) 2024-06-19 18:52:51 +08:00
dufucun
26fd839e74
chore: fix some comments (#2379)
Signed-off-by: dufucun <dufuchun@sohu.com>
Co-authored-by: dufucun <dufucunn@sohu.com>
2024-06-13 08:53:20 +08:00
Rot127
0a67596f70
Add test with ASAN enabled. (#2313)
* Add test with ASAN enabled.

* Fix leaks in cstool and cs.c

* Add work around so ASAN binaries don't DEADSIGNAL due to too many randomized address bits.

* Add ASAN build arguments to cstest

* Fix leaks in cstest

* Use cstest binary build by the main build.

* Add clonging step for cmocka when cstest is build

* Skip Python tests for ASAN

* Remove make build from CI

* Fix leaks in cstest.

- Rewrite split to remove leaks and improve runtime by 6%
- Add free()

* Fix cmocka external project to stable branch.

* Revert "Fix leaks in cstest."

This reverts commit bf8ee125b0c58f9c794eb081a69c80f8a71825cd.

* Fix memleaks in cstest

* Document adding of ASAN job to release guide

* Add CAPSTONE_BUILD_CSTEST to build docs

* Fix double free

* Add more detail tests to CI and fix them

* Initialize variables

* Fix typo

* Update cstest build docs

* Revert "Remove make build from CI"

This reverts commit 84f7360c6da6183cd41bec0fef3e1d0a2ee49ddf.

* Make cstest only run for cmake builds.

* Add cstest job for make build.

* Add CAPSTONE_DIET build test.

* Compile the compatibility header test with ASAN if enabled.

* Fix DIET build by excluding not used code.

* Missing "

* Build static library with ASAN and DIET if enabled.

* Revert "Add CAPSTONE_DIET build test."

This reverts commit 71e1469dee.
2024-06-10 10:01:00 +08:00
Rot127
03c41e1be4
Restructure auto-sync docs to have them more contained (#2355)
* Restructure auto-sync docs to have them more contained in suite/auto-sync

* Enhance Differ documentation

* Fix link and emphasize importance of ARCHITECTURE.md

* Add auto-syc intro.md document, based on @moste00 work

* Be consistent with Auto-Sync naming and use python3
2024-06-10 09:55:47 +08:00
Kevin Phoenix
60d5b7ec2f
Remove python2 leftovers (#2378)
* Remove python2 leftovers

* Remove python2 references from BUILDING.txt

* Remove some leftover install3 references
2024-06-09 17:29:50 +08:00
Rot127
1a6921f5cc
AArch64 compatibility header (#2321) 2024-05-31 20:07:03 +08:00
Rot127
3a6331b4c2
Fix Warning C4098: void returns value. (#2362) 2024-05-31 20:02:03 +08:00
Anton Kochkov
f6ed6efc9c
Mapping - return NULL if compiled with DIET (#2370) 2024-05-31 19:49:41 +08:00
Rot127
fe60b1371c
Apply #2360 to next (#2361) 2024-05-18 14:32:01 +08:00
Rot127
5f11d3c1fe
Typo and tree-sitter init fix (#2358) 2024-05-16 20:31:44 +08:00
Anton Kochkov
9987b86aa4
README: Mention Alpha and HPPA (#2357) 2024-05-14 09:57:19 +08:00
Florian Märkl
2ef45f2a73
Replace non-standard 0b(...) literals (#2314)
Despite being widely implemented and part of C++, the 0b prefix is not
part of any C standard and will be rejected by some compilers such as
Apple GCC 4.0.1 (5493).
2024-05-12 21:19:11 +08:00
RainRat
972bd066bb
fix typos (#2346)
* fix typos

* fix typos

* fix typos
2024-05-12 21:17:20 +08:00
Snoppy
3b18d7d2a4
chore: fix typos (#2328)
Signed-off-by: snoppy <michaleli@foxmail.com>
Co-authored-by: Rot127 <45763064+Rot127@users.noreply.github.com>
2024-05-12 21:16:24 +08:00
Rot127
1a65b8db9e
Fix #2244: The offset for pseudo-instr. IDs was incorrectly applied for vcmp. (#2331) 2024-05-08 22:25:14 +08:00
Rot127
0002f10c99
Clang tidy quality of life (#2348) 2024-05-08 22:24:01 +08:00
Chen
9378216492
Rewrite str_replace using snprintf for security and fix clang-tidy (#2350) 2024-05-08 22:23:23 +08:00
Riccardo Schirone
f81eb3affa
Fix pkgconfig file to make #include <capstone/capstone.h> work (#2307) 2024-05-03 01:07:00 +08:00
Rot127
8f9a337dfa
Fix clang tidy (#2347) 2024-05-01 12:04:27 +08:00
RainRat
b91c727481
fix typos (#2344) 2024-04-30 10:37:53 +08:00
Rot127
b2d5b43ed2
Fix #2079 via the post-printer. (#2330) 2024-04-30 10:35:40 +08:00
Rot127
eb4fc2d761
Replace manually compile tree-sitter-cpp with their Python bindings. (#2337) 2024-04-26 15:16:00 +08:00
Rot127
514b8fca9c
Fix #2128 by adding missing mapping values. (#2335) 2024-04-26 15:12:42 +08:00
Rot127
6c7b54817f
Add a clang-tidy checks and warnings (#2312) 2024-04-26 15:11:46 +08:00
Shuyi Cheng
c4d0993071
Add eBPF bswap16/32/64 instruction (#2323) 2024-04-23 22:04:37 +08:00
Ced2911
e9284b6b36
check if decode[idx] is callable (#2322) 2024-04-23 21:58:40 +08:00
Florian Märkl
bf05d695dd
Fix cstool Makefile for non-C99-defaulting compilers (#2315) 2024-04-23 21:57:39 +08:00
careworry
16017d5f92
chore: remove repetitive words (#2326)
Signed-off-by: careworry <worrycare@outlook.com>

chore: remove repetitive words
2024-04-22 11:57:11 +08:00
Rot127
7746648f0b
[Auto-Sync] LLVM 18 update (#2296)
Refactor auto-sync updater

This refactors the auto-sync updater scripts, adds multiple tests and some other smaller things:

- Converts the updater in a proper Python package.
- Renaming was done to fit this new package structure.
- Format code with usort and black and enforce it with the CI.
- Add license information to auto-sync scripts.
- Update tree-sitter-cpp to v20.0.5
- Fix py-tree-sitter version to `< 0.22.0` due to https://github.com/tree-sitter/tree-sitter-cpp/issues/250
- Allow file/dir creation of non existing paths.
- Add CI tests for Patch, inc gen, translation and diff persistence testing.
- Implement editing of diffs with an editor.
- Fix: Add Namespace id also to anonymous enumeration members.
2024-04-22 11:55:44 +08:00
Rot127
24d99a907b
Weaken requirements to document functions. (#2324) 2024-04-18 23:51:49 +08:00
R3v0LT
a5cf15e556
HPPA dissassembler fix unitialized variables errors (#2309) 2024-04-10 13:49:43 +08:00
R3v0LT
cda40c6537
Fix invalid comparison with HPPA_OP_INVALID (#2300) 2024-03-29 16:46:00 +08:00
R3v0LT
9daa1ffbac
Add HPPA(PA-RISC) architecture (#2265)
* Refactor HPPA

* Add full HPPA 1.1 instructions support

* Add HPPA 1.1 cs tests

* Fix HPPA dissassembler

* Add HPPA 2.0 instructions

* Add HPPA tests

* Fix HPPA disasm & printer

* Update HPPA tests

* Remove unused code

* Add implicit register access info & Refactor HPPA main files

* Add python bindings/tests and cstests

* Fix HPPA disasm wrong decoding

* Rewrite invalid test cases

* Update HPPA python constants

* Make HPPA python test executable

* Change HPPA python tests sequence to match c tests

* Refactor HPPA main files

* Write target instead of offset in details

* Add HPPA detail function support in cstest

* Rewrite targets in branch tests

* Make correct string modifier addition

* Add hppa test calls

* Add zero operands check

* Remove MCOperand array

* Change immediate values printing

* Add HPPA 2.0 wide support

* Fix invalid break instruction decode

Remove unused code

* Add HPPA to fuzzing tests

* Add HPPA to options

* Add HPPA to docs

* Refactor HPPA

* Fix invalid branch insn decoding

* Add HPPA to labeler

* clang-format hppa files

* Document internal structures and minor refactoring

* Add missing default statements

* Fix invalid default statement
2024-03-26 13:58:56 +08:00
James Kang
0d12bcacd7
Remove repetitive words (#2297) 2024-03-23 19:42:19 +08:00
Yudi Zheng
5d9942d13f
Avoid random access values for operands in not-yet-specified instructions. (#2259) 2024-03-21 13:33:30 +08:00
Wu ChenXu
989dca2a28
Add telegram group link to README.md 2024-03-20 19:20:40 +08:00
Rot127
3ef564bcf4
Add issue and PR templates (#2294)
* Add PR template.

* Add issue templates.
2024-03-20 16:57:52 +08:00
Rot127
b4fde983de
[PPC] Expose instruction formats (#2276)
* Expose PPC formats in PPC details

* Add PPC format note in v6 release guide.

* Update python bindings
2024-02-23 13:20:46 +08:00
Rot127
122348ba47
[CMake] Architecture definition fix (#2272)
* Enble all archs only if CAPSTONE_USE_ARCH_REGISTRATION=false

* Add a test if cstool reaches each disassembler engine.

* Move cstool test to sh file.
2024-02-23 13:20:00 +08:00
Sevan Janiyan
1c238b6491
Makefile: Improve Apple detection (#2263)
* Makefile: Improve Apple detection

__APPLE__ is always defined & set to 1 on Darwin.

* HACK.TXT: wording
2024-02-23 13:18:53 +08:00
Rot127
215eae8e54
Fix incorrect alignment of labels. (#2277) 2024-02-22 11:01:05 +08:00
Rot127
34a1e012b7
Fix OOB read and wries (#2273)
* Fix OOB read due to wrong macro in use.

* Fix OOB write for regs_write and replace hardcoded values.
2024-02-18 13:03:05 +08:00