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,45 @@
|
|
|
1
|
+
/* Capstone Disassembly Engine */
|
|
2
|
+
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2015 */
|
|
3
|
+
|
|
4
|
+
#ifdef CAPSTONE_HAS_POWERPC
|
|
5
|
+
|
|
6
|
+
#include "../../utils.h"
|
|
7
|
+
#include "../../MCRegisterInfo.h"
|
|
8
|
+
#include "PPCDisassembler.h"
|
|
9
|
+
#include "PPCInstPrinter.h"
|
|
10
|
+
#include "PPCMapping.h"
|
|
11
|
+
#include "PPCModule.h"
|
|
12
|
+
|
|
13
|
+
cs_err PPC_global_init(cs_struct *ud)
|
|
14
|
+
{
|
|
15
|
+
MCRegisterInfo *mri;
|
|
16
|
+
mri = (MCRegisterInfo *) cs_mem_malloc(sizeof(*mri));
|
|
17
|
+
|
|
18
|
+
PPC_init(mri);
|
|
19
|
+
ud->printer = PPC_printInst;
|
|
20
|
+
ud->printer_info = mri;
|
|
21
|
+
ud->getinsn_info = mri;
|
|
22
|
+
ud->disasm = PPC_getInstruction;
|
|
23
|
+
ud->post_printer = PPC_post_printer;
|
|
24
|
+
|
|
25
|
+
ud->reg_name = PPC_reg_name;
|
|
26
|
+
ud->insn_id = PPC_get_insn_id;
|
|
27
|
+
ud->insn_name = PPC_insn_name;
|
|
28
|
+
ud->group_name = PPC_group_name;
|
|
29
|
+
|
|
30
|
+
return CS_ERR_OK;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
cs_err PPC_option(cs_struct *handle, cs_opt_type type, size_t value)
|
|
34
|
+
{
|
|
35
|
+
if (type == CS_OPT_SYNTAX)
|
|
36
|
+
handle->syntax = (int) value;
|
|
37
|
+
|
|
38
|
+
if (type == CS_OPT_MODE) {
|
|
39
|
+
handle->mode = (cs_mode)value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return CS_ERR_OK;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#endif
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* Capstone Disassembly Engine */
|
|
2
|
+
/* By Travis Finkenauer <tmfinken@gmail.com>, 2018 */
|
|
3
|
+
|
|
4
|
+
#ifndef CS_POWERPC_MODULE_H
|
|
5
|
+
#define CS_POWERPC_MODULE_H
|
|
6
|
+
|
|
7
|
+
#include "../../utils.h"
|
|
8
|
+
|
|
9
|
+
cs_err PPC_global_init(cs_struct *ud);
|
|
10
|
+
cs_err PPC_option(cs_struct *handle, cs_opt_type type, size_t value);
|
|
11
|
+
|
|
12
|
+
#endif
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//===-- PPCPredicates.h - PPC Branch Predicate Information ------*- 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 the PowerPC branch predicates.
|
|
11
|
+
//
|
|
12
|
+
//===----------------------------------------------------------------------===//
|
|
13
|
+
|
|
14
|
+
/* Capstone Disassembly Engine */
|
|
15
|
+
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2015 */
|
|
16
|
+
|
|
17
|
+
#ifndef CS_POWERPC_PPCPREDICATES_H
|
|
18
|
+
#define CS_POWERPC_PPCPREDICATES_H
|
|
19
|
+
|
|
20
|
+
#include "capstone/ppc.h"
|
|
21
|
+
|
|
22
|
+
// NOTE: duplicate of ppc_bc in ppc.h to maitain code compatibility with LLVM
|
|
23
|
+
typedef enum ppc_predicate {
|
|
24
|
+
PPC_PRED_LT = (0 << 5) | 12,
|
|
25
|
+
PPC_PRED_LE = (1 << 5) | 4,
|
|
26
|
+
PPC_PRED_EQ = (2 << 5) | 12,
|
|
27
|
+
PPC_PRED_GE = (0 << 5) | 4,
|
|
28
|
+
PPC_PRED_GT = (1 << 5) | 12,
|
|
29
|
+
PPC_PRED_NE = (2 << 5) | 4,
|
|
30
|
+
PPC_PRED_UN = (3 << 5) | 12,
|
|
31
|
+
PPC_PRED_NU = (3 << 5) | 4,
|
|
32
|
+
PPC_PRED_LT_MINUS = (0 << 5) | 14,
|
|
33
|
+
PPC_PRED_LE_MINUS = (1 << 5) | 6,
|
|
34
|
+
PPC_PRED_EQ_MINUS = (2 << 5) | 14,
|
|
35
|
+
PPC_PRED_GE_MINUS = (0 << 5) | 6,
|
|
36
|
+
PPC_PRED_GT_MINUS = (1 << 5) | 14,
|
|
37
|
+
PPC_PRED_NE_MINUS = (2 << 5) | 6,
|
|
38
|
+
PPC_PRED_UN_MINUS = (3 << 5) | 14,
|
|
39
|
+
PPC_PRED_NU_MINUS = (3 << 5) | 6,
|
|
40
|
+
PPC_PRED_LT_PLUS = (0 << 5) | 15,
|
|
41
|
+
PPC_PRED_LE_PLUS = (1 << 5) | 7,
|
|
42
|
+
PPC_PRED_EQ_PLUS = (2 << 5) | 15,
|
|
43
|
+
PPC_PRED_GE_PLUS = (0 << 5) | 7,
|
|
44
|
+
PPC_PRED_GT_PLUS = (1 << 5) | 15,
|
|
45
|
+
PPC_PRED_NE_PLUS = (2 << 5) | 7,
|
|
46
|
+
PPC_PRED_UN_PLUS = (3 << 5) | 15,
|
|
47
|
+
PPC_PRED_NU_PLUS = (3 << 5) | 7,
|
|
48
|
+
|
|
49
|
+
// When dealing with individual condition-register bits, we have simple set
|
|
50
|
+
// and unset predicates.
|
|
51
|
+
PPC_PRED_BIT_SET = 1024,
|
|
52
|
+
PPC_PRED_BIT_UNSET = 1025
|
|
53
|
+
} ppc_predicate;
|
|
54
|
+
|
|
55
|
+
/// Invert the specified predicate. != -> ==, < -> >=.
|
|
56
|
+
ppc_predicate InvertPredicate(ppc_predicate Opcode);
|
|
57
|
+
|
|
58
|
+
/// Assume the condition register is set by MI(a,b), return the predicate if
|
|
59
|
+
/// we modify the instructions such that condition register is set by MI(b,a).
|
|
60
|
+
ppc_predicate getSwappedPredicate(ppc_predicate Opcode);
|
|
61
|
+
|
|
62
|
+
#endif
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//===-- RISCVBaseInfo.h - Top level definitions for RISCV MC ----*- 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 contains small standalone enum definitions for the RISCV target
|
|
11
|
+
// useful for the compiler back-end and the MC libraries.
|
|
12
|
+
//
|
|
13
|
+
//===----------------------------------------------------------------------===//
|
|
14
|
+
#ifndef CS_RISCVBASEINFO_H
|
|
15
|
+
#define CS_RISCVBASEINFO_H
|
|
16
|
+
#include "../../cs_priv.h"
|
|
17
|
+
|
|
18
|
+
//#include "RISCVMCTargetDesc.h"
|
|
19
|
+
|
|
20
|
+
// RISCVII - This namespace holds all of the target specific flags that
|
|
21
|
+
// instruction info tracks. All definitions must match RISCVInstrFormats.td.
|
|
22
|
+
enum {
|
|
23
|
+
IRISCVII_InstFormatPseudo = 0,
|
|
24
|
+
IRISCVII_InstFormatR = 1,
|
|
25
|
+
IRISCVII_InstFormatR4 = 2,
|
|
26
|
+
IRISCVII_InstFormatI = 3,
|
|
27
|
+
IRISCVII_InstFormatS = 4,
|
|
28
|
+
IRISCVII_InstFormatB = 5,
|
|
29
|
+
IRISCVII_InstFormatU = 6,
|
|
30
|
+
IRISCVII_InstFormatJ = 7,
|
|
31
|
+
IRISCVII_InstFormatCR = 8,
|
|
32
|
+
IRISCVII_InstFormatCI = 9,
|
|
33
|
+
IRISCVII_InstFormatCSS = 10,
|
|
34
|
+
IRISCVII_InstFormatCIW = 11,
|
|
35
|
+
IRISCVII_InstFormatCL = 12,
|
|
36
|
+
IRISCVII_InstFormatCS = 13,
|
|
37
|
+
IRISCVII_InstFormatCA = 14,
|
|
38
|
+
IRISCVII_InstFormatCB = 15,
|
|
39
|
+
IRISCVII_InstFormatCJ = 16,
|
|
40
|
+
IRISCVII_InstFormatOther = 17,
|
|
41
|
+
|
|
42
|
+
IRISCVII_InstFormatMask = 31
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
enum {
|
|
46
|
+
RISCVII_MO_None,
|
|
47
|
+
RISCVII_MO_LO,
|
|
48
|
+
RISCVII_MO_HI,
|
|
49
|
+
RISCVII_MO_PCREL_HI,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Describes the predecessor/successor bits used in the FENCE instruction.
|
|
53
|
+
enum FenceField {
|
|
54
|
+
RISCVFenceField_I = 8,
|
|
55
|
+
RISCVFenceField_O = 4,
|
|
56
|
+
RISCVFenceField_R = 2,
|
|
57
|
+
RISCVFenceField_W = 1
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Describes the supported floating point rounding mode encodings.
|
|
61
|
+
enum RoundingMode {
|
|
62
|
+
RISCVFPRndMode_RNE = 0,
|
|
63
|
+
RISCVFPRndMode_RTZ = 1,
|
|
64
|
+
RISCVFPRndMode_RDN = 2,
|
|
65
|
+
RISCVFPRndMode_RUP = 3,
|
|
66
|
+
RISCVFPRndMode_RMM = 4,
|
|
67
|
+
RISCVFPRndMode_DYN = 7,
|
|
68
|
+
RISCVFPRndMode_Invalid
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
inline static const char *roundingModeToString(enum RoundingMode RndMode)
|
|
72
|
+
{
|
|
73
|
+
switch (RndMode) {
|
|
74
|
+
default:
|
|
75
|
+
CS_ASSERT(0 && "Unknown floating point rounding mode");
|
|
76
|
+
case RISCVFPRndMode_RNE:
|
|
77
|
+
return "rne";
|
|
78
|
+
case RISCVFPRndMode_RTZ:
|
|
79
|
+
return "rtz";
|
|
80
|
+
case RISCVFPRndMode_RDN:
|
|
81
|
+
return "rdn";
|
|
82
|
+
case RISCVFPRndMode_RUP:
|
|
83
|
+
return "rup";
|
|
84
|
+
case RISCVFPRndMode_RMM:
|
|
85
|
+
return "rmm";
|
|
86
|
+
case RISCVFPRndMode_DYN:
|
|
87
|
+
return "dyn";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
inline static bool RISCVFPRndMode_isValidRoundingMode(unsigned Mode)
|
|
92
|
+
{
|
|
93
|
+
switch (Mode) {
|
|
94
|
+
default:
|
|
95
|
+
return false;
|
|
96
|
+
case RISCVFPRndMode_RNE:
|
|
97
|
+
case RISCVFPRndMode_RTZ:
|
|
98
|
+
case RISCVFPRndMode_RDN:
|
|
99
|
+
case RISCVFPRndMode_RUP:
|
|
100
|
+
case RISCVFPRndMode_RMM:
|
|
101
|
+
case RISCVFPRndMode_DYN:
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#endif
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
//===-- RISCVDisassembler.cpp - Disassembler for RISCV --------------------===//
|
|
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
|
+
/* Capstone Disassembly Engine */
|
|
11
|
+
/* RISC-V Backend By Rodrigo Cortes Porto <porto703@gmail.com> &
|
|
12
|
+
Shawn Chang <citypw@gmail.com>, HardenedLinux@2018 */
|
|
13
|
+
|
|
14
|
+
#ifdef CAPSTONE_HAS_RISCV
|
|
15
|
+
|
|
16
|
+
#include <stdio.h> // DEBUG
|
|
17
|
+
#include <stdlib.h>
|
|
18
|
+
#include <string.h>
|
|
19
|
+
|
|
20
|
+
#include "../../cs_priv.h"
|
|
21
|
+
#include "../../utils.h"
|
|
22
|
+
|
|
23
|
+
#include "../../MCInst.h"
|
|
24
|
+
#include "../../MCInstrDesc.h"
|
|
25
|
+
#include "../../MCFixedLenDisassembler.h"
|
|
26
|
+
#include "../../MCRegisterInfo.h"
|
|
27
|
+
#include "../../MCDisassembler.h"
|
|
28
|
+
#include "../../MathExtras.h"
|
|
29
|
+
#include "RISCVBaseInfo.h"
|
|
30
|
+
#include "RISCVDisassembler.h"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/* Need the feature infos define in
|
|
34
|
+
RISCVGenSubtargetInfo.inc. */
|
|
35
|
+
#define GET_SUBTARGETINFO_ENUM
|
|
36
|
+
#include "RISCVGenSubtargetInfo.inc"
|
|
37
|
+
|
|
38
|
+
/* When we specify the RISCV64 mode, It means It is RV64IMAFD.
|
|
39
|
+
Similar, RISCV32 means RV32IMAFD.
|
|
40
|
+
*/
|
|
41
|
+
static uint64_t getFeatureBits(int mode)
|
|
42
|
+
{
|
|
43
|
+
uint64_t ret = RISCV_FeatureStdExtM | RISCV_FeatureStdExtA |
|
|
44
|
+
RISCV_FeatureStdExtF | RISCV_FeatureStdExtD ;
|
|
45
|
+
|
|
46
|
+
if (mode & CS_MODE_RISCV64)
|
|
47
|
+
ret |= RISCV_Feature64Bit;
|
|
48
|
+
if (mode & CS_MODE_RISCVC)
|
|
49
|
+
ret |= RISCV_FeatureStdExtC;
|
|
50
|
+
|
|
51
|
+
return ret;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#define GET_REGINFO_ENUM
|
|
55
|
+
#define GET_REGINFO_MC_DESC
|
|
56
|
+
#include "RISCVGenRegisterInfo.inc"
|
|
57
|
+
#define GET_INSTRINFO_ENUM
|
|
58
|
+
#include "RISCVGenInstrInfo.inc"
|
|
59
|
+
|
|
60
|
+
static const unsigned GPRDecoderTable[] = {
|
|
61
|
+
RISCV_X0, RISCV_X1, RISCV_X2, RISCV_X3,
|
|
62
|
+
RISCV_X4, RISCV_X5, RISCV_X6, RISCV_X7,
|
|
63
|
+
RISCV_X8, RISCV_X9, RISCV_X10, RISCV_X11,
|
|
64
|
+
RISCV_X12, RISCV_X13, RISCV_X14, RISCV_X15,
|
|
65
|
+
RISCV_X16, RISCV_X17, RISCV_X18, RISCV_X19,
|
|
66
|
+
RISCV_X20, RISCV_X21, RISCV_X22, RISCV_X23,
|
|
67
|
+
RISCV_X24, RISCV_X25, RISCV_X26, RISCV_X27,
|
|
68
|
+
RISCV_X28, RISCV_X29, RISCV_X30, RISCV_X31
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
static DecodeStatus DecodeGPRRegisterClass(MCInst *Inst, uint64_t RegNo,
|
|
72
|
+
uint64_t Address, const void *Decoder)
|
|
73
|
+
{
|
|
74
|
+
unsigned Reg = 0;
|
|
75
|
+
|
|
76
|
+
if (RegNo >= ARR_SIZE(GPRDecoderTable))
|
|
77
|
+
return MCDisassembler_Fail;
|
|
78
|
+
|
|
79
|
+
// We must define our own mapping from RegNo to register identifier.
|
|
80
|
+
// Accessing index RegNo in the register class will work in the case that
|
|
81
|
+
// registers were added in ascending order, but not in general.
|
|
82
|
+
Reg = GPRDecoderTable[RegNo];
|
|
83
|
+
//Inst.addOperand(MCOperand::createReg(Reg));
|
|
84
|
+
MCOperand_CreateReg0(Inst, Reg);
|
|
85
|
+
return MCDisassembler_Success;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static const unsigned FPR32DecoderTable[] = {
|
|
89
|
+
RISCV_F0_32, RISCV_F1_32, RISCV_F2_32, RISCV_F3_32,
|
|
90
|
+
RISCV_F4_32, RISCV_F5_32, RISCV_F6_32, RISCV_F7_32,
|
|
91
|
+
RISCV_F8_32, RISCV_F9_32, RISCV_F10_32, RISCV_F11_32,
|
|
92
|
+
RISCV_F12_32, RISCV_F13_32, RISCV_F14_32, RISCV_F15_32,
|
|
93
|
+
RISCV_F16_32, RISCV_F17_32, RISCV_F18_32, RISCV_F19_32,
|
|
94
|
+
RISCV_F20_32, RISCV_F21_32, RISCV_F22_32, RISCV_F23_32,
|
|
95
|
+
RISCV_F24_32, RISCV_F25_32, RISCV_F26_32, RISCV_F27_32,
|
|
96
|
+
RISCV_F28_32, RISCV_F29_32, RISCV_F30_32, RISCV_F31_32
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
static DecodeStatus DecodeFPR32RegisterClass(MCInst *Inst, uint64_t RegNo,
|
|
100
|
+
uint64_t Address, const void *Decoder)
|
|
101
|
+
{
|
|
102
|
+
unsigned Reg = 0;
|
|
103
|
+
|
|
104
|
+
if (RegNo >= ARR_SIZE(FPR32DecoderTable))
|
|
105
|
+
return MCDisassembler_Fail;
|
|
106
|
+
|
|
107
|
+
// We must define our own mapping from RegNo to register identifier.
|
|
108
|
+
// Accessing index RegNo in the register class will work in the case that
|
|
109
|
+
// registers were added in ascending order, but not in general.
|
|
110
|
+
Reg = FPR32DecoderTable[RegNo];
|
|
111
|
+
MCOperand_CreateReg0(Inst, Reg);
|
|
112
|
+
return MCDisassembler_Success;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static DecodeStatus DecodeFPR32CRegisterClass(MCInst *Inst, uint64_t RegNo,
|
|
116
|
+
uint64_t Address,
|
|
117
|
+
const void *Decoder)
|
|
118
|
+
{
|
|
119
|
+
unsigned Reg = 0;
|
|
120
|
+
|
|
121
|
+
if (RegNo > 8)
|
|
122
|
+
return MCDisassembler_Fail;
|
|
123
|
+
Reg = FPR32DecoderTable[RegNo + 8];
|
|
124
|
+
MCOperand_CreateReg0(Inst, Reg);
|
|
125
|
+
return MCDisassembler_Success;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
static const unsigned FPR64DecoderTable[] = {
|
|
129
|
+
RISCV_F0_64, RISCV_F1_64, RISCV_F2_64, RISCV_F3_64,
|
|
130
|
+
RISCV_F4_64, RISCV_F5_64, RISCV_F6_64, RISCV_F7_64,
|
|
131
|
+
RISCV_F8_64, RISCV_F9_64, RISCV_F10_64, RISCV_F11_64,
|
|
132
|
+
RISCV_F12_64, RISCV_F13_64, RISCV_F14_64, RISCV_F15_64,
|
|
133
|
+
RISCV_F16_64, RISCV_F17_64, RISCV_F18_64, RISCV_F19_64,
|
|
134
|
+
RISCV_F20_64, RISCV_F21_64, RISCV_F22_64, RISCV_F23_64,
|
|
135
|
+
RISCV_F24_64, RISCV_F25_64, RISCV_F26_64, RISCV_F27_64,
|
|
136
|
+
RISCV_F28_64, RISCV_F29_64, RISCV_F30_64, RISCV_F31_64
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
static DecodeStatus DecodeFPR64RegisterClass(MCInst *Inst, uint64_t RegNo,
|
|
140
|
+
uint64_t Address, const void *Decoder)
|
|
141
|
+
{
|
|
142
|
+
unsigned Reg = 0;
|
|
143
|
+
|
|
144
|
+
if (RegNo >= ARR_SIZE(FPR64DecoderTable))
|
|
145
|
+
return MCDisassembler_Fail;
|
|
146
|
+
|
|
147
|
+
// We must define our own mapping from RegNo to register identifier.
|
|
148
|
+
// Accessing index RegNo in the register class will work in the case that
|
|
149
|
+
// registers were added in ascending order, but not in general.
|
|
150
|
+
Reg = FPR64DecoderTable[RegNo];
|
|
151
|
+
MCOperand_CreateReg0(Inst, Reg);
|
|
152
|
+
return MCDisassembler_Success;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static DecodeStatus DecodeFPR64CRegisterClass(MCInst *Inst, uint64_t RegNo,
|
|
156
|
+
uint64_t Address,
|
|
157
|
+
const void *Decoder)
|
|
158
|
+
{
|
|
159
|
+
unsigned Reg = 0;
|
|
160
|
+
|
|
161
|
+
if (RegNo > 8)
|
|
162
|
+
return MCDisassembler_Fail;
|
|
163
|
+
Reg = FPR64DecoderTable[RegNo + 8];
|
|
164
|
+
MCOperand_CreateReg0(Inst, Reg);
|
|
165
|
+
return MCDisassembler_Success;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static DecodeStatus DecodeGPRNoX0RegisterClass(MCInst *Inst, uint64_t RegNo,
|
|
169
|
+
uint64_t Address,
|
|
170
|
+
const void *Decoder)
|
|
171
|
+
{
|
|
172
|
+
if (RegNo == 0)
|
|
173
|
+
return MCDisassembler_Fail;
|
|
174
|
+
return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
static DecodeStatus DecodeGPRNoX0X2RegisterClass(MCInst *Inst, uint64_t RegNo,
|
|
178
|
+
uint64_t Address,
|
|
179
|
+
const void *Decoder)
|
|
180
|
+
{
|
|
181
|
+
if (RegNo == 2)
|
|
182
|
+
return MCDisassembler_Fail;
|
|
183
|
+
return DecodeGPRNoX0RegisterClass(Inst, RegNo, Address, Decoder);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
static DecodeStatus DecodeGPRCRegisterClass(MCInst *Inst, uint64_t RegNo,
|
|
187
|
+
uint64_t Address,
|
|
188
|
+
const void *Decoder)
|
|
189
|
+
{
|
|
190
|
+
unsigned Reg = 0;
|
|
191
|
+
|
|
192
|
+
if (RegNo > 8)
|
|
193
|
+
return MCDisassembler_Fail;
|
|
194
|
+
|
|
195
|
+
Reg = GPRDecoderTable[RegNo + 8];
|
|
196
|
+
MCOperand_CreateReg0(Inst, Reg);
|
|
197
|
+
return MCDisassembler_Success;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Add implied SP operand for instructions *SP compressed instructions. The SP
|
|
201
|
+
// operand isn't explicitly encoded in the instruction.
|
|
202
|
+
static void addImplySP(MCInst *Inst, int64_t Address, const void *Decoder)
|
|
203
|
+
{
|
|
204
|
+
if (MCInst_getOpcode(Inst) == RISCV_C_LWSP ||
|
|
205
|
+
MCInst_getOpcode(Inst) == RISCV_C_SWSP ||
|
|
206
|
+
MCInst_getOpcode(Inst) == RISCV_C_LDSP ||
|
|
207
|
+
MCInst_getOpcode(Inst) == RISCV_C_SDSP ||
|
|
208
|
+
MCInst_getOpcode(Inst) == RISCV_C_FLWSP ||
|
|
209
|
+
MCInst_getOpcode(Inst) == RISCV_C_FSWSP ||
|
|
210
|
+
MCInst_getOpcode(Inst) == RISCV_C_FLDSP ||
|
|
211
|
+
MCInst_getOpcode(Inst) == RISCV_C_FSDSP ||
|
|
212
|
+
MCInst_getOpcode(Inst) == RISCV_C_ADDI4SPN) {
|
|
213
|
+
DecodeGPRRegisterClass(Inst, 2, Address, Decoder);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (MCInst_getOpcode(Inst) == RISCV_C_ADDI16SP) {
|
|
217
|
+
DecodeGPRRegisterClass(Inst, 2, Address, Decoder);
|
|
218
|
+
DecodeGPRRegisterClass(Inst, 2, Address, Decoder);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
static DecodeStatus decodeUImmOperand(MCInst *Inst, uint64_t Imm,
|
|
223
|
+
int64_t Address, const void *Decoder,
|
|
224
|
+
unsigned N)
|
|
225
|
+
{
|
|
226
|
+
//CS_ASSERT(isUInt<N>(Imm) && "Invalid immediate");
|
|
227
|
+
addImplySP(Inst, Address, Decoder);
|
|
228
|
+
//Inst.addOperand(MCOperand::createImm(Imm));
|
|
229
|
+
MCOperand_CreateImm0(Inst, Imm);
|
|
230
|
+
return MCDisassembler_Success;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
static DecodeStatus decodeUImmNonZeroOperand(MCInst *Inst, uint64_t Imm,
|
|
234
|
+
int64_t Address,
|
|
235
|
+
const void *Decoder,
|
|
236
|
+
unsigned N)
|
|
237
|
+
{
|
|
238
|
+
if (Imm == 0)
|
|
239
|
+
return MCDisassembler_Fail;
|
|
240
|
+
return decodeUImmOperand(Inst, Imm, Address, Decoder, N);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
static DecodeStatus decodeSImmOperand(MCInst *Inst, uint64_t Imm,
|
|
244
|
+
int64_t Address, const void *Decoder,
|
|
245
|
+
unsigned N)
|
|
246
|
+
{
|
|
247
|
+
//CS_ASSERT(isUInt<N>(Imm) && "Invalid immediate");
|
|
248
|
+
addImplySP(Inst, Address, Decoder);
|
|
249
|
+
// Sign-extend the number in the bottom N bits of Imm
|
|
250
|
+
//Inst.addOperand(MCOperand::createImm(SignExtend64<N>(Imm)));
|
|
251
|
+
MCOperand_CreateImm0(Inst, SignExtend64(Imm, N));
|
|
252
|
+
return MCDisassembler_Success;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
static DecodeStatus decodeSImmNonZeroOperand(MCInst *Inst, uint64_t Imm,
|
|
256
|
+
int64_t Address,
|
|
257
|
+
const void *Decoder,
|
|
258
|
+
unsigned N)
|
|
259
|
+
{
|
|
260
|
+
if (Imm == 0)
|
|
261
|
+
return MCDisassembler_Fail;
|
|
262
|
+
return decodeSImmOperand(Inst, Imm, Address, Decoder, N);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
static DecodeStatus decodeSImmOperandAndLsl1(MCInst *Inst, uint64_t Imm,
|
|
266
|
+
int64_t Address,
|
|
267
|
+
const void *Decoder,
|
|
268
|
+
unsigned N)
|
|
269
|
+
{
|
|
270
|
+
//CS_ASSERT(isUInt<N>(Imm) && "Invalid immediate");
|
|
271
|
+
// Sign-extend the number in the bottom N bits of Imm after accounting for
|
|
272
|
+
// the fact that the N bit immediate is stored in N-1 bits (the LSB is
|
|
273
|
+
// always zero)
|
|
274
|
+
//Inst.addOperand(MCOperand::createImm(SignExtend64<N>(Imm << 1)));
|
|
275
|
+
MCOperand_CreateImm0(Inst, SignExtend64(Imm << 1, N));
|
|
276
|
+
return MCDisassembler_Success;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
static DecodeStatus decodeCLUIImmOperand(MCInst *Inst, uint64_t Imm,
|
|
280
|
+
int64_t Address,
|
|
281
|
+
const void *Decoder)
|
|
282
|
+
{
|
|
283
|
+
//CS_ASSERT(isUInt<6>(Imm) && "Invalid immediate");
|
|
284
|
+
if (Imm > 31) {
|
|
285
|
+
Imm = (SignExtend64(Imm, 6) & 0xfffff);
|
|
286
|
+
}
|
|
287
|
+
//Inst.addOperand(MCOperand::createImm(Imm));
|
|
288
|
+
MCOperand_CreateImm0(Inst, Imm);
|
|
289
|
+
return MCDisassembler_Success;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
static DecodeStatus decodeFRMArg(MCInst *Inst, uint64_t Imm,
|
|
293
|
+
int64_t Address,
|
|
294
|
+
const void *Decoder)
|
|
295
|
+
{
|
|
296
|
+
//CS_ASSERT(isUInt<3>(Imm) && "Invalid immediate");
|
|
297
|
+
if (!RISCVFPRndMode_isValidRoundingMode(Imm))
|
|
298
|
+
return MCDisassembler_Fail;
|
|
299
|
+
|
|
300
|
+
//Inst.addOperand(MCOperand::createImm(Imm));
|
|
301
|
+
MCOperand_CreateImm0(Inst, Imm);
|
|
302
|
+
return MCDisassembler_Success;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
#include "RISCVGenDisassemblerTables.inc"
|
|
307
|
+
|
|
308
|
+
static void init_MI_insn_detail(MCInst *MI)
|
|
309
|
+
{
|
|
310
|
+
if (MI->flat_insn->detail) {
|
|
311
|
+
memset(MI->flat_insn->detail, 0, sizeof(cs_detail));
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// mark the load/store instructions through the opcode.
|
|
318
|
+
static void markLSInsn(MCInst *MI, uint32_t in)
|
|
319
|
+
{
|
|
320
|
+
/*
|
|
321
|
+
I ld 0000011 = 0x03
|
|
322
|
+
st 0100011 = 0x23
|
|
323
|
+
F/D ld 0000111 = 0x07
|
|
324
|
+
st 0100111 = 0x27
|
|
325
|
+
*/
|
|
326
|
+
#define MASK_LS_INSN 0x0000007f
|
|
327
|
+
uint32_t opcode = in & MASK_LS_INSN;
|
|
328
|
+
if (0 == (opcode ^ 0x03) || 0 == (opcode ^ 0x07) ||
|
|
329
|
+
0 == (opcode ^ 0x23) || 0 == (opcode ^ 0x27))
|
|
330
|
+
MI->flat_insn->detail->riscv.need_effective_addr = true;
|
|
331
|
+
#undef MASK_LS_INSN
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
static DecodeStatus RISCVDisassembler_getInstruction(int mode, MCInst *MI,
|
|
336
|
+
const uint8_t *code, size_t code_len,
|
|
337
|
+
uint16_t *Size, uint64_t Address,
|
|
338
|
+
MCRegisterInfo *MRI)
|
|
339
|
+
{
|
|
340
|
+
// TODO: This will need modification when supporting instruction set
|
|
341
|
+
// extensions with instructions > 32-bits (up to 176 bits wide).
|
|
342
|
+
uint32_t Inst = 0;
|
|
343
|
+
DecodeStatus Result;
|
|
344
|
+
|
|
345
|
+
// It's a 32 bit instruction if bit 0 and 1 are 1.
|
|
346
|
+
if ((code[0] & 0x3) == 0x3) {
|
|
347
|
+
if (code_len < 4) {
|
|
348
|
+
*Size = 0;
|
|
349
|
+
return MCDisassembler_Fail;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
*Size = 4;
|
|
353
|
+
// Get the four bytes of the instruction.
|
|
354
|
+
//Encoded as little endian 32 bits.
|
|
355
|
+
Inst = code[0] | (code[1] << 8) | (code[2] << 16) | ((uint32_t)code[3] << 24);
|
|
356
|
+
init_MI_insn_detail(MI);
|
|
357
|
+
// Now we need mark what instruction need fix effective address output.
|
|
358
|
+
if (MI->csh->detail)
|
|
359
|
+
markLSInsn(MI, Inst);
|
|
360
|
+
Result = decodeInstruction(DecoderTable32, MI, Inst, Address, MRI, mode);
|
|
361
|
+
} else {
|
|
362
|
+
if (code_len < 2) {
|
|
363
|
+
*Size = 0;
|
|
364
|
+
return MCDisassembler_Fail;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// If not b4bit.
|
|
368
|
+
if (! (getFeatureBits(mode) & ((uint64_t)RISCV_Feature64Bit))) {
|
|
369
|
+
// Trying RISCV32Only_16 table (16-bit Instruction)
|
|
370
|
+
Inst = code[0] | (code[1] << 8);
|
|
371
|
+
init_MI_insn_detail(MI);
|
|
372
|
+
Result = decodeInstruction(DecoderTableRISCV32Only_16, MI, Inst, Address,
|
|
373
|
+
MRI, mode);
|
|
374
|
+
if (Result != MCDisassembler_Fail) {
|
|
375
|
+
*Size = 2;
|
|
376
|
+
return Result;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Trying RISCV_C table (16-bit Instruction)
|
|
381
|
+
Inst = code[0] | (code[1] << 8);
|
|
382
|
+
init_MI_insn_detail(MI);
|
|
383
|
+
// Calling the auto-generated decoder function.
|
|
384
|
+
Result = decodeInstruction(DecoderTable16, MI, Inst, Address, MRI, mode);
|
|
385
|
+
*Size = 2;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return Result;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
bool RISCV_getInstruction(csh ud, const uint8_t *code, size_t code_len,
|
|
392
|
+
MCInst *instr, uint16_t *size, uint64_t address,
|
|
393
|
+
void *info)
|
|
394
|
+
{
|
|
395
|
+
cs_struct *handle = (cs_struct *)(uintptr_t)ud;
|
|
396
|
+
|
|
397
|
+
return MCDisassembler_Success ==
|
|
398
|
+
RISCVDisassembler_getInstruction(handle->mode, instr,
|
|
399
|
+
code, code_len,
|
|
400
|
+
size, address,
|
|
401
|
+
(MCRegisterInfo *)info);
|
|
402
|
+
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
void RISCV_init(MCRegisterInfo * MRI)
|
|
406
|
+
{
|
|
407
|
+
/*
|
|
408
|
+
InitMCRegisterInfo(RISCVRegDesc, 97, RA, PC,
|
|
409
|
+
RISCVMCRegisterClasses, 11,
|
|
410
|
+
RISCVRegUnitRoots,
|
|
411
|
+
64,
|
|
412
|
+
RISCVRegDiffLists,
|
|
413
|
+
RISCVLaneMaskLists,
|
|
414
|
+
RISCVRegStrings,
|
|
415
|
+
RISCVRegClassStrings,
|
|
416
|
+
RISCVSubRegIdxLists,
|
|
417
|
+
2,
|
|
418
|
+
RISCVSubRegIdxRanges,
|
|
419
|
+
RISCVRegEncodingTable);
|
|
420
|
+
*/
|
|
421
|
+
|
|
422
|
+
MCRegisterInfo_InitMCRegisterInfo(MRI, RISCVRegDesc, 97, 0, 0,
|
|
423
|
+
RISCVMCRegisterClasses, 11,
|
|
424
|
+
0,
|
|
425
|
+
0,
|
|
426
|
+
RISCVRegDiffLists,
|
|
427
|
+
0,
|
|
428
|
+
RISCVSubRegIdxLists,
|
|
429
|
+
2,
|
|
430
|
+
0);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
#endif
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* Capstone Disassembly Engine */
|
|
2
|
+
/* RISC-V Backend By Rodrigo Cortes Porto <porto703@gmail.com> &
|
|
3
|
+
Shawn Chang <citypw@gmail.com>, HardenedLinux@2018 */
|
|
4
|
+
|
|
5
|
+
#ifndef CS_RISCVDISASSEMBLER_H
|
|
6
|
+
#define CS_RISCVDISASSEMBLER_H
|
|
7
|
+
|
|
8
|
+
#include "../../include/capstone/capstone.h"
|
|
9
|
+
#include "../../MCRegisterInfo.h"
|
|
10
|
+
#include "../../MCInst.h"
|
|
11
|
+
|
|
12
|
+
void RISCV_init(MCRegisterInfo *MRI);
|
|
13
|
+
|
|
14
|
+
bool RISCV_getInstruction(csh ud, const uint8_t *code, size_t code_len,
|
|
15
|
+
MCInst *instr, uint16_t *size, uint64_t address,
|
|
16
|
+
void *info);
|
|
17
|
+
|
|
18
|
+
#endif
|