hexcore-capstone 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +26 -0
- package/README.md +191 -0
- package/binding.gyp +168 -0
- package/deps/capstone/LEB128.h +38 -0
- package/deps/capstone/MCDisassembler.h +14 -0
- package/deps/capstone/MCFixedLenDisassembler.h +32 -0
- package/deps/capstone/MCInst.c +270 -0
- package/deps/capstone/MCInst.h +165 -0
- package/deps/capstone/MCInstrDesc.c +41 -0
- package/deps/capstone/MCInstrDesc.h +167 -0
- package/deps/capstone/MCRegisterInfo.c +151 -0
- package/deps/capstone/MCRegisterInfo.h +116 -0
- package/deps/capstone/Mapping.c +254 -0
- package/deps/capstone/Mapping.h +174 -0
- package/deps/capstone/MathExtras.h +442 -0
- package/deps/capstone/SStream.c +181 -0
- package/deps/capstone/SStream.h +40 -0
- package/deps/capstone/arch/AArch64/AArch64AddressingModes.h +945 -0
- package/deps/capstone/arch/AArch64/AArch64BaseInfo.c +77 -0
- package/deps/capstone/arch/AArch64/AArch64BaseInfo.h +585 -0
- package/deps/capstone/arch/AArch64/AArch64Disassembler.c +2280 -0
- package/deps/capstone/arch/AArch64/AArch64Disassembler.h +18 -0
- package/deps/capstone/arch/AArch64/AArch64GenAsmWriter.inc +26589 -0
- package/deps/capstone/arch/AArch64/AArch64GenDisassemblerTables.inc +27322 -0
- package/deps/capstone/arch/AArch64/AArch64GenInstrInfo.inc +13194 -0
- package/deps/capstone/arch/AArch64/AArch64GenRegisterInfo.inc +3814 -0
- package/deps/capstone/arch/AArch64/AArch64GenRegisterName.inc +714 -0
- package/deps/capstone/arch/AArch64/AArch64GenRegisterV.inc +673 -0
- package/deps/capstone/arch/AArch64/AArch64GenSubtargetInfo.inc +229 -0
- package/deps/capstone/arch/AArch64/AArch64GenSystemOperands.inc +2863 -0
- package/deps/capstone/arch/AArch64/AArch64GenSystemOperands_enum.inc +21 -0
- package/deps/capstone/arch/AArch64/AArch64InstPrinter.c +3029 -0
- package/deps/capstone/arch/AArch64/AArch64InstPrinter.h +28 -0
- package/deps/capstone/arch/AArch64/AArch64Mapping.c +883 -0
- package/deps/capstone/arch/AArch64/AArch64Mapping.h +43 -0
- package/deps/capstone/arch/AArch64/AArch64MappingInsn.inc +37790 -0
- package/deps/capstone/arch/AArch64/AArch64MappingInsnName.inc +1282 -0
- package/deps/capstone/arch/AArch64/AArch64MappingInsnOp.inc +26994 -0
- package/deps/capstone/arch/AArch64/AArch64Module.c +44 -0
- package/deps/capstone/arch/AArch64/AArch64Module.h +12 -0
- package/deps/capstone/arch/ARM/ARMAddressingModes.h +698 -0
- package/deps/capstone/arch/ARM/ARMBaseInfo.h +486 -0
- package/deps/capstone/arch/ARM/ARMDisassembler.c +5763 -0
- package/deps/capstone/arch/ARM/ARMDisassembler.h +18 -0
- package/deps/capstone/arch/ARM/ARMGenAsmWriter.inc +9545 -0
- package/deps/capstone/arch/ARM/ARMGenDisassemblerTables.inc +15185 -0
- package/deps/capstone/arch/ARM/ARMGenInstrInfo.inc +6632 -0
- package/deps/capstone/arch/ARM/ARMGenRegisterInfo.inc +2102 -0
- package/deps/capstone/arch/ARM/ARMGenRegisterName.inc +231 -0
- package/deps/capstone/arch/ARM/ARMGenRegisterName_digit.inc +231 -0
- package/deps/capstone/arch/ARM/ARMGenSubtargetInfo.inc +162 -0
- package/deps/capstone/arch/ARM/ARMGenSystemRegister.inc +270 -0
- package/deps/capstone/arch/ARM/ARMInstPrinter.c +3364 -0
- package/deps/capstone/arch/ARM/ARMInstPrinter.h +43 -0
- package/deps/capstone/arch/ARM/ARMMapping.c +551 -0
- package/deps/capstone/arch/ARM/ARMMapping.h +40 -0
- package/deps/capstone/arch/ARM/ARMMappingInsn.inc +18772 -0
- package/deps/capstone/arch/ARM/ARMMappingInsnName.inc +475 -0
- package/deps/capstone/arch/ARM/ARMMappingInsnOp.inc +10729 -0
- package/deps/capstone/arch/ARM/ARMModule.c +63 -0
- package/deps/capstone/arch/ARM/ARMModule.h +12 -0
- package/deps/capstone/arch/BPF/BPFConstants.h +88 -0
- package/deps/capstone/arch/BPF/BPFDisassembler.c +464 -0
- package/deps/capstone/arch/BPF/BPFDisassembler.h +27 -0
- package/deps/capstone/arch/BPF/BPFInstPrinter.c +285 -0
- package/deps/capstone/arch/BPF/BPFInstPrinter.h +16 -0
- package/deps/capstone/arch/BPF/BPFMapping.c +513 -0
- package/deps/capstone/arch/BPF/BPFMapping.h +21 -0
- package/deps/capstone/arch/BPF/BPFModule.c +34 -0
- package/deps/capstone/arch/BPF/BPFModule.h +12 -0
- package/deps/capstone/arch/EVM/EVMDisassembler.c +379 -0
- package/deps/capstone/arch/EVM/EVMDisassembler.h +12 -0
- package/deps/capstone/arch/EVM/EVMInstPrinter.c +20 -0
- package/deps/capstone/arch/EVM/EVMInstPrinter.h +17 -0
- package/deps/capstone/arch/EVM/EVMMapping.c +344 -0
- package/deps/capstone/arch/EVM/EVMMapping.h +8 -0
- package/deps/capstone/arch/EVM/EVMMappingInsn.inc +259 -0
- package/deps/capstone/arch/EVM/EVMModule.c +33 -0
- package/deps/capstone/arch/EVM/EVMModule.h +12 -0
- package/deps/capstone/arch/M680X/M680XDisassembler.c +2307 -0
- package/deps/capstone/arch/M680X/M680XDisassembler.h +17 -0
- package/deps/capstone/arch/M680X/M680XDisassemblerInternals.h +57 -0
- package/deps/capstone/arch/M680X/M680XInstPrinter.c +360 -0
- package/deps/capstone/arch/M680X/M680XInstPrinter.h +25 -0
- package/deps/capstone/arch/M680X/M680XModule.c +77 -0
- package/deps/capstone/arch/M680X/M680XModule.h +12 -0
- package/deps/capstone/arch/M680X/cpu12.inc +335 -0
- package/deps/capstone/arch/M680X/hcs08.inc +60 -0
- package/deps/capstone/arch/M680X/hd6301.inc +15 -0
- package/deps/capstone/arch/M680X/hd6309.inc +259 -0
- package/deps/capstone/arch/M680X/insn_props.inc +367 -0
- package/deps/capstone/arch/M680X/m6800.inc +277 -0
- package/deps/capstone/arch/M680X/m6801.inc +39 -0
- package/deps/capstone/arch/M680X/m6805.inc +277 -0
- package/deps/capstone/arch/M680X/m6808.inc +91 -0
- package/deps/capstone/arch/M680X/m6809.inc +352 -0
- package/deps/capstone/arch/M680X/m6811.inc +105 -0
- package/deps/capstone/arch/M68K/M68KDisassembler.c +3668 -0
- package/deps/capstone/arch/M68K/M68KDisassembler.h +30 -0
- package/deps/capstone/arch/M68K/M68KInstPrinter.c +387 -0
- package/deps/capstone/arch/M68K/M68KInstPrinter.h +21 -0
- package/deps/capstone/arch/M68K/M68KInstructionTable.inc +65540 -0
- package/deps/capstone/arch/M68K/M68KModule.c +42 -0
- package/deps/capstone/arch/M68K/M68KModule.h +12 -0
- package/deps/capstone/arch/MOS65XX/MOS65XXDisassembler.c +544 -0
- package/deps/capstone/arch/MOS65XX/MOS65XXDisassembler.h +22 -0
- package/deps/capstone/arch/MOS65XX/MOS65XXDisassemblerInternals.h +23 -0
- package/deps/capstone/arch/MOS65XX/MOS65XXModule.c +79 -0
- package/deps/capstone/arch/MOS65XX/MOS65XXModule.h +12 -0
- package/deps/capstone/arch/MOS65XX/instruction_info.inc +106 -0
- package/deps/capstone/arch/MOS65XX/m6502.inc +256 -0
- package/deps/capstone/arch/MOS65XX/m65816.inc +256 -0
- package/deps/capstone/arch/MOS65XX/m65c02.inc +256 -0
- package/deps/capstone/arch/MOS65XX/mw65c02.inc +256 -0
- package/deps/capstone/arch/Mips/MipsDisassembler.c +1794 -0
- package/deps/capstone/arch/Mips/MipsDisassembler.h +16 -0
- package/deps/capstone/arch/Mips/MipsGenAsmWriter.inc +5725 -0
- package/deps/capstone/arch/Mips/MipsGenDisassemblerTables.inc +6942 -0
- package/deps/capstone/arch/Mips/MipsGenInstrInfo.inc +1805 -0
- package/deps/capstone/arch/Mips/MipsGenRegisterInfo.inc +1679 -0
- package/deps/capstone/arch/Mips/MipsGenSubtargetInfo.inc +52 -0
- package/deps/capstone/arch/Mips/MipsInstPrinter.c +424 -0
- package/deps/capstone/arch/Mips/MipsInstPrinter.h +25 -0
- package/deps/capstone/arch/Mips/MipsMapping.c +1070 -0
- package/deps/capstone/arch/Mips/MipsMapping.h +25 -0
- package/deps/capstone/arch/Mips/MipsMappingInsn.inc +9315 -0
- package/deps/capstone/arch/Mips/MipsModule.c +52 -0
- package/deps/capstone/arch/Mips/MipsModule.h +12 -0
- package/deps/capstone/arch/PowerPC/PPCDisassembler.c +627 -0
- package/deps/capstone/arch/PowerPC/PPCDisassembler.h +17 -0
- package/deps/capstone/arch/PowerPC/PPCGenAsmWriter.inc +11451 -0
- package/deps/capstone/arch/PowerPC/PPCGenDisassemblerTables.inc +6886 -0
- package/deps/capstone/arch/PowerPC/PPCGenInstrInfo.inc +4772 -0
- package/deps/capstone/arch/PowerPC/PPCGenRegisterInfo.inc +1122 -0
- package/deps/capstone/arch/PowerPC/PPCGenRegisterName.inc +278 -0
- package/deps/capstone/arch/PowerPC/PPCGenSubtargetInfo.inc +90 -0
- package/deps/capstone/arch/PowerPC/PPCInstPrinter.c +1238 -0
- package/deps/capstone/arch/PowerPC/PPCInstPrinter.h +15 -0
- package/deps/capstone/arch/PowerPC/PPCMapping.c +570 -0
- package/deps/capstone/arch/PowerPC/PPCMapping.h +40 -0
- package/deps/capstone/arch/PowerPC/PPCMappingInsn.inc +13220 -0
- package/deps/capstone/arch/PowerPC/PPCMappingInsnName.inc +1731 -0
- package/deps/capstone/arch/PowerPC/PPCModule.c +45 -0
- package/deps/capstone/arch/PowerPC/PPCModule.h +12 -0
- package/deps/capstone/arch/PowerPC/PPCPredicates.h +62 -0
- package/deps/capstone/arch/RISCV/RISCVBaseInfo.h +106 -0
- package/deps/capstone/arch/RISCV/RISCVDisassembler.c +433 -0
- package/deps/capstone/arch/RISCV/RISCVDisassembler.h +18 -0
- package/deps/capstone/arch/RISCV/RISCVGenAsmWriter.inc +2651 -0
- package/deps/capstone/arch/RISCV/RISCVGenDisassemblerTables.inc +1776 -0
- package/deps/capstone/arch/RISCV/RISCVGenInsnNameMaps.inc +275 -0
- package/deps/capstone/arch/RISCV/RISCVGenInstrInfo.inc +470 -0
- package/deps/capstone/arch/RISCV/RISCVGenRegisterInfo.inc +426 -0
- package/deps/capstone/arch/RISCV/RISCVGenSubtargetInfo.inc +33 -0
- package/deps/capstone/arch/RISCV/RISCVInstPrinter.c +447 -0
- package/deps/capstone/arch/RISCV/RISCVInstPrinter.h +24 -0
- package/deps/capstone/arch/RISCV/RISCVMapping.c +366 -0
- package/deps/capstone/arch/RISCV/RISCVMapping.h +22 -0
- package/deps/capstone/arch/RISCV/RISCVMappingInsn.inc +1635 -0
- package/deps/capstone/arch/RISCV/RISCVModule.c +42 -0
- package/deps/capstone/arch/RISCV/RISCVModule.h +12 -0
- package/deps/capstone/arch/SH/SHDisassembler.c +2221 -0
- package/deps/capstone/arch/SH/SHDisassembler.h +19 -0
- package/deps/capstone/arch/SH/SHInsnTable.inc +66 -0
- package/deps/capstone/arch/SH/SHInstPrinter.c +438 -0
- package/deps/capstone/arch/SH/SHInstPrinter.h +23 -0
- package/deps/capstone/arch/SH/SHModule.c +39 -0
- package/deps/capstone/arch/SH/SHModule.h +12 -0
- package/deps/capstone/arch/SH/mktable.rb +390 -0
- package/deps/capstone/arch/Sparc/Sparc.h +63 -0
- package/deps/capstone/arch/Sparc/SparcDisassembler.c +500 -0
- package/deps/capstone/arch/Sparc/SparcDisassembler.h +17 -0
- package/deps/capstone/arch/Sparc/SparcGenAsmWriter.inc +5709 -0
- package/deps/capstone/arch/Sparc/SparcGenDisassemblerTables.inc +2028 -0
- package/deps/capstone/arch/Sparc/SparcGenInstrInfo.inc +514 -0
- package/deps/capstone/arch/Sparc/SparcGenRegisterInfo.inc +451 -0
- package/deps/capstone/arch/Sparc/SparcGenSubtargetInfo.inc +27 -0
- package/deps/capstone/arch/Sparc/SparcInstPrinter.c +446 -0
- package/deps/capstone/arch/Sparc/SparcInstPrinter.h +17 -0
- package/deps/capstone/arch/Sparc/SparcMapping.c +665 -0
- package/deps/capstone/arch/Sparc/SparcMapping.h +34 -0
- package/deps/capstone/arch/Sparc/SparcMappingInsn.inc +2643 -0
- package/deps/capstone/arch/Sparc/SparcModule.c +45 -0
- package/deps/capstone/arch/Sparc/SparcModule.h +12 -0
- package/deps/capstone/arch/SystemZ/SystemZDisassembler.c +484 -0
- package/deps/capstone/arch/SystemZ/SystemZDisassembler.h +17 -0
- package/deps/capstone/arch/SystemZ/SystemZGenAsmWriter.inc +11575 -0
- package/deps/capstone/arch/SystemZ/SystemZGenDisassemblerTables.inc +10262 -0
- package/deps/capstone/arch/SystemZ/SystemZGenInsnNameMaps.inc +2348 -0
- package/deps/capstone/arch/SystemZ/SystemZGenInstrInfo.inc +2820 -0
- package/deps/capstone/arch/SystemZ/SystemZGenRegisterInfo.inc +741 -0
- package/deps/capstone/arch/SystemZ/SystemZGenSubtargetInfo.inc +49 -0
- package/deps/capstone/arch/SystemZ/SystemZInstPrinter.c +433 -0
- package/deps/capstone/arch/SystemZ/SystemZInstPrinter.h +15 -0
- package/deps/capstone/arch/SystemZ/SystemZMCTargetDesc.c +195 -0
- package/deps/capstone/arch/SystemZ/SystemZMCTargetDesc.h +51 -0
- package/deps/capstone/arch/SystemZ/SystemZMapping.c +479 -0
- package/deps/capstone/arch/SystemZ/SystemZMapping.h +23 -0
- package/deps/capstone/arch/SystemZ/SystemZMappingInsn.inc +14175 -0
- package/deps/capstone/arch/SystemZ/SystemZModule.c +44 -0
- package/deps/capstone/arch/SystemZ/SystemZModule.h +12 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xDisassembler.c +628 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xDisassembler.h +19 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xGenAsmWriter.inc +684 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xGenDisassemblerTables.inc +1352 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xGenInstrInfo.inc +298 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xGenRegisterInfo.inc +277 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xInstPrinter.c +572 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xInstPrinter.h +15 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xMapping.c +1926 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xMapping.h +26 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xModule.c +39 -0
- package/deps/capstone/arch/TMS320C64x/TMS320C64xModule.h +12 -0
- package/deps/capstone/arch/TriCore/TriCore.td +134 -0
- package/deps/capstone/arch/TriCore/TriCoreCallingConv.td +61 -0
- package/deps/capstone/arch/TriCore/TriCoreDisassembler.c +1655 -0
- package/deps/capstone/arch/TriCore/TriCoreDisassembler.h +18 -0
- package/deps/capstone/arch/TriCore/TriCoreGenAsmWriter.inc +3691 -0
- package/deps/capstone/arch/TriCore/TriCoreGenCSFeatureName.inc +22 -0
- package/deps/capstone/arch/TriCore/TriCoreGenCSMappingInsn.inc +8938 -0
- package/deps/capstone/arch/TriCore/TriCoreGenCSMappingInsnName.inc +404 -0
- package/deps/capstone/arch/TriCore/TriCoreGenCSMappingInsnOp.inc +7994 -0
- package/deps/capstone/arch/TriCore/TriCoreGenCSOpGroup.inc +32 -0
- package/deps/capstone/arch/TriCore/TriCoreGenDisassemblerTables.inc +4044 -0
- package/deps/capstone/arch/TriCore/TriCoreGenInstrInfo.inc +2693 -0
- package/deps/capstone/arch/TriCore/TriCoreGenRegisterInfo.inc +295 -0
- package/deps/capstone/arch/TriCore/TriCoreGenSubtargetInfo.inc +40 -0
- package/deps/capstone/arch/TriCore/TriCoreInstPrinter.c +488 -0
- package/deps/capstone/arch/TriCore/TriCoreInstrFormats.td +773 -0
- package/deps/capstone/arch/TriCore/TriCoreInstrInfo.td +1873 -0
- package/deps/capstone/arch/TriCore/TriCoreLinkage.h +21 -0
- package/deps/capstone/arch/TriCore/TriCoreMapping.c +241 -0
- package/deps/capstone/arch/TriCore/TriCoreMapping.h +32 -0
- package/deps/capstone/arch/TriCore/TriCoreModule.c +44 -0
- package/deps/capstone/arch/TriCore/TriCoreModule.h +11 -0
- package/deps/capstone/arch/TriCore/TriCoreRegisterInfo.td +153 -0
- package/deps/capstone/arch/WASM/WASMDisassembler.c +1009 -0
- package/deps/capstone/arch/WASM/WASMDisassembler.h +12 -0
- package/deps/capstone/arch/WASM/WASMInstPrinter.c +47 -0
- package/deps/capstone/arch/WASM/WASMInstPrinter.h +18 -0
- package/deps/capstone/arch/WASM/WASMMapping.c +333 -0
- package/deps/capstone/arch/WASM/WASMMapping.h +9 -0
- package/deps/capstone/arch/WASM/WASMModule.c +33 -0
- package/deps/capstone/arch/WASM/WASMModule.h +12 -0
- package/deps/capstone/arch/X86/X86ATTInstPrinter.c +997 -0
- package/deps/capstone/arch/X86/X86BaseInfo.h +50 -0
- package/deps/capstone/arch/X86/X86Disassembler.c +1033 -0
- package/deps/capstone/arch/X86/X86Disassembler.h +28 -0
- package/deps/capstone/arch/X86/X86DisassemblerDecoder.c +2358 -0
- package/deps/capstone/arch/X86/X86DisassemblerDecoder.h +725 -0
- package/deps/capstone/arch/X86/X86DisassemblerDecoderCommon.h +483 -0
- package/deps/capstone/arch/X86/X86GenAsmWriter.inc +49199 -0
- package/deps/capstone/arch/X86/X86GenAsmWriter1.inc +33196 -0
- package/deps/capstone/arch/X86/X86GenAsmWriter1_reduce.inc +2531 -0
- package/deps/capstone/arch/X86/X86GenAsmWriter_reduce.inc +2855 -0
- package/deps/capstone/arch/X86/X86GenDisassemblerTables.inc +112961 -0
- package/deps/capstone/arch/X86/X86GenDisassemblerTables2.inc +102151 -0
- package/deps/capstone/arch/X86/X86GenDisassemblerTables_reduce.inc +28047 -0
- package/deps/capstone/arch/X86/X86GenDisassemblerTables_reduce2.inc +18827 -0
- package/deps/capstone/arch/X86/X86GenInstrInfo.inc +15158 -0
- package/deps/capstone/arch/X86/X86GenInstrInfo_reduce.inc +1564 -0
- package/deps/capstone/arch/X86/X86GenRegisterInfo.inc +1549 -0
- package/deps/capstone/arch/X86/X86GenRegisterName.inc +292 -0
- package/deps/capstone/arch/X86/X86GenRegisterName1.inc +291 -0
- package/deps/capstone/arch/X86/X86ImmSize.inc +335 -0
- package/deps/capstone/arch/X86/X86InstPrinter.h +26 -0
- package/deps/capstone/arch/X86/X86InstPrinterCommon.c +116 -0
- package/deps/capstone/arch/X86/X86InstPrinterCommon.h +16 -0
- package/deps/capstone/arch/X86/X86IntelInstPrinter.c +1061 -0
- package/deps/capstone/arch/X86/X86Lookup16.inc +16874 -0
- package/deps/capstone/arch/X86/X86Lookup16_reduce.inc +2308 -0
- package/deps/capstone/arch/X86/X86Mapping.c +2266 -0
- package/deps/capstone/arch/X86/X86Mapping.h +96 -0
- package/deps/capstone/arch/X86/X86MappingInsn.inc +105977 -0
- package/deps/capstone/arch/X86/X86MappingInsnName.inc +1527 -0
- package/deps/capstone/arch/X86/X86MappingInsnName_reduce.inc +348 -0
- package/deps/capstone/arch/X86/X86MappingInsnOp.inc +75700 -0
- package/deps/capstone/arch/X86/X86MappingInsnOp_reduce.inc +7729 -0
- package/deps/capstone/arch/X86/X86MappingInsn_reduce.inc +10819 -0
- package/deps/capstone/arch/X86/X86MappingReg.inc +280 -0
- package/deps/capstone/arch/X86/X86Module.c +94 -0
- package/deps/capstone/arch/X86/X86Module.h +12 -0
- package/deps/capstone/arch/XCore/XCoreDisassembler.c +794 -0
- package/deps/capstone/arch/XCore/XCoreDisassembler.h +17 -0
- package/deps/capstone/arch/XCore/XCoreGenAsmWriter.inc +772 -0
- package/deps/capstone/arch/XCore/XCoreGenDisassemblerTables.inc +853 -0
- package/deps/capstone/arch/XCore/XCoreGenInstrInfo.inc +267 -0
- package/deps/capstone/arch/XCore/XCoreGenRegisterInfo.inc +110 -0
- package/deps/capstone/arch/XCore/XCoreInstPrinter.c +250 -0
- package/deps/capstone/arch/XCore/XCoreInstPrinter.h +18 -0
- package/deps/capstone/arch/XCore/XCoreMapping.c +297 -0
- package/deps/capstone/arch/XCore/XCoreMapping.h +26 -0
- package/deps/capstone/arch/XCore/XCoreMappingInsn.inc +1287 -0
- package/deps/capstone/arch/XCore/XCoreModule.c +41 -0
- package/deps/capstone/arch/XCore/XCoreModule.h +12 -0
- package/deps/capstone/cs.c +1664 -0
- package/deps/capstone/cs_priv.h +101 -0
- package/deps/capstone/cs_simple_types.h +886 -0
- package/deps/capstone/include/capstone/arm.h +991 -0
- package/deps/capstone/include/capstone/arm64.h +3159 -0
- package/deps/capstone/include/capstone/bpf.h +209 -0
- package/deps/capstone/include/capstone/capstone.h +875 -0
- package/deps/capstone/include/capstone/evm.h +188 -0
- package/deps/capstone/include/capstone/m680x.h +537 -0
- package/deps/capstone/include/capstone/m68k.h +613 -0
- package/deps/capstone/include/capstone/mips.h +956 -0
- package/deps/capstone/include/capstone/mos65xx.h +204 -0
- package/deps/capstone/include/capstone/platform.h +122 -0
- package/deps/capstone/include/capstone/ppc.h +2108 -0
- package/deps/capstone/include/capstone/riscv.h +531 -0
- package/deps/capstone/include/capstone/sh.h +465 -0
- package/deps/capstone/include/capstone/sparc.h +520 -0
- package/deps/capstone/include/capstone/systemz.h +2601 -0
- package/deps/capstone/include/capstone/tms320c64x.h +359 -0
- package/deps/capstone/include/capstone/tricore.h +567 -0
- package/deps/capstone/include/capstone/wasm.h +250 -0
- package/deps/capstone/include/capstone/x86.h +1986 -0
- package/deps/capstone/include/capstone/xcore.h +235 -0
- package/deps/capstone/include/platform.h +110 -0
- package/deps/capstone/include/windowsce/intrin.h +12 -0
- package/deps/capstone/include/windowsce/stdint.h +133 -0
- package/deps/capstone/utils.c +140 -0
- package/deps/capstone/utils.h +54 -0
- package/index.d.ts +448 -0
- package/index.js +64 -0
- package/index.mjs +25 -0
- package/package.json +82 -0
- package/prebuilds/win32-x64/hexcore-capstone.node +0 -0
- package/src/capstone_wrapper.cpp +910 -0
- package/src/capstone_wrapper.h +147 -0
- package/src/disasm_async_worker.h +215 -0
- package/src/main.cpp +145 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
//=== MC/MCRegisterInfo.cpp - Target Register Description -------*- C++ -*-===//
|
|
2
|
+
//
|
|
3
|
+
// The LLVM Compiler Infrastructure
|
|
4
|
+
//
|
|
5
|
+
// This file is distributed under the University of Illinois Open Source
|
|
6
|
+
// License. See LICENSE.TXT for details.
|
|
7
|
+
//
|
|
8
|
+
//===----------------------------------------------------------------------===//
|
|
9
|
+
//
|
|
10
|
+
// This file implements MCRegisterInfo functions.
|
|
11
|
+
//
|
|
12
|
+
//===----------------------------------------------------------------------===//
|
|
13
|
+
|
|
14
|
+
/* Capstone Disassembly Engine */
|
|
15
|
+
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
|
|
16
|
+
|
|
17
|
+
#include "MCRegisterInfo.h"
|
|
18
|
+
|
|
19
|
+
/// DiffListIterator - Base iterator class that can traverse the
|
|
20
|
+
/// differentially encoded register and regunit lists in DiffLists.
|
|
21
|
+
/// Don't use this class directly, use one of the specialized sub-classes
|
|
22
|
+
/// defined below.
|
|
23
|
+
typedef struct DiffListIterator {
|
|
24
|
+
uint16_t Val;
|
|
25
|
+
const MCPhysReg *List;
|
|
26
|
+
} DiffListIterator;
|
|
27
|
+
|
|
28
|
+
void MCRegisterInfo_InitMCRegisterInfo(MCRegisterInfo *RI,
|
|
29
|
+
const MCRegisterDesc *D, unsigned NR,
|
|
30
|
+
unsigned RA, unsigned PC,
|
|
31
|
+
const MCRegisterClass *C, unsigned NC,
|
|
32
|
+
uint16_t (*RURoots)[2], unsigned NRU,
|
|
33
|
+
const MCPhysReg *DL,
|
|
34
|
+
const char *Strings,
|
|
35
|
+
const uint16_t *SubIndices, unsigned NumIndices,
|
|
36
|
+
const uint16_t *RET)
|
|
37
|
+
{
|
|
38
|
+
RI->Desc = D;
|
|
39
|
+
RI->NumRegs = NR;
|
|
40
|
+
RI->RAReg = RA;
|
|
41
|
+
RI->PCReg = PC;
|
|
42
|
+
RI->Classes = C;
|
|
43
|
+
RI->DiffLists = DL;
|
|
44
|
+
RI->RegStrings = Strings;
|
|
45
|
+
RI->NumClasses = NC;
|
|
46
|
+
RI->RegUnitRoots = RURoots;
|
|
47
|
+
RI->NumRegUnits = NRU;
|
|
48
|
+
RI->SubRegIndices = SubIndices;
|
|
49
|
+
RI->NumSubRegIndices = NumIndices;
|
|
50
|
+
RI->RegEncodingTable = RET;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static void DiffListIterator_init(DiffListIterator *d, MCPhysReg InitVal, const MCPhysReg *DiffList)
|
|
54
|
+
{
|
|
55
|
+
d->Val = InitVal;
|
|
56
|
+
d->List = DiffList;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static uint16_t DiffListIterator_getVal(DiffListIterator *d)
|
|
60
|
+
{
|
|
61
|
+
return d->Val;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static bool DiffListIterator_next(DiffListIterator *d)
|
|
65
|
+
{
|
|
66
|
+
MCPhysReg D;
|
|
67
|
+
|
|
68
|
+
if (d->List == 0)
|
|
69
|
+
return false;
|
|
70
|
+
|
|
71
|
+
D = *d->List;
|
|
72
|
+
d->List++;
|
|
73
|
+
d->Val += D;
|
|
74
|
+
|
|
75
|
+
if (!D)
|
|
76
|
+
d->List = 0;
|
|
77
|
+
|
|
78
|
+
return (D != 0);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static bool DiffListIterator_isValid(DiffListIterator *d)
|
|
82
|
+
{
|
|
83
|
+
return (d->List != 0);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
unsigned MCRegisterInfo_getMatchingSuperReg(const MCRegisterInfo *RI, unsigned Reg, unsigned SubIdx, const MCRegisterClass *RC)
|
|
87
|
+
{
|
|
88
|
+
DiffListIterator iter;
|
|
89
|
+
|
|
90
|
+
if (Reg >= RI->NumRegs) {
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
DiffListIterator_init(&iter, (MCPhysReg)Reg, RI->DiffLists + RI->Desc[Reg].SuperRegs);
|
|
95
|
+
DiffListIterator_next(&iter);
|
|
96
|
+
|
|
97
|
+
while(DiffListIterator_isValid(&iter)) {
|
|
98
|
+
uint16_t val = DiffListIterator_getVal(&iter);
|
|
99
|
+
if (MCRegisterClass_contains(RC, val) && Reg == MCRegisterInfo_getSubReg(RI, val, SubIdx))
|
|
100
|
+
return val;
|
|
101
|
+
|
|
102
|
+
DiffListIterator_next(&iter);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
unsigned MCRegisterInfo_getSubReg(const MCRegisterInfo *RI, unsigned Reg, unsigned Idx)
|
|
109
|
+
{
|
|
110
|
+
DiffListIterator iter;
|
|
111
|
+
const uint16_t *SRI = RI->SubRegIndices + RI->Desc[Reg].SubRegIndices;
|
|
112
|
+
|
|
113
|
+
DiffListIterator_init(&iter, (MCPhysReg)Reg, RI->DiffLists + RI->Desc[Reg].SubRegs);
|
|
114
|
+
DiffListIterator_next(&iter);
|
|
115
|
+
|
|
116
|
+
while(DiffListIterator_isValid(&iter)) {
|
|
117
|
+
if (*SRI == Idx)
|
|
118
|
+
return DiffListIterator_getVal(&iter);
|
|
119
|
+
DiffListIterator_next(&iter);
|
|
120
|
+
++SRI;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const MCRegisterClass* MCRegisterInfo_getRegClass(const MCRegisterInfo *RI, unsigned i)
|
|
127
|
+
{
|
|
128
|
+
//assert(i < getNumRegClasses() && "Register Class ID out of range");
|
|
129
|
+
if (i >= RI->NumClasses)
|
|
130
|
+
return 0;
|
|
131
|
+
return &(RI->Classes[i]);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
bool MCRegisterClass_contains(const MCRegisterClass *c, unsigned Reg)
|
|
135
|
+
{
|
|
136
|
+
unsigned InByte = 0;
|
|
137
|
+
unsigned Byte = 0;
|
|
138
|
+
|
|
139
|
+
// Make sure that MCRegisterInfo_getRegClass didn't return 0
|
|
140
|
+
// (for calls to GETREGCLASS_CONTAIN0)
|
|
141
|
+
if(!c)
|
|
142
|
+
return false;
|
|
143
|
+
|
|
144
|
+
InByte = Reg % 8;
|
|
145
|
+
Byte = Reg / 8;
|
|
146
|
+
|
|
147
|
+
if (Byte >= c->RegSetSize)
|
|
148
|
+
return false;
|
|
149
|
+
|
|
150
|
+
return (c->RegSet[Byte] & (1 << InByte)) != 0;
|
|
151
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
//=== MC/MCRegisterInfo.h - Target Register Description ---------*- C++ -*-===//
|
|
2
|
+
//
|
|
3
|
+
// The LLVM Compiler Infrastructure
|
|
4
|
+
//
|
|
5
|
+
// This file is distributed under the University of Illinois Open Source
|
|
6
|
+
// License. See LICENSE.TXT for details.
|
|
7
|
+
//
|
|
8
|
+
//===----------------------------------------------------------------------===//
|
|
9
|
+
//
|
|
10
|
+
// This file describes an abstract interface used to get information about a
|
|
11
|
+
// target machines register file. This information is used for a variety of
|
|
12
|
+
// purposed, especially register allocation.
|
|
13
|
+
//
|
|
14
|
+
//===----------------------------------------------------------------------===//
|
|
15
|
+
|
|
16
|
+
/* Capstone Disassembly Engine */
|
|
17
|
+
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
|
|
18
|
+
|
|
19
|
+
#ifndef CS_LLVM_MC_MCREGISTERINFO_H
|
|
20
|
+
#define CS_LLVM_MC_MCREGISTERINFO_H
|
|
21
|
+
|
|
22
|
+
#include "capstone/platform.h"
|
|
23
|
+
|
|
24
|
+
/// An unsigned integer type large enough to represent all physical registers,
|
|
25
|
+
/// but not necessarily virtual registers.
|
|
26
|
+
typedef uint16_t MCPhysReg;
|
|
27
|
+
typedef const MCPhysReg* iterator;
|
|
28
|
+
|
|
29
|
+
typedef struct MCRegisterClass2 {
|
|
30
|
+
iterator RegsBegin;
|
|
31
|
+
const uint8_t *RegSet;
|
|
32
|
+
uint8_t RegsSize;
|
|
33
|
+
uint8_t RegSetSize;
|
|
34
|
+
} MCRegisterClass2;
|
|
35
|
+
|
|
36
|
+
typedef struct MCRegisterClass {
|
|
37
|
+
iterator RegsBegin;
|
|
38
|
+
const uint8_t *RegSet;
|
|
39
|
+
uint16_t RegSetSize;
|
|
40
|
+
} MCRegisterClass;
|
|
41
|
+
|
|
42
|
+
/// MCRegisterDesc - This record contains information about a particular
|
|
43
|
+
/// register. The SubRegs field is a zero terminated array of registers that
|
|
44
|
+
/// are sub-registers of the specific register, e.g. AL, AH are sub-registers
|
|
45
|
+
/// of AX. The SuperRegs field is a zero terminated array of registers that are
|
|
46
|
+
/// super-registers of AX.
|
|
47
|
+
typedef struct MCRegisterDesc {
|
|
48
|
+
uint32_t Name; // Printable name for the reg (for debugging)
|
|
49
|
+
uint32_t SubRegs; // Sub-register set, described above
|
|
50
|
+
uint32_t SuperRegs; // Super-register set, described above
|
|
51
|
+
|
|
52
|
+
// Offset into MCRI::SubRegIndices of a list of sub-register indices for each
|
|
53
|
+
// sub-register in SubRegs.
|
|
54
|
+
uint32_t SubRegIndices;
|
|
55
|
+
|
|
56
|
+
// RegUnits - Points to the list of register units. The low 4 bits holds the
|
|
57
|
+
// Scale, the high bits hold an offset into DiffLists. See MCRegUnitIterator.
|
|
58
|
+
uint32_t RegUnits;
|
|
59
|
+
|
|
60
|
+
/// Index into list with lane mask sequences. The sequence contains a lanemask
|
|
61
|
+
/// for every register unit.
|
|
62
|
+
uint16_t RegUnitLaneMasks; // ???
|
|
63
|
+
} MCRegisterDesc;
|
|
64
|
+
|
|
65
|
+
/// MCRegisterInfo base class - We assume that the target defines a static
|
|
66
|
+
/// array of MCRegisterDesc objects that represent all of the machine
|
|
67
|
+
/// registers that the target has. As such, we simply have to track a pointer
|
|
68
|
+
/// to this array so that we can turn register number into a register
|
|
69
|
+
/// descriptor.
|
|
70
|
+
///
|
|
71
|
+
/// Note this class is designed to be a base class of TargetRegisterInfo, which
|
|
72
|
+
/// is the interface used by codegen. However, specific targets *should never*
|
|
73
|
+
/// specialize this class. MCRegisterInfo should only contain getters to access
|
|
74
|
+
/// TableGen generated physical register data. It must not be extended with
|
|
75
|
+
/// virtual methods.
|
|
76
|
+
typedef struct MCRegisterInfo {
|
|
77
|
+
const MCRegisterDesc *Desc; // Pointer to the descriptor array
|
|
78
|
+
unsigned NumRegs; // Number of entries in the array
|
|
79
|
+
unsigned RAReg; // Return address register
|
|
80
|
+
unsigned PCReg; // Program counter register
|
|
81
|
+
const MCRegisterClass *Classes; // Pointer to the regclass array
|
|
82
|
+
unsigned NumClasses; // Number of entries in the array
|
|
83
|
+
unsigned NumRegUnits; // Number of regunits.
|
|
84
|
+
uint16_t (*RegUnitRoots)[2]; // Pointer to regunit root table.
|
|
85
|
+
const MCPhysReg *DiffLists; // Pointer to the difflists array
|
|
86
|
+
// const LaneBitmask *RegUnitMaskSequences; // Pointer to lane mask sequences
|
|
87
|
+
const char *RegStrings; // Pointer to the string table.
|
|
88
|
+
// const char *RegClassStrings; // Pointer to the class strings.
|
|
89
|
+
const uint16_t *SubRegIndices; // Pointer to the subreg lookup
|
|
90
|
+
// array.
|
|
91
|
+
unsigned NumSubRegIndices; // Number of subreg indices.
|
|
92
|
+
const uint16_t *RegEncodingTable; // Pointer to array of register
|
|
93
|
+
// encodings.
|
|
94
|
+
} MCRegisterInfo;
|
|
95
|
+
|
|
96
|
+
void MCRegisterInfo_InitMCRegisterInfo(MCRegisterInfo *RI,
|
|
97
|
+
const MCRegisterDesc *D, unsigned NR, unsigned RA,
|
|
98
|
+
unsigned PC,
|
|
99
|
+
const MCRegisterClass *C, unsigned NC,
|
|
100
|
+
uint16_t (*RURoots)[2],
|
|
101
|
+
unsigned NRU,
|
|
102
|
+
const MCPhysReg *DL,
|
|
103
|
+
const char *Strings,
|
|
104
|
+
const uint16_t *SubIndices,
|
|
105
|
+
unsigned NumIndices,
|
|
106
|
+
const uint16_t *RET);
|
|
107
|
+
|
|
108
|
+
unsigned MCRegisterInfo_getMatchingSuperReg(const MCRegisterInfo *RI, unsigned Reg, unsigned SubIdx, const MCRegisterClass *RC);
|
|
109
|
+
|
|
110
|
+
unsigned MCRegisterInfo_getSubReg(const MCRegisterInfo *RI, unsigned Reg, unsigned Idx);
|
|
111
|
+
|
|
112
|
+
const MCRegisterClass* MCRegisterInfo_getRegClass(const MCRegisterInfo *RI, unsigned i);
|
|
113
|
+
|
|
114
|
+
bool MCRegisterClass_contains(const MCRegisterClass *c, unsigned Reg);
|
|
115
|
+
|
|
116
|
+
#endif
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/* Capstone Disassembly Engine */
|
|
2
|
+
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
|
|
3
|
+
/* Rot127 <unisono@quyllur.org>, 2022-2023 */
|
|
4
|
+
|
|
5
|
+
#include "Mapping.h"
|
|
6
|
+
|
|
7
|
+
// create a cache for fast id lookup
|
|
8
|
+
static unsigned short *make_id2insn(const insn_map *insns, unsigned int size)
|
|
9
|
+
{
|
|
10
|
+
// NOTE: assume that the max id is always put at the end of insns array
|
|
11
|
+
unsigned short max_id = insns[size - 1].id;
|
|
12
|
+
unsigned int i;
|
|
13
|
+
|
|
14
|
+
unsigned short *cache =
|
|
15
|
+
(unsigned short *)cs_mem_calloc(max_id + 1, sizeof(*cache));
|
|
16
|
+
|
|
17
|
+
for (i = 1; i < size; i++)
|
|
18
|
+
cache[insns[i].id] = i;
|
|
19
|
+
|
|
20
|
+
return cache;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// look for @id in @insns, given its size in @max. first time call will update
|
|
24
|
+
// @cache. return 0 if not found
|
|
25
|
+
unsigned short insn_find(const insn_map *insns, unsigned int max,
|
|
26
|
+
unsigned int id, unsigned short **cache)
|
|
27
|
+
{
|
|
28
|
+
if (id > insns[max - 1].id)
|
|
29
|
+
return 0;
|
|
30
|
+
|
|
31
|
+
if (*cache == NULL)
|
|
32
|
+
*cache = make_id2insn(insns, max);
|
|
33
|
+
|
|
34
|
+
return (*cache)[id];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Gives the id for the given @name if it is saved in @map.
|
|
38
|
+
// Returns the id or -1 if not found.
|
|
39
|
+
int name2id(const name_map *map, int max, const char *name)
|
|
40
|
+
{
|
|
41
|
+
int i;
|
|
42
|
+
|
|
43
|
+
for (i = 0; i < max; i++) {
|
|
44
|
+
if (!strcmp(map[i].name, name)) {
|
|
45
|
+
return map[i].id;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// nothing match
|
|
50
|
+
return -1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Gives the name for the given @id if it is saved in @map.
|
|
54
|
+
// Returns the name or NULL if not found.
|
|
55
|
+
const char *id2name(const name_map *map, int max, const unsigned int id)
|
|
56
|
+
{
|
|
57
|
+
int i;
|
|
58
|
+
|
|
59
|
+
for (i = 0; i < max; i++) {
|
|
60
|
+
if (map[i].id == id) {
|
|
61
|
+
return map[i].name;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// nothing match
|
|
66
|
+
return NULL;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// Adds a register to the implicit write register list.
|
|
70
|
+
/// It will not add the same register twice.
|
|
71
|
+
void map_add_implicit_write(MCInst *MI, uint32_t Reg)
|
|
72
|
+
{
|
|
73
|
+
if (!MI->flat_insn->detail)
|
|
74
|
+
return;
|
|
75
|
+
|
|
76
|
+
uint16_t *regs_write = MI->flat_insn->detail->regs_write;
|
|
77
|
+
for (int i = 0; i < MAX_IMPL_W_REGS; ++i) {
|
|
78
|
+
if (i == MI->flat_insn->detail->regs_write_count) {
|
|
79
|
+
regs_write[i] = Reg;
|
|
80
|
+
MI->flat_insn->detail->regs_write_count++;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (regs_write[i] == Reg)
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/// Copies the implicit read registers of @imap to @MI->flat_insn.
|
|
89
|
+
/// Already present registers will be preserved.
|
|
90
|
+
void map_implicit_reads(MCInst *MI, const insn_map *imap)
|
|
91
|
+
{
|
|
92
|
+
#ifndef CAPSTONE_DIET
|
|
93
|
+
if (!MI->flat_insn->detail)
|
|
94
|
+
return;
|
|
95
|
+
|
|
96
|
+
cs_detail *detail = MI->flat_insn->detail;
|
|
97
|
+
unsigned Opcode = MCInst_getOpcode(MI);
|
|
98
|
+
unsigned i = 0;
|
|
99
|
+
uint16_t reg = imap[Opcode].regs_use[i];
|
|
100
|
+
while (reg != 0) {
|
|
101
|
+
if (i >= MAX_IMPL_R_REGS ||
|
|
102
|
+
detail->regs_read_count >= MAX_IMPL_R_REGS) {
|
|
103
|
+
printf("ERROR: Too many implicit read register defined in "
|
|
104
|
+
"instruction mapping.\n");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
detail->regs_read[detail->regs_read_count++] = reg;
|
|
108
|
+
reg = imap[Opcode].regs_use[++i];
|
|
109
|
+
}
|
|
110
|
+
#endif // CAPSTONE_DIET
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/// Copies the implicit write registers of @imap to @MI->flat_insn.
|
|
114
|
+
/// Already present registers will be preserved.
|
|
115
|
+
void map_implicit_writes(MCInst *MI, const insn_map *imap)
|
|
116
|
+
{
|
|
117
|
+
#ifndef CAPSTONE_DIET
|
|
118
|
+
if (!MI->flat_insn->detail)
|
|
119
|
+
return;
|
|
120
|
+
|
|
121
|
+
cs_detail *detail = MI->flat_insn->detail;
|
|
122
|
+
unsigned Opcode = MCInst_getOpcode(MI);
|
|
123
|
+
unsigned i = 0;
|
|
124
|
+
uint16_t reg = imap[Opcode].regs_mod[i];
|
|
125
|
+
while (reg != 0) {
|
|
126
|
+
if (i >= MAX_IMPL_W_REGS ||
|
|
127
|
+
detail->regs_write_count >= MAX_IMPL_W_REGS) {
|
|
128
|
+
printf("ERROR: Too many implicit write register defined in "
|
|
129
|
+
"instruction mapping.\n");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
detail->regs_write[detail->regs_write_count++] = reg;
|
|
133
|
+
reg = imap[Opcode].regs_mod[++i];
|
|
134
|
+
}
|
|
135
|
+
#endif // CAPSTONE_DIET
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/// Copies the groups from @imap to @MI->flat_insn.
|
|
139
|
+
/// Already present groups will be preserved.
|
|
140
|
+
void map_groups(MCInst *MI, const insn_map *imap)
|
|
141
|
+
{
|
|
142
|
+
#ifndef CAPSTONE_DIET
|
|
143
|
+
if (!MI->flat_insn->detail)
|
|
144
|
+
return;
|
|
145
|
+
|
|
146
|
+
cs_detail *detail = MI->flat_insn->detail;
|
|
147
|
+
unsigned Opcode = MCInst_getOpcode(MI);
|
|
148
|
+
unsigned i = 0;
|
|
149
|
+
uint16_t group = imap[Opcode].groups[i];
|
|
150
|
+
while (group != 0) {
|
|
151
|
+
if (detail->groups_count >= MAX_NUM_GROUPS) {
|
|
152
|
+
printf("ERROR: Too many groups defined in instruction mapping.\n");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
detail->groups[detail->groups_count++] = group;
|
|
156
|
+
group = imap[Opcode].groups[++i];
|
|
157
|
+
}
|
|
158
|
+
#endif // CAPSTONE_DIET
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Search for the CS instruction id for the given @MC_Opcode in @imap.
|
|
162
|
+
// return -1 if none is found.
|
|
163
|
+
unsigned int find_cs_id(unsigned MC_Opcode, const insn_map *imap,
|
|
164
|
+
unsigned imap_size)
|
|
165
|
+
{
|
|
166
|
+
// binary searching since the IDs are sorted in order
|
|
167
|
+
unsigned int left, right, m;
|
|
168
|
+
unsigned int max = imap_size;
|
|
169
|
+
|
|
170
|
+
right = max - 1;
|
|
171
|
+
|
|
172
|
+
if (MC_Opcode < imap[0].id || MC_Opcode > imap[right].id)
|
|
173
|
+
// not found
|
|
174
|
+
return -1;
|
|
175
|
+
|
|
176
|
+
left = 0;
|
|
177
|
+
|
|
178
|
+
while (left <= right) {
|
|
179
|
+
m = (left + right) / 2;
|
|
180
|
+
if (MC_Opcode == imap[m].id) {
|
|
181
|
+
return m;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (MC_Opcode < imap[m].id)
|
|
185
|
+
right = m - 1;
|
|
186
|
+
else
|
|
187
|
+
left = m + 1;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return -1;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/// Sets the Capstone instruction id which maps to the @MI opcode.
|
|
194
|
+
/// If no mapping is found the function returns and prints an error.
|
|
195
|
+
void map_cs_id(MCInst *MI, const insn_map *imap, unsigned int imap_size)
|
|
196
|
+
{
|
|
197
|
+
unsigned int i = find_cs_id(MCInst_getOpcode(MI), imap, imap_size);
|
|
198
|
+
if (i != -1) {
|
|
199
|
+
MI->flat_insn->id = imap[i].mapid;
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
printf("ERROR: Could not find CS id for MCInst opcode: %d\n",
|
|
203
|
+
MCInst_getOpcode(MI));
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/// Returns the operand type information from the
|
|
208
|
+
/// mapping table for instruction operands.
|
|
209
|
+
/// Only usable by `auto-sync` archs!
|
|
210
|
+
const cs_op_type mapping_get_op_type(MCInst *MI, unsigned OpNum,
|
|
211
|
+
const map_insn_ops *insn_ops_map,
|
|
212
|
+
size_t map_size)
|
|
213
|
+
{
|
|
214
|
+
assert(MI);
|
|
215
|
+
assert(MI->Opcode < map_size);
|
|
216
|
+
assert(OpNum < sizeof(insn_ops_map[MI->Opcode].ops) /
|
|
217
|
+
sizeof(insn_ops_map[MI->Opcode].ops[0]));
|
|
218
|
+
|
|
219
|
+
return insn_ops_map[MI->Opcode].ops[OpNum].type;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/// Returns the operand access flags from the
|
|
223
|
+
/// mapping table for instruction operands.
|
|
224
|
+
/// Only usable by `auto-sync` archs!
|
|
225
|
+
const cs_ac_type mapping_get_op_access(MCInst *MI, unsigned OpNum,
|
|
226
|
+
const map_insn_ops *insn_ops_map,
|
|
227
|
+
size_t map_size)
|
|
228
|
+
{
|
|
229
|
+
assert(MI);
|
|
230
|
+
assert(MI->Opcode < map_size);
|
|
231
|
+
assert(OpNum < sizeof(insn_ops_map[MI->Opcode].ops) /
|
|
232
|
+
sizeof(insn_ops_map[MI->Opcode].ops[0]));
|
|
233
|
+
|
|
234
|
+
cs_ac_type access = insn_ops_map[MI->Opcode].ops[OpNum].access;
|
|
235
|
+
if (MCInst_opIsTied(MI, OpNum) || MCInst_opIsTying(MI, OpNum))
|
|
236
|
+
access |= (access == CS_AC_READ) ? CS_AC_WRITE : CS_AC_READ;
|
|
237
|
+
return access;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/// Returns the operand at detail->arch.operands[op_count + offset]
|
|
241
|
+
/// Or NULL if detail is not set.
|
|
242
|
+
#define DEFINE_get_detail_op(arch, ARCH) \
|
|
243
|
+
cs_##arch##_op *ARCH##_get_detail_op(MCInst *MI, int offset) \
|
|
244
|
+
{ \
|
|
245
|
+
if (!MI->flat_insn->detail) \
|
|
246
|
+
return NULL; \
|
|
247
|
+
int OpIdx = MI->flat_insn->detail->arch.op_count + offset; \
|
|
248
|
+
assert(OpIdx >= 0 && OpIdx < MAX_MC_OPS); \
|
|
249
|
+
return &MI->flat_insn->detail->arch.operands[OpIdx]; \
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
DEFINE_get_detail_op(arm, ARM);
|
|
253
|
+
DEFINE_get_detail_op(ppc, PPC);
|
|
254
|
+
DEFINE_get_detail_op(tricore, TriCore);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/* Capstone Disassembly Engine */
|
|
2
|
+
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
|
|
3
|
+
/* Rot127 <unisono@quyllur.org>, 2022-2023 */
|
|
4
|
+
|
|
5
|
+
#ifndef CS_MAPPING_H
|
|
6
|
+
#define CS_MAPPING_H
|
|
7
|
+
|
|
8
|
+
#if defined(CAPSTONE_HAS_OSXKERNEL)
|
|
9
|
+
#include <libkern/libkern.h>
|
|
10
|
+
#else
|
|
11
|
+
#include "include/capstone/capstone.h"
|
|
12
|
+
#include <stddef.h>
|
|
13
|
+
#endif
|
|
14
|
+
#include "cs_priv.h"
|
|
15
|
+
#include <assert.h>
|
|
16
|
+
#include <string.h>
|
|
17
|
+
|
|
18
|
+
// map instruction to its characteristics
|
|
19
|
+
typedef struct insn_map {
|
|
20
|
+
unsigned short id; // The LLVM instruction id
|
|
21
|
+
unsigned short mapid; // The Capstone instruction id
|
|
22
|
+
#ifndef CAPSTONE_DIET
|
|
23
|
+
uint16_t regs_use[MAX_IMPL_R_REGS]; ///< list of implicit registers used by
|
|
24
|
+
///< this instruction
|
|
25
|
+
uint16_t regs_mod[MAX_IMPL_W_REGS]; ///< list of implicit registers modified
|
|
26
|
+
///< by this instruction
|
|
27
|
+
unsigned char groups
|
|
28
|
+
[MAX_NUM_GROUPS]; ///< list of group this instruction belong to
|
|
29
|
+
bool branch; // branch instruction?
|
|
30
|
+
bool indirect_branch; // indirect branch instruction?
|
|
31
|
+
#endif
|
|
32
|
+
} insn_map;
|
|
33
|
+
|
|
34
|
+
// look for @id in @m, given its size in @max. first time call will update
|
|
35
|
+
// @cache. return 0 if not found
|
|
36
|
+
unsigned short insn_find(const insn_map *m, unsigned int max, unsigned int id,
|
|
37
|
+
unsigned short **cache);
|
|
38
|
+
|
|
39
|
+
unsigned int find_cs_id(unsigned MC_Opcode, const insn_map *imap,
|
|
40
|
+
unsigned imap_size);
|
|
41
|
+
|
|
42
|
+
#define MAX_NO_DATA_TYPES 10
|
|
43
|
+
|
|
44
|
+
///< A LLVM<->CS Mapping entry of an MCOperand.
|
|
45
|
+
typedef struct {
|
|
46
|
+
uint8_t /* cs_op_type */ type; ///< Operand type (e.g.: reg, imm, mem)
|
|
47
|
+
uint8_t /* cs_ac_type */ access; ///< The access type (read, write)
|
|
48
|
+
uint8_t /* cs_data_type */
|
|
49
|
+
dtypes[MAX_NO_DATA_TYPES]; ///< List of op types. Terminated by
|
|
50
|
+
///< CS_DATA_TYPE_LAST
|
|
51
|
+
} mapping_op;
|
|
52
|
+
|
|
53
|
+
#define MAX_NO_INSN_MAP_OPS 16
|
|
54
|
+
|
|
55
|
+
///< MCOperands of an instruction.
|
|
56
|
+
typedef struct {
|
|
57
|
+
mapping_op
|
|
58
|
+
ops[MAX_NO_INSN_MAP_OPS]; ///< NULL terminated array of insn_op.
|
|
59
|
+
} map_insn_ops;
|
|
60
|
+
|
|
61
|
+
/// Only usable by `auto-sync` archs!
|
|
62
|
+
const cs_op_type mapping_get_op_type(MCInst *MI, unsigned OpNum,
|
|
63
|
+
const map_insn_ops *insn_ops_map,
|
|
64
|
+
size_t map_size);
|
|
65
|
+
|
|
66
|
+
/// Only usable by `auto-sync` archs!
|
|
67
|
+
const cs_ac_type mapping_get_op_access(MCInst *MI, unsigned OpNum,
|
|
68
|
+
const map_insn_ops *insn_ops_map,
|
|
69
|
+
size_t map_size);
|
|
70
|
+
|
|
71
|
+
/// Macro for easier access of operand types from the map.
|
|
72
|
+
/// Assumes the istruction operands map is called "insn_operands"
|
|
73
|
+
/// Only usable by `auto-sync` archs!
|
|
74
|
+
#define map_get_op_type(MI, OpNum) \
|
|
75
|
+
mapping_get_op_type(MI, OpNum, (const map_insn_ops *)insn_operands, \
|
|
76
|
+
sizeof(insn_operands) / sizeof(insn_operands[0]))
|
|
77
|
+
|
|
78
|
+
/// Macro for easier access of operand access flags from the map.
|
|
79
|
+
/// Assumes the istruction operands map is called "insn_operands"
|
|
80
|
+
/// Only usable by `auto-sync` archs!
|
|
81
|
+
#define map_get_op_access(MI, OpNum) \
|
|
82
|
+
mapping_get_op_access(MI, OpNum, (const map_insn_ops *)insn_operands, \
|
|
83
|
+
sizeof(insn_operands) / \
|
|
84
|
+
sizeof(insn_operands[0]))
|
|
85
|
+
|
|
86
|
+
///< Map for ids to their string
|
|
87
|
+
typedef struct name_map {
|
|
88
|
+
unsigned int id;
|
|
89
|
+
const char *name;
|
|
90
|
+
} name_map;
|
|
91
|
+
|
|
92
|
+
// map a name to its ID
|
|
93
|
+
// return 0 if not found
|
|
94
|
+
int name2id(const name_map *map, int max, const char *name);
|
|
95
|
+
|
|
96
|
+
// map ID to a name
|
|
97
|
+
// return NULL if not found
|
|
98
|
+
const char *id2name(const name_map *map, int max, const unsigned int id);
|
|
99
|
+
|
|
100
|
+
void map_add_implicit_write(MCInst *MI, uint32_t Reg);
|
|
101
|
+
|
|
102
|
+
void map_implicit_reads(MCInst *MI, const insn_map *imap);
|
|
103
|
+
|
|
104
|
+
void map_implicit_writes(MCInst *MI, const insn_map *imap);
|
|
105
|
+
|
|
106
|
+
void map_groups(MCInst *MI, const insn_map *imap);
|
|
107
|
+
|
|
108
|
+
void map_cs_id(MCInst *MI, const insn_map *imap, unsigned int imap_size);
|
|
109
|
+
|
|
110
|
+
#define DECL_get_detail_op(arch, ARCH) \
|
|
111
|
+
cs_##arch##_op *ARCH##_get_detail_op(MCInst *MI, int offset);
|
|
112
|
+
|
|
113
|
+
DECL_get_detail_op(arm, ARM);
|
|
114
|
+
DECL_get_detail_op(ppc, PPC);
|
|
115
|
+
DECL_get_detail_op(tricore, TriCore);
|
|
116
|
+
|
|
117
|
+
/// Increments the detail->arch.op_count by one.
|
|
118
|
+
#define DEFINE_inc_detail_op_count(arch, ARCH) \
|
|
119
|
+
static inline void ARCH##_inc_op_count(MCInst *MI) \
|
|
120
|
+
{ \
|
|
121
|
+
MI->flat_insn->detail->arch.op_count++; \
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// Decrements the detail->arch.op_count by one.
|
|
125
|
+
#define DEFINE_dec_detail_op_count(arch, ARCH) \
|
|
126
|
+
static inline void ARCH##_dec_op_count(MCInst *MI) \
|
|
127
|
+
{ \
|
|
128
|
+
MI->flat_insn->detail->arch.op_count--; \
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
DEFINE_inc_detail_op_count(arm, ARM);
|
|
132
|
+
DEFINE_dec_detail_op_count(arm, ARM);
|
|
133
|
+
DEFINE_inc_detail_op_count(ppc, PPC);
|
|
134
|
+
DEFINE_dec_detail_op_count(ppc, PPC);
|
|
135
|
+
DEFINE_inc_detail_op_count(tricore, TriCore);
|
|
136
|
+
DEFINE_dec_detail_op_count(tricore, TriCore);
|
|
137
|
+
|
|
138
|
+
/// Returns true if a memory operand is currently edited.
|
|
139
|
+
static inline bool doing_mem(const MCInst *MI)
|
|
140
|
+
{
|
|
141
|
+
return MI->csh->doing_mem;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/// Sets the doing_mem flag to @status.
|
|
145
|
+
static inline void set_doing_mem(const MCInst *MI, bool status)
|
|
146
|
+
{
|
|
147
|
+
MI->csh->doing_mem = status;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// Returns detail->arch
|
|
151
|
+
#define DEFINE_get_arch_detail(arch, ARCH) \
|
|
152
|
+
static inline cs_##arch *ARCH##_get_detail(const MCInst *MI) \
|
|
153
|
+
{ \
|
|
154
|
+
assert(MI && MI->flat_insn && MI->flat_insn->detail); \
|
|
155
|
+
return &MI->flat_insn->detail->arch; \
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
DEFINE_get_arch_detail(arm, ARM);
|
|
159
|
+
DEFINE_get_arch_detail(ppc, PPC);
|
|
160
|
+
DEFINE_get_arch_detail(tricore, TriCore);
|
|
161
|
+
|
|
162
|
+
static inline bool detail_is_set(const MCInst *MI)
|
|
163
|
+
{
|
|
164
|
+
assert(MI && MI->flat_insn);
|
|
165
|
+
return MI->flat_insn->detail != NULL;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static inline cs_detail *get_detail(const MCInst *MI)
|
|
169
|
+
{
|
|
170
|
+
assert(MI && MI->flat_insn);
|
|
171
|
+
return MI->flat_insn->detail;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
#endif // CS_MAPPING_H
|