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

Apple compatibility changes for #2026 + misc. AARCH64 naming cleanups. #1

Closed
wants to merge 372 commits into from
Closed
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
372 commits
Select commit Hold shift + click to select a range
537dce1
Add more typedefs
Rot127 May 26, 2023
9316004
Add features not used by CGIs
Rot127 May 27, 2023
b739700
Add udate InstPrinter.h
Rot127 May 27, 2023
a047f9b
Add header file
Rot127 May 27, 2023
8848cb0
Add decoder arguent
Rot127 May 27, 2023
f81166c
Add Extensions
Rot127 May 27, 2023
a7cb536
Add new system operands.
Rot127 May 28, 2023
4ce3407
Add IMPLICIT_IMM_0
Rot127 May 29, 2023
d49e316
Fix DecodeComplete assignment and passing
Rot127 May 29, 2023
09b6477
Add Linkage header
Rot127 May 29, 2023
3109ad4
Patch register getter via reg class tables.
Rot127 May 29, 2023
c790b6d
Fix namespaces in SystemOPerands.inc
Rot127 May 29, 2023
b9a31f0
Emit comment to mark namespace
Rot127 May 29, 2023
f6ea521
Hand made fixes for AArch64Disassembler.c
Rot127 May 29, 2023
49730b7
Replace C++ syntax in generated file
Rot127 May 30, 2023
6654c29
Add add_cs_detail() to printOperand functions.
Rot127 May 30, 2023
af4fced
Fix inc name
Rot127 May 30, 2023
338be32
Fix passing by ref instead of pointer
Rot127 May 30, 2023
9577cdb
Hand made fixes InstPrinter (undone)
Rot127 May 30, 2023
395ebcc
Fix DeclarationConditionClause
Rot127 May 31, 2023
ecc0c67
Fix getReg/getImm patch to not patch other functions with getReg in name
Rot127 May 31, 2023
9e56b8d
Add Patch for getRegClass
Rot127 May 31, 2023
461a67c
Fix typo
Rot127 May 31, 2023
669ff5d
Add patch for MCRegisterClass.contains()
Rot127 May 31, 2023
12e7b51
Add new concat macro
Rot127 May 31, 2023
2ebed5b
Fix more build errors in InstPrinter.c
Rot127 May 31, 2023
8fd6bb2
Add OpGroup enum.
Rot127 May 31, 2023
6472db4
Make op argument constant
Rot127 May 31, 2023
7b43bb6
Several build errors.
Rot127 May 31, 2023
96e3310
Add default arguments to template functions
Rot127 Jun 3, 2023
adeee7c
Add AArch64 macros
Rot127 Jun 3, 2023
4aed5cd
Set correct group names.
Rot127 Jun 3, 2023
0402d2d
Rename ARM64_INS_ENDING -> AArch64_INS_ENDING
Rot127 Jun 3, 2023
ed6b9fc
Update inc files
Rot127 Jun 3, 2023
4eb2564
Remove duplicate definition
Rot127 Jun 3, 2023
554b34f
Import ccorrect header
Rot127 Jun 3, 2023
bf8dbb0
Increase Max number of data types.
Rot127 Jun 3, 2023
22bc17c
Remove old Mapping code and add new one where needed.
Rot127 Jun 3, 2023
ee6a778
Fix several linking issues.
Rot127 Jun 3, 2023
5bde24e
Add new system operands in groups as defined in LLVM.
Rot127 Jun 3, 2023
54d2e46
Move some core enums to the main header file and fix case style
Rot127 Jun 4, 2023
be2c23e
Add system operand types to op type enum
Rot127 Jun 4, 2023
863a9d6
Rename ARM64 -> AArch64
Rot127 Jun 4, 2023
0fb48cd
Rename ARM64 -> AArch64 in main source files.
Rot127 Jun 4, 2023
9f350bd
Rename ARM64 -> AArch64
Rot127 Jun 4, 2023
dca1bce
Rename cstool_arm64 -> cstool_aarch64
Rot127 Jun 4, 2023
6849943
Rename arm64_detail.c -> aarch64_detail.c
Rot127 Jun 4, 2023
1aa5721
Rename tests/test_arm64.c tests/test_aarch64.c
Rot127 Jun 4, 2023
a925f34
Rename ARM64 -> AArch64
Rot127 Jun 4, 2023
5826dca
Rename ARM64 -> AArch64 in some docs
Rot127 Jun 4, 2023
99766eb
Renaming ARM64 -> AArch64 in cs.c, cstool and test_aarch64
Rot127 Jun 4, 2023
a649257
Rename arm64 -> aarch64 in Mapping.*
Rot127 Jun 4, 2023
aa7a3f0
Rename ast arm64 -> aarch64
Rot127 Jun 4, 2023
11690e2
Update sysop inc file
Rot127 Jun 4, 2023
c76df1a
Fix missing braces warning
Rot127 Jun 4, 2023
b35c87b
Handle new system operands
Rot127 Jun 5, 2023
8a7641c
Fix build errors by renaming.
Rot127 Jun 5, 2023
aa75ae1
Fix segfault
Rot127 Jun 5, 2023
27e09b0
Fix segfault
Rot127 Jun 5, 2023
7a83a10
Add custom MCOperand valiadtors
Rot127 Jun 5, 2023
3aeb484
Add AArch64 case for getFeatureBits
Rot127 Jun 5, 2023
34c6254
Fix infinite loop
Rot127 Jun 5, 2023
0d05064
Fix braces warning.
Rot127 Jun 5, 2023
0aaa68b
Implement loopuo by name for sys operands
Rot127 Jun 5, 2023
7399746
Fix incorrect translation which remove else if statements.
Rot127 Jun 5, 2023
2a06e7c
Fix several segfaults
Rot127 Jun 5, 2023
770f2cf
Rename GetRegFromClass patch
Rot127 Jun 5, 2023
74312ce
Fix segfaults and asserts
Rot127 Jun 5, 2023
5898665
Fix segfault
Rot127 Jun 6, 2023
b3ec98b
Move MRI setting to Mapping
Rot127 Jun 8, 2023
2b8c0c0
Remove unused code
Rot127 Jun 8, 2023
e0559ec
Add add_op_X functinos for AArch64.
Rot127 Jun 10, 2023
ce812ca
Add fill detail functins
Rot127 Jun 14, 2023
7c83aaf
Handle RegWithShiftExtend operands
Rot127 Jun 14, 2023
177f50a
Handle TypedVectorList operands.
Rot127 Jun 14, 2023
0d6b7dc
Handle ComplexRoatation operands
Rot127 Jun 15, 2023
0b40714
Handle MemExtend operands
Rot127 Jun 15, 2023
0e91a13
Handle ImmRangeScale operands
Rot127 Jun 15, 2023
ced2669
Handle ExactFPImm operands
Rot127 Jun 15, 2023
cc04eaa
Handle GPRSeqPairsClass operands
Rot127 Jun 15, 2023
067d03c
Handle Imm8OptLsl operands
Rot127 Jun 15, 2023
8f18e3e
Handle ImmScale operands
Rot127 Jun 15, 2023
ac8fb87
Handle LogicalImm operands
Rot127 Jun 15, 2023
c5b0ce7
Handle Matrix operands
Rot127 Jun 15, 2023
28cfa95
Handle SME Matrix tiles and vectors.
Rot127 Jun 15, 2023
7a52514
Handle normal operands.
Rot127 Jun 15, 2023
6cbf2ef
Fix segfault.
Rot127 Jun 15, 2023
78017c1
Handle PostInc operands.
Rot127 Jun 15, 2023
5d02fce
Reorder VecLayout enum to have no duplicate enum value.
Rot127 Jun 15, 2023
09f2c1d
Handle PredicateAsCounter operands
Rot127 Jun 15, 2023
fb7d08a
Handle ZPRasFPR operands
Rot127 Jun 16, 2023
4ba3572
Handle VectorIndex operands
Rot127 Jun 16, 2023
8ef8f7f
Handle UImm12Offset operands.
Rot127 Jun 16, 2023
dfc46b7
Move reg suffix to enum val to single function.
Rot127 Jun 16, 2023
fe15ddf
Handle SVERegOp operands
Rot127 Jun 16, 2023
331e6c3
Handle SVELogicalImm operands
Rot127 Jun 16, 2023
d792681
Handle SImm operand
Rot127 Jun 16, 2023
2bd33b4
Handle PrefetchOp operands
Rot127 Jun 16, 2023
5c11c97
Handle Imm and ImmHex operands
Rot127 Jun 17, 2023
f208261
Handle GPR64as32 and GPR64x8 operands
Rot127 Jun 17, 2023
31f92cb
Add missing break
Rot127 Jun 17, 2023
261b37c
Handle FPImm operand
Rot127 Jun 17, 2023
05d3b9a
Handle ExtendedRegister opreand
Rot127 Jun 17, 2023
3603925
Handle CondCode operands
Rot127 Jun 17, 2023
168ce4b
Handle BTIHintOp operands
Rot127 Jun 17, 2023
78ebe98
Handle BarrierOption operands
Rot127 Jun 17, 2023
79db515
Handle BarrierXSOption
Rot127 Jun 17, 2023
d8328f1
Add not implemeted case again
Rot127 Jun 17, 2023
ab6104c
Handle ArithExtend operands
Rot127 Jun 17, 2023
893dffb
Handle AdrpLabel and AlignedLabel operands
Rot127 Jun 17, 2023
7d93ec6
Handle AMNoIndex operands
Rot127 Jun 17, 2023
c1cfe58
Handle AddSubImm operands
Rot127 Jun 17, 2023
8cd10e1
Handle MSRSystemRegisters and MRSSystemRegister operands
Rot127 Jun 17, 2023
203fe23
Handle PSBHntOp and RPRFMOperand operands
Rot127 Jun 17, 2023
ea1db73
Remove unused variables
Rot127 Jun 18, 2023
c460ce4
Handle InverseCondCode operands
Rot127 Jun 18, 2023
1c5b259
Handle ImplicityTypedVectorList operands
Rot127 Jun 18, 2023
93b4a8d
Handle ShiftedRegister operands
Rot127 Jun 18, 2023
8bee68c
Handle Shifter operands
Rot127 Jun 18, 2023
623f515
Handle SIMDType10Operand operands
Rot127 Jun 18, 2023
1b3a6e5
Handle SVCROp operands
Rot127 Jun 18, 2023
0edf72a
Handle SVEPattern operands
Rot127 Jun 18, 2023
b267a62
Handle SVEVecLenSpecifier operands
Rot127 Jun 18, 2023
2077653
Handle SysCROperands
Rot127 Jun 18, 2023
75a1f31
Handle SysXzrPair operands
Rot127 Jun 18, 2023
0893984
Handle PState operands
Rot127 Jun 18, 2023
7ec42fd
Handle VRegOperands
Rot127 Jun 18, 2023
d645adb
Primt SME oeprands.
Rot127 Jun 21, 2023
48c59be
Fix cs_operand.h include
Rot127 Aug 5, 2023
030dd40
Rename arm64 -> aarch64 in python bindings.
Rot127 Aug 5, 2023
8d7906d
Add Python bindings for SH
peace-maker Jul 13, 2023
d8ccfd6
Fix ARM Python bindings (#2127)
peace-maker Jul 29, 2023
dfbd792
Restructure auto-sync update scripts.
Rot127 Aug 5, 2023
f4c769b
Move Helper functions to Updater dir
Rot127 Aug 5, 2023
50a224a
Move requirements.txt
Rot127 Aug 5, 2023
e4f68e9
Add basic ASUpdater.py
Rot127 Aug 5, 2023
e7f67a1
Run black.
Rot127 Aug 5, 2023
8f29f68
Add inc file generater to updater
Rot127 Aug 5, 2023
a0028bc
Add option to select certain inc files fore generation.
Rot127 Aug 5, 2023
57bf13e
Enable clean build and implement patcher for inc files.
Rot127 Aug 7, 2023
161b2f5
Format config
Rot127 Aug 7, 2023
b9f1519
Patch main header files after inc generation.
Rot127 Aug 7, 2023
7607b96
Implement clang-format function (unused yet, because it takes forever.)
Rot127 Aug 7, 2023
5de5a4e
Copy generated inc files to arch dir
Rot127 Aug 7, 2023
31fa88f
Invert clean option (noramlly we need to clean the build dir.)
Rot127 Aug 7, 2023
2036491
Clearify arg doc
Rot127 Aug 7, 2023
5031c0e
Rename SystemRegister file for AArch64
Rot127 Aug 7, 2023
07b9636
Centralize handling of path variables.
Rot127 Aug 7, 2023
b1e7a9e
Check if SystemOperands had to be generated before renaming on of its…
Rot127 Aug 7, 2023
d959d43
Replace class parameters by calling get_path
Rot127 Aug 7, 2023
f8f448f
Remove updater config which only contained paths.
Rot127 Aug 7, 2023
64e6c52
Add refactor option.
Rot127 Aug 7, 2023
b35c723
Remove more path handling in the Configurator.
Rot127 Aug 7, 2023
32649ec
Add translation step to updater.
Rot127 Aug 7, 2023
fd7c67f
Fix includes after CppTranslator was moved into the Updater
Rot127 Aug 7, 2023
db6b8da
Remove updater config
Rot127 Aug 7, 2023
a32a8e3
Fix several issue in the Configurator
Rot127 Aug 7, 2023
fa99d55
Fix file operations
Rot127 Aug 7, 2023
9a13d44
Remove addition argument from translator.
Rot127 Aug 7, 2023
b7a9743
Add Differ step to updater.
Rot127 Aug 7, 2023
430cbbd
Add path variable for arch_config
Rot127 Aug 7, 2023
f1383b5
Add diff step.
Rot127 Aug 7, 2023
8e5b51b
Fix typo
Rot127 Aug 7, 2023
96150c6
Introduce .clang-format path variable.
Rot127 Aug 7, 2023
0943e4c
Remove duplicate functions
Rot127 Aug 7, 2023
fa020e2
Add option to select update steps to execute.
Rot127 Aug 7, 2023
af668dd
Check in write functions for write flag.
Rot127 Aug 7, 2023
0b3d330
Rename PatchMainHeader -> HeaderPatcher
Rot127 Aug 7, 2023
26b2624
Move .gitignore
Rot127 Aug 7, 2023
789fa21
Add README to vendor dir.
Rot127 Aug 7, 2023
f7aa7fc
Add all system operands to cstool output
Rot127 Aug 10, 2023
9016878
Update cstest with aarch64 changes
Rot127 Aug 10, 2023
44c79c5
Remove wb flag of aarch64 detail struct
Rot127 Aug 10, 2023
28b4daf
Set updates_flag after decoding
Rot127 Aug 10, 2023
72b0467
Set writeback after decoding.
Rot127 Aug 10, 2023
b336653
Rename ARM64 -> AArch64
Rot127 Aug 10, 2023
82a307e
Update printer and op mapping
Rot127 Aug 11, 2023
b0e0ea5
Exit normally
Rot127 Aug 11, 2023
65b77d3
Add AArch64 alias
Rot127 Aug 11, 2023
94b357f
Fix some tmeplate function calls
Rot127 Aug 11, 2023
7bbebd4
Fix flag check after rebase.
Rot127 Aug 11, 2023
daf9d88
Fix build by commentig unnused code.
Rot127 Aug 11, 2023
c87010c
Add memory operand flag
Rot127 Aug 21, 2023
d45e714
Handle memory operands printed via generic printOperand function.
Rot127 Aug 21, 2023
7add1dd
Handle UImm memory offsets
Rot127 Aug 21, 2023
a356145
Introduce MEM_REG and MEM_IMM op types
Rot127 Aug 21, 2023
4397c78
Handle scaled memory immediates
Rot127 Aug 21, 2023
3ae75e1
Check for op_count before checking for mem op at -1 index.
Rot127 Aug 21, 2023
e4b9a4d
Update memory operand flags.
Rot127 Aug 21, 2023
9bcee66
Pass imm/reg memory ops in set_imm/reg to set_mem.
Rot127 Aug 21, 2023
b6ae3b9
Add missing set_sme_operand call and fix assert.
Rot127 Aug 21, 2023
1d255a2
Remove CS_OP_MEM flag before entering switch.
Rot127 Aug 21, 2023
3ed2b6d
Preidcates are registers.
Rot127 Aug 21, 2023
c598ec6
Add shift info always to the previous operand
Rot127 Aug 21, 2023
05d2c4d
Check for generic system regs
Rot127 Aug 22, 2023
d879a3f
Handle NumLanes = 0 LaneKind = q case
Rot127 Aug 22, 2023
5f9eabe
Replace printImm call with normal print logic. Otherwise ops get adde…
Rot127 Aug 22, 2023
f45ccc9
Handle FP operands in printOperand.
Rot127 Aug 22, 2023
c4384fd
Add access information to float operands.
Rot127 Aug 22, 2023
194b2c8
Rewrite SME matrix handling.
Rot127 Aug 22, 2023
f4fce50
Set correct SME layouts and allow for immediate range sme offsets.
Rot127 Aug 22, 2023
1fd8e20
Handle cases of unknown system alias by setting their raw values
Rot127 Aug 22, 2023
0b45e7d
Update cstool and header file with new SME offset handling
Rot127 Aug 22, 2023
9c6f2c4
Handle SME Tile lists.
Rot127 Aug 22, 2023
a9325d2
Fix build error in cstest
Rot127 Aug 22, 2023
c947dd7
Update MC tests for AArch64
Rot127 Aug 23, 2023
e20698b
Handle TLBI operands and fix printing bug.
Rot127 Aug 23, 2023
45e13fd
Fix: Print signed value as signed.
Rot127 Aug 23, 2023
48855f6
Add more system alias to detail.
Rot127 Aug 23, 2023
7fc3c1c
Remove duplicate hex prefix
Rot127 Aug 23, 2023
ef3403f
Set correct values for the register info
Rot127 Aug 23, 2023
3380fb2
Replace tabs with white spaces
Rot127 Aug 24, 2023
3f4fb6b
Move string append logic to own function.
Rot127 Aug 24, 2023
48479d3
Set DecodeComplete = true before decoding (as originally in the LLVM …
Rot127 Aug 24, 2023
200cc87
Change type of feature argument, since only LLVM features are passed,…
Rot127 Aug 24, 2023
8cc3e35
Imitate lower_bound for the index table binary search.
Rot127 Aug 24, 2023
b9e7c48
Remove trailing comments from test files.
Rot127 Aug 24, 2023
791f0e9
Print shift amount in decimal
Rot127 Aug 24, 2023
d584ff6
Save detail of shift alias instructions.
Rot127 Aug 24, 2023
f0107f3
Add extension details fot ext instruction alias
Rot127 Aug 24, 2023
7eb4684
Print LSB and width in decimal
Rot127 Aug 24, 2023
42e9dec
Fix LLVM bug. The feature check for V8_2a doesn't check if all featur…
Rot127 Aug 24, 2023
9bb4061
Fix lower_bounds check.
Rot127 Aug 24, 2023
e16b2b5
Fix feature check. Add check for FeatureAll since it includes XS
Rot127 Aug 24, 2023
d6299bc
Operate on temporary MCInst when trying decoding.
Rot127 Aug 24, 2023
4670f2a
Add lower_bound behavior to IndexTypeStr binsearch.
Rot127 Aug 24, 2023
b7daba3
Fix MC tests which were incorrect because of missing FeatureAll check
Rot127 Aug 24, 2023
fd9e007
Add Alias handling for AArch64
Rot127 Aug 25, 2023
70eace0
Update system operands with SYSIMM types and add additional sysop cat…
Rot127 Aug 25, 2023
0f4161d
Add macros for meta programming (ARM64 <-> AArch64 selection).
Rot127 Aug 26, 2023
e86533c
Fix union/struct confusion and add raw_value member to uninions.
Rot127 Aug 26, 2023
532be95
Allow to set Syntax and mode options for AArch64
Rot127 Aug 26, 2023
4910edc
Fix build warning by using correct type
Rot127 Aug 26, 2023
6bfd8d1
Print shift value in decimal
Rot127 Aug 26, 2023
f5536d2
Add missing call to add_cs_detail.
Rot127 Aug 26, 2023
e2bf0b5
Update name map files with normalized names.
Rot127 Aug 27, 2023
0449576
Remove unused function
Rot127 Aug 27, 2023
d6f7a0a
Add check if detail should be filled.
Rot127 Aug 27, 2023
12c5e8f
Fill detail for real instructions if only real detail is requested.
Rot127 Aug 27, 2023
eaf4c01
Add always the extension.
Rot127 Aug 27, 2023
3a650e7
apple linker wants `add_cs_detail` visibility
watbulb Aug 28, 2023
af65399
add AARCH64 to `cmake.sh`
watbulb Aug 28, 2023
282ba22
add HAS_AARCH64 to `cs.c`
watbulb Aug 28, 2023
d13e0d5
should probably just reference `cs_operand.h` in `aarch64.h`
watbulb Aug 28, 2023
67138da
hint compiler at `AArch64_SYSREG` enum type for casting purposes
watbulb Aug 28, 2023
56d4fc1
update `Makefile` for AARCH64
watbulb Aug 28, 2023
a69767b
`testFeatureBits` platform function check
watbulb Aug 28, 2023
58fff88
update tests to use AARCH64 convention
watbulb Aug 28, 2023
9b26555
hack: avoid enum casts for `MCInst` Values
watbulb Aug 28, 2023
83c3a62
bugfix: dont assume clang arch select args if not on darwin/apple
watbulb Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
52 changes: 28 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ option(CAPSTONE_ARCHITECTURE_DEFAULT "Whether architectures are enabled by defau
option(CAPSTONE_DEBUG "Whether to enable extra debug assertions" OFF)
option(CAPSTONE_INSTALL "Generate install target" ${PROJECT_IS_TOP_LEVEL})

set(SUPPORTED_ARCHITECTURES ARM ARM64 M68K MIPS PPC SPARC SYSZ XCORE X86 TMS320C64X M680X EVM MOS65XX WASM BPF RISCV SH TRICORE)
set(SUPPORTED_ARCHITECTURE_LABELS ARM ARM64 M68K MIPS PowerPC Sparc SystemZ XCore x86 TMS320C64x M680x EVM MOS65XX WASM BPF RISCV SH TriCore)
set(SUPPORTED_ARCHITECTURES ARM AARCH64 M68K MIPS PPC SPARC SYSZ XCORE X86 TMS320C64X M680X EVM MOS65XX WASM BPF RISCV SH TRICORE)
set(SUPPORTED_ARCHITECTURE_LABELS ARM AARCH64 M68K MIPS PowerPC Sparc SystemZ XCore x86 TMS320C64x M680x EVM MOS65XX WASM BPF RISCV SH TriCore)

list(LENGTH SUPPORTED_ARCHITECTURES count)
math(EXPR count "${count}-1")
Expand Down Expand Up @@ -123,7 +123,7 @@ set(HEADERS_ENGINE
)

set(HEADERS_COMMON
include/capstone/arm64.h
include/capstone/aarch64.h
include/capstone/arm.h
include/capstone/capstone.h
include/capstone/cs_operand.h
Expand Down Expand Up @@ -181,35 +181,35 @@ if(CAPSTONE_ARM_SUPPORT)
set(TEST_SOURCES ${TEST_SOURCES} test_arm.c)
endif()

if(CAPSTONE_ARM64_SUPPORT)
add_definitions(-DCAPSTONE_HAS_ARM64)
set(SOURCES_ARM64
if(CAPSTONE_AARCH64_SUPPORT)
add_definitions(-DCAPSTONE_HAS_AARCH64)
set(SOURCES_AARCH64
arch/AArch64/AArch64BaseInfo.c
arch/AArch64/AArch64Disassembler.c
arch/AArch64/AArch64DisassemblerExtension.c
arch/AArch64/AArch64InstPrinter.c
arch/AArch64/AArch64Mapping.c
arch/AArch64/AArch64Module.c
)
set(HEADERS_ARM64
set(HEADERS_AARCH64
arch/AArch64/AArch64AddressingModes.h
arch/AArch64/AArch64BaseInfo.h
arch/AArch64/AArch64Disassembler.h
arch/AArch64/AArch64DisassemblerExtension.h
arch/AArch64/AArch64InstPrinter.h
arch/AArch64/AArch64Linkage.h
arch/AArch64/AArch64Mapping.h
arch/AArch64/AArch64GenAsmWriter.inc
arch/AArch64/AArch64GenDisassemblerTables.inc
arch/AArch64/AArch64GenInstrInfo.inc
arch/AArch64/AArch64GenRegisterInfo.inc
arch/AArch64/AArch64GenRegisterName.inc
arch/AArch64/AArch64GenRegisterV.inc
arch/AArch64/AArch64GenSubtargetInfo.inc
arch/AArch64/AArch64GenSystemOperands.inc
arch/AArch64/AArch64GenSystemOperands_enum.inc
arch/AArch64/AArch64MappingInsn.inc
arch/AArch64/AArch64MappingInsnName.inc
arch/AArch64/AArch64MappingInsnOp.inc
arch/AArch64/AArch64GenCSMappingInsn.inc
arch/AArch64/AArch64GenCSMappingInsnName.inc
arch/AArch64/AArch64GenCSMappingInsnOp.inc
)
set(TEST_SOURCES ${TEST_SOURCES} test_arm64.c)
set(TEST_SOURCES ${TEST_SOURCES} test_aarch64.c)
endif()

if(CAPSTONE_MIPS_SUPPORT)
Expand Down Expand Up @@ -253,19 +253,23 @@ if(CAPSTONE_PPC_SUPPORT)
arch/PowerPC/PPCModule.c
)
set(HEADERS_PPC
arch/PowerPC/PPCDisassembler.h
arch/PowerPC/PPCGenAsmWriter.inc
arch/PowerPC/PPCInstrInfo.h
arch/PowerPC/PPCInstPrinter.h
arch/PowerPC/PPCLinkage.h
arch/PowerPC/PPCMapping.h
arch/PowerPC/PPCMCTargetDesc.h
arch/PowerPC/PPCPredicates.h
arch/PowerPC/PPCRegisterInfo.h
arch/PowerPC/PPCGenAsmWriter.inc
arch/PowerPC/PPCGenRegisterName.inc
arch/PowerPC/PPCGenCSFeatureName.inc
arch/PowerPC/PPCGenCSMappingInsn.inc
arch/PowerPC/PPCGenCSMappingInsnOp.inc
arch/PowerPC/PPCGenCSMappingInsnName.inc
arch/PowerPC/PPCGenCSOpGroup.inc
arch/PowerPC/PPCGenDisassemblerTables.inc
arch/PowerPC/PPCMappingInsn.inc
arch/PowerPC/PPCMappingInsnName.inc
arch/PowerPC/PPCGenInstrInfo.inc
arch/PowerPC/PPCGenSubtargetInfo.inc
arch/PowerPC/PPCGenRegisterInfo.inc
arch/PowerPC/PPCGenInstrInfo.inc
)
set(TEST_SOURCES ${TEST_SOURCES} test_ppc.c)
endif()
Expand Down Expand Up @@ -572,7 +576,7 @@ endif()
set(ALL_SOURCES
${SOURCES_ENGINE}
${SOURCES_ARM}
${SOURCES_ARM64}
${SOURCES_AARCH64}
${SOURCES_MIPS}
${SOURCES_PPC}
${SOURCES_X86}
Expand All @@ -595,7 +599,7 @@ set(ALL_HEADERS
${HEADERS_COMMON}
${HEADERS_ENGINE}
${HEADERS_ARM}
${HEADERS_ARM64}
${HEADERS_AARCH64}
${HEADERS_MIPS}
${HEADERS_PPC}
${HEADERS_X86}
Expand Down Expand Up @@ -658,7 +662,7 @@ endif()

source_group("Source\\Engine" FILES ${SOURCES_ENGINE})
source_group("Source\\ARM" FILES ${SOURCES_ARM})
source_group("Source\\ARM64" FILES ${SOURCES_ARM64})
source_group("Source\\AARCH64" FILES ${SOURCES_AARCH64})
source_group("Source\\Mips" FILES ${SOURCES_MIPS})
source_group("Source\\PowerPC" FILES ${SOURCES_PPC})
source_group("Source\\Sparc" FILES ${SOURCES_SPARC})
Expand All @@ -679,7 +683,7 @@ source_group("Source\\TriCore" FILES ${SOURCES_TRICORE})
source_group("Include\\Common" FILES ${HEADERS_COMMON})
source_group("Include\\Engine" FILES ${HEADERS_ENGINE})
source_group("Include\\ARM" FILES ${HEADERS_ARM})
source_group("Include\\ARM64" FILES ${HEADERS_ARM64})
source_group("Include\\AARCH64" FILES ${HEADERS_AARCH64})
source_group("Include\\Mips" FILES ${HEADERS_MIPS})
source_group("Include\\PowerPC" FILES ${HEADERS_PPC})
source_group("Include\\Sparc" FILES ${HEADERS_SPARC})
Expand Down
2 changes: 1 addition & 1 deletion COMPILE.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Capstone requires no prerequisite packages, so it is easy to compile & install.
(5) Cross-compile for Android

To cross-compile for Android (smartphone/tablet), Android NDK is required.
NOTE: Only ARM and ARM64 are currently supported.
NOTE: Only ARM and AARCH64 are currently supported.

$ NDK=/android/android-ndk-r10e ./make.sh cross-android arm
or
Expand Down
4 changes: 2 additions & 2 deletions COMPILE_CMAKE.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Get CMake for free from http://www.cmake.org.
run "cmake" with the unwanted archs disabled (set to 0) as followings.

- CAPSTONE_ARM_SUPPORT: support ARM. Run cmake with -DCAPSTONE_ARM_SUPPORT=0 to remove ARM.
- CAPSTONE_ARM64_SUPPORT: support ARM64. Run cmake with -DCAPSTONE_ARM64_SUPPORT=0 to remove ARM64.
- CAPSTONE_AARCH64_SUPPORT: support AARCH64. Run cmake with -DCAPSTONE_AARCH64_SUPPORT=0 to remove AARCH64.
- CAPSTONE_M680X_SUPPORT: support M680X. Run cmake with -DCAPSTONE_M680X_SUPPORT=0 to remove M680X.
- CAPSTONE_M68K_SUPPORT: support M68K. Run cmake with -DCAPSTONE_M68K_SUPPORT=0 to remove M68K.
- CAPSTONE_MIPS_SUPPORT: support Mips. Run cmake with -DCAPSTONE_MIPS_SUPPORT=0 to remove Mips.
Expand Down Expand Up @@ -112,7 +112,7 @@ Get CMake for free from http://www.cmake.org.
../cmake.sh x86

Will just target the x86 architecture. The list of available architectures is: ARM,
ARM64, M68K, MIPS, PowerPC, Sparc, SystemZ, XCore, x86, TMS320C64x, M680x, EVM, MOS65XX,
AARCH64, M68K, MIPS, PowerPC, Sparc, SystemZ, XCore, x86, TMS320C64x, M680x, EVM, MOS65XX,
WASM, BPF, RISCV.

(4) You can also create an installation image with cmake, by using the 'install' target.
Expand Down
2 changes: 1 addition & 1 deletion COMPILE_MSVC.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ versions, and Windows Driver Kit 8.1 Update 1 or newer versions are required.
to customize Capstone library, as followings.

- CAPSTONE_HAS_ARM: support ARM. Delete this to remove ARM support.
- CAPSTONE_HAS_ARM64: support ARM64. Delete this to remove ARM64 support.
- CAPSTONE_HAS_AARCH64: support AARCH64. Delete this to remove AARCH64 support.
- CAPSTONE_HAS_M68K: support M68K. Delete this to remove M68K support.
- CAPSTONE_HAS_MIPS: support Mips. Delete this to remove Mips support.
- CAPSTONE_HAS_POWERPC: support PPC. Delete this to remove PPC support.
Expand Down
2 changes: 1 addition & 1 deletion HACK.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Capstone source is organized as followings.

. <- core engine + README + COMPILE.TXT etc
├── arch <- code handling disasm engine for each arch
│   ├── AArch64 <- ARM64 (aka ARMv8) engine
│   ├── AArch64 <- AArch64 engine
│   ├── ARM <- ARM engine
│   ├── BPF <- Berkeley Packet Filter engine
│   ├── EVM <- Ethereum engine
Expand Down
21 changes: 20 additions & 1 deletion MCInst.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ void MCInst_Init(MCInst *inst)
inst->xAcquireRelease = 0;
for (int i = 0; i < MAX_MC_OPS; ++i)
inst->tied_op_idx[i] = -1;
inst->isAliasInstr = false;
inst->fillDetailOps = false;
}

void MCInst_clear(MCInst *inst)
Expand Down Expand Up @@ -142,7 +144,7 @@ void MCOperand_setReg(MCOperand *op, unsigned Reg)
op->RegVal = Reg;
}

int64_t MCOperand_getImm(MCOperand *op)
int64_t MCOperand_getImm(const MCOperand *op)
{
return op->ImmVal;
}
Expand Down Expand Up @@ -280,3 +282,20 @@ uint64_t MCInst_getOpVal(MCInst *MI, unsigned OpNum)
else
assert(0 && "Operand type not handled in this getter.");
}

void MCInst_setIsAlias(MCInst *MI, bool Flag) {
assert(MI);
MI->isAliasInstr = Flag;
MI->flat_insn->is_alias = Flag;
}

/// @brief Copies the relevant members of a temporary MCInst to
/// the main MCInst. This is used if TryDecode was run on a temporary MCInst.
/// @param MI The main MCInst
/// @param TmpMI The temporary MCInst.
void MCInst_updateWithTmpMI(MCInst *MI, MCInst *TmpMI) {
MI->size = TmpMI->size;
MI->Opcode = TmpMI->Opcode;
assert(MI->size < MAX_MC_OPS);
memcpy(MI->Operands, TmpMI->Operands, sizeof(MI->Operands[0]) * MI->size);
}
12 changes: 11 additions & 1 deletion MCInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ unsigned MCOperand_getReg(const MCOperand *op);
/// setReg - Set the register number.
void MCOperand_setReg(MCOperand *op, unsigned Reg);

int64_t MCOperand_getImm(MCOperand *op);
int64_t MCOperand_getImm(const MCOperand *op);

void MCOperand_setImm(MCOperand *op, int64_t Val);

Expand Down Expand Up @@ -129,6 +129,8 @@ struct MCInst {
cs_wasm_op wasm_data; // for WASM operand
MCRegisterInfo *MRI;
uint8_t xAcquireRelease; // X86 xacquire/xrelease
bool isAliasInstr; // Flag if this MCInst is an alias.
bool fillDetailOps; // If set, detail->operands gets filled.
};

void MCInst_Init(MCInst *inst);
Expand Down Expand Up @@ -163,4 +165,12 @@ bool MCInst_opIsTying(const MCInst *MI, unsigned OpNum);

uint64_t MCInst_getOpVal(MCInst *MI, unsigned OpNum);

void MCInst_setIsAlias(MCInst *MI, bool Flag);

static inline bool MCInst_isAlias(const MCInst *MI) {
return MI->isAliasInstr;
}

void MCInst_updateWithTmpMI(MCInst *MI, MCInst *TmpMI);

#endif
22 changes: 22 additions & 0 deletions MCInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@
#include <capstone/platform.h>

extern bool ARM_getFeatureBits(unsigned int mode, unsigned int feature);
extern bool PPC_getFeatureBits(unsigned int mode, unsigned int feature);
extern bool AArch64_getFeatureBits(unsigned int mode, unsigned int feature);

static bool testFeatureBits(const MCInst *MI, uint32_t Value)
{
assert(MI && MI->csh);
switch (MI->csh->arch) {
default:
assert(0 && "Not implemented for current arch.");
#ifdef CAPSTONE_HAS_ARM
case CS_ARCH_ARM:
return ARM_getFeatureBits(MI->csh->mode, Value);
#endif
#ifdef CAPSTONE_HAS_PPC
case CS_ARCH_PPC:
return PPC_getFeatureBits(MI->csh->mode, Value);
#endif
#ifdef CAPSTONE_HAS_AARCH64
case CS_ARCH_AARCH64:
return AArch64_getFeatureBits(MI->csh->mode, Value);
#endif
}
}

Expand Down Expand Up @@ -180,6 +192,11 @@ unsigned int binsearch_IndexTypeEncoding(const struct IndexType *index, size_t s
while(left <= right) {
m = (left + right) / 2;
if (encoding == index[m].encoding) {
// LLVM actually uses lower_bound for the index table search
// Here we need to check if a previous entry is of the same encoding
// and return the first one.
while (m > 0 && encoding == index[m - 1].encoding)
--m;
return m;
}

Expand Down Expand Up @@ -213,6 +230,11 @@ unsigned int binsearch_IndexTypeStrEncoding(const struct IndexTypeStr *index, si
while(left <= right) {
m = (left + right) / 2;
if (strcmp(name, index[m].name) == 0) {
// LLVM actually uses lower_bound for the index table search
// Here we need to check if a previous entry is of the same encoding
// and return the first one.
while (m > 0 && (strcmp(name, index[m - 1].name) == 0))
--m;
return m;
}

Expand Down
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ ifneq (,$(findstring arm,$(CAPSTONE_ARCHS)))
LIBOBJ_ARM += $(LIBSRC_ARM:%.c=$(OBJDIR)/%.o)
endif

DEP_ARM64 =
DEP_ARM64 += $(wildcard arch/AArch64/AArch64*.inc)
DEP_AARCH64 =
DEP_AARCH64 += $(wildcard arch/AArch64/AArch64*.inc)

LIBOBJ_ARM64 =
LIBOBJ_AARCH64 =
ifneq (,$(findstring aarch64,$(CAPSTONE_ARCHS)))
CFLAGS += -DCAPSTONE_HAS_ARM64
LIBSRC_ARM64 += $(wildcard arch/AArch64/AArch64*.c)
LIBOBJ_ARM64 += $(LIBSRC_ARM64:%.c=$(OBJDIR)/%.o)
CFLAGS += -DCAPSTONE_HAS_AARCH64
LIBSRC_AARCH64 += $(wildcard arch/AArch64/AArch64*.c)
LIBOBJ_AARCH64 += $(LIBSRC_AARCH64:%.c=$(OBJDIR)/%.o)
endif


Expand Down Expand Up @@ -327,7 +328,7 @@ endif

LIBOBJ =
LIBOBJ += $(OBJDIR)/cs.o $(OBJDIR)/utils.o $(OBJDIR)/SStream.o $(OBJDIR)/MCInstrDesc.o $(OBJDIR)/MCRegisterInfo.o $(OBJDIR)/MCInst.o $(OBJDIR)/MCInstPrinter.o $(OBJDIR)/Mapping.o
LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_ARM64) $(LIBOBJ_M68K) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_RISCV) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ) $(LIBOBJ_SH)
LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_AARCH64) $(LIBOBJ_M68K) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_RISCV) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ) $(LIBOBJ_SH)
LIBOBJ += $(LIBOBJ_X86) $(LIBOBJ_XCORE) $(LIBOBJ_TMS320C64X) $(LIBOBJ_M680X) $(LIBOBJ_EVM) $(LIBOBJ_MOS65XX) $(LIBOBJ_WASM) $(LIBOBJ_BPF)
LIBOBJ += $(LIBOBJ_TRICORE)

Expand Down Expand Up @@ -448,7 +449,7 @@ endif
$(LIBOBJ): config.mk

$(LIBOBJ_ARM): $(DEP_ARM)
$(LIBOBJ_ARM64): $(DEP_ARM64)
$(LIBOBJ_AARCH64): $(DEP_AARCH64)
$(LIBOBJ_M68K): $(DEP_M68K)
$(LIBOBJ_MIPS): $(DEP_MIPS)
$(LIBOBJ_PPC): $(DEP_PPC)
Expand Down
Loading
Loading