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,442 @@
|
|
|
1
|
+
//===-- llvm/Support/MathExtras.h - Useful math functions -------*- 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 some functions that are useful for math stuff.
|
|
11
|
+
//
|
|
12
|
+
//===----------------------------------------------------------------------===//
|
|
13
|
+
|
|
14
|
+
/* Capstone Disassembly Engine */
|
|
15
|
+
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
|
|
16
|
+
|
|
17
|
+
#ifndef CS_LLVM_SUPPORT_MATHEXTRAS_H
|
|
18
|
+
#define CS_LLVM_SUPPORT_MATHEXTRAS_H
|
|
19
|
+
|
|
20
|
+
#if defined(_WIN32_WCE) && (_WIN32_WCE < 0x800)
|
|
21
|
+
#include "windowsce/intrin.h"
|
|
22
|
+
#elif defined(_MSC_VER)
|
|
23
|
+
#include <intrin.h>
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
#ifndef __cplusplus
|
|
27
|
+
#if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)
|
|
28
|
+
#define inline /* inline */
|
|
29
|
+
#endif
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
// NOTE: The following support functions use the _32/_64 extensions instead of
|
|
33
|
+
// type overloading so that signed and unsigned integers can be used without
|
|
34
|
+
// ambiguity.
|
|
35
|
+
|
|
36
|
+
/// Hi_32 - This function returns the high 32 bits of a 64 bit value.
|
|
37
|
+
static inline uint32_t Hi_32(uint64_t Value) {
|
|
38
|
+
return (uint32_t)(Value >> 32);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// Lo_32 - This function returns the low 32 bits of a 64 bit value.
|
|
42
|
+
static inline uint32_t Lo_32(uint64_t Value) {
|
|
43
|
+
return (uint32_t)(Value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// isUIntN - Checks if an unsigned integer fits into the given (dynamic)
|
|
47
|
+
/// bit width.
|
|
48
|
+
static inline bool isUIntN(unsigned N, uint64_t x) {
|
|
49
|
+
return x == (x & (~0ULL >> (64 - N)));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/// isIntN - Checks if an signed integer fits into the given (dynamic)
|
|
53
|
+
/// bit width.
|
|
54
|
+
//static inline bool isIntN(unsigned N, int64_t x) {
|
|
55
|
+
// return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1)));
|
|
56
|
+
//}
|
|
57
|
+
|
|
58
|
+
/// isMask_32 - This function returns true if the argument is a sequence of ones
|
|
59
|
+
/// starting at the least significant bit with the remainder zero (32 bit
|
|
60
|
+
/// version). Ex. isMask_32(0x0000FFFFU) == true.
|
|
61
|
+
static inline bool isMask_32(uint32_t Value) {
|
|
62
|
+
return Value && ((Value + 1) & Value) == 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/// isMask_64 - This function returns true if the argument is a sequence of ones
|
|
66
|
+
/// starting at the least significant bit with the remainder zero (64 bit
|
|
67
|
+
/// version).
|
|
68
|
+
static inline bool isMask_64(uint64_t Value) {
|
|
69
|
+
return Value && ((Value + 1) & Value) == 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// isShiftedMask_32 - This function returns true if the argument contains a
|
|
73
|
+
/// sequence of ones with the remainder zero (32 bit version.)
|
|
74
|
+
/// Ex. isShiftedMask_32(0x0000FF00U) == true.
|
|
75
|
+
static inline bool isShiftedMask_32(uint32_t Value) {
|
|
76
|
+
return isMask_32((Value - 1) | Value);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// isShiftedMask_64 - This function returns true if the argument contains a
|
|
80
|
+
/// sequence of ones with the remainder zero (64 bit version.)
|
|
81
|
+
static inline bool isShiftedMask_64(uint64_t Value) {
|
|
82
|
+
return isMask_64((Value - 1) | Value);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/// isPowerOf2_32 - This function returns true if the argument is a power of
|
|
86
|
+
/// two > 0. Ex. isPowerOf2_32(0x00100000U) == true (32 bit edition.)
|
|
87
|
+
static inline bool isPowerOf2_32(uint32_t Value) {
|
|
88
|
+
return Value && !(Value & (Value - 1));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/// CountLeadingZeros_32 - this function performs the platform optimal form of
|
|
92
|
+
/// counting the number of zeros from the most significant bit to the first one
|
|
93
|
+
/// bit. Ex. CountLeadingZeros_32(0x00F000FF) == 8.
|
|
94
|
+
/// Returns 32 if the word is zero.
|
|
95
|
+
static inline unsigned CountLeadingZeros_32(uint32_t Value) {
|
|
96
|
+
unsigned Count; // result
|
|
97
|
+
#if __GNUC__ >= 4
|
|
98
|
+
// PowerPC is defined for __builtin_clz(0)
|
|
99
|
+
#if !defined(__ppc__) && !defined(__ppc64__)
|
|
100
|
+
if (!Value) return 32;
|
|
101
|
+
#endif
|
|
102
|
+
Count = __builtin_clz(Value);
|
|
103
|
+
#else
|
|
104
|
+
unsigned Shift;
|
|
105
|
+
if (!Value) return 32;
|
|
106
|
+
Count = 0;
|
|
107
|
+
// bisection method for count leading zeros
|
|
108
|
+
for (Shift = 32 >> 1; Shift; Shift >>= 1) {
|
|
109
|
+
uint32_t Tmp = Value >> Shift;
|
|
110
|
+
if (Tmp) {
|
|
111
|
+
Value = Tmp;
|
|
112
|
+
} else {
|
|
113
|
+
Count |= Shift;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
#endif
|
|
117
|
+
return Count;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/// CountLeadingOnes_32 - this function performs the operation of
|
|
121
|
+
/// counting the number of ones from the most significant bit to the first zero
|
|
122
|
+
/// bit. Ex. CountLeadingOnes_32(0xFF0FFF00) == 8.
|
|
123
|
+
/// Returns 32 if the word is all ones.
|
|
124
|
+
static inline unsigned CountLeadingOnes_32(uint32_t Value) {
|
|
125
|
+
return CountLeadingZeros_32(~Value);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/// CountLeadingZeros_64 - This function performs the platform optimal form
|
|
129
|
+
/// of counting the number of zeros from the most significant bit to the first
|
|
130
|
+
/// one bit (64 bit edition.)
|
|
131
|
+
/// Returns 64 if the word is zero.
|
|
132
|
+
static inline unsigned CountLeadingZeros_64(uint64_t Value) {
|
|
133
|
+
unsigned Count; // result
|
|
134
|
+
#if __GNUC__ >= 4
|
|
135
|
+
// PowerPC is defined for __builtin_clzll(0)
|
|
136
|
+
#if !defined(__ppc__) && !defined(__ppc64__)
|
|
137
|
+
if (!Value) return 64;
|
|
138
|
+
#endif
|
|
139
|
+
Count = __builtin_clzll(Value);
|
|
140
|
+
#else
|
|
141
|
+
#ifndef _MSC_VER
|
|
142
|
+
unsigned Shift;
|
|
143
|
+
if (sizeof(long) == sizeof(int64_t))
|
|
144
|
+
{
|
|
145
|
+
if (!Value) return 64;
|
|
146
|
+
Count = 0;
|
|
147
|
+
// bisection method for count leading zeros
|
|
148
|
+
for (Shift = 64 >> 1; Shift; Shift >>= 1) {
|
|
149
|
+
uint64_t Tmp = Value >> Shift;
|
|
150
|
+
if (Tmp) {
|
|
151
|
+
Value = Tmp;
|
|
152
|
+
} else {
|
|
153
|
+
Count |= Shift;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else
|
|
158
|
+
#endif
|
|
159
|
+
{
|
|
160
|
+
// get hi portion
|
|
161
|
+
uint32_t Hi = Hi_32(Value);
|
|
162
|
+
|
|
163
|
+
// if some bits in hi portion
|
|
164
|
+
if (Hi) {
|
|
165
|
+
// leading zeros in hi portion plus all bits in lo portion
|
|
166
|
+
Count = CountLeadingZeros_32(Hi);
|
|
167
|
+
} else {
|
|
168
|
+
// get lo portion
|
|
169
|
+
uint32_t Lo = Lo_32(Value);
|
|
170
|
+
// same as 32 bit value
|
|
171
|
+
Count = CountLeadingZeros_32(Lo)+32;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
#endif
|
|
175
|
+
return Count;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/// CountLeadingOnes_64 - This function performs the operation
|
|
179
|
+
/// of counting the number of ones from the most significant bit to the first
|
|
180
|
+
/// zero bit (64 bit edition.)
|
|
181
|
+
/// Returns 64 if the word is all ones.
|
|
182
|
+
static inline unsigned CountLeadingOnes_64(uint64_t Value) {
|
|
183
|
+
return CountLeadingZeros_64(~Value);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/// CountTrailingZeros_32 - this function performs the platform optimal form of
|
|
187
|
+
/// counting the number of zeros from the least significant bit to the first one
|
|
188
|
+
/// bit. Ex. CountTrailingZeros_32(0xFF00FF00) == 8.
|
|
189
|
+
/// Returns 32 if the word is zero.
|
|
190
|
+
static inline unsigned CountTrailingZeros_32(uint32_t Value) {
|
|
191
|
+
#if __GNUC__ >= 4
|
|
192
|
+
return Value ? __builtin_ctz(Value) : 32;
|
|
193
|
+
#else
|
|
194
|
+
static const unsigned Mod37BitPosition[] = {
|
|
195
|
+
32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13,
|
|
196
|
+
4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9,
|
|
197
|
+
5, 20, 8, 19, 18
|
|
198
|
+
};
|
|
199
|
+
// Replace "-Value" by "1+~Value" in the following commented code to avoid
|
|
200
|
+
// MSVC warning C4146
|
|
201
|
+
// return Mod37BitPosition[(-Value & Value) % 37];
|
|
202
|
+
return Mod37BitPosition[((1 + ~Value) & Value) % 37];
|
|
203
|
+
#endif
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/// CountTrailingOnes_32 - this function performs the operation of
|
|
207
|
+
/// counting the number of ones from the least significant bit to the first zero
|
|
208
|
+
/// bit. Ex. CountTrailingOnes_32(0x00FF00FF) == 8.
|
|
209
|
+
/// Returns 32 if the word is all ones.
|
|
210
|
+
static inline unsigned CountTrailingOnes_32(uint32_t Value) {
|
|
211
|
+
return CountTrailingZeros_32(~Value);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/// CountTrailingZeros_64 - This function performs the platform optimal form
|
|
215
|
+
/// of counting the number of zeros from the least significant bit to the first
|
|
216
|
+
/// one bit (64 bit edition.)
|
|
217
|
+
/// Returns 64 if the word is zero.
|
|
218
|
+
static inline unsigned CountTrailingZeros_64(uint64_t Value) {
|
|
219
|
+
#if __GNUC__ >= 4
|
|
220
|
+
return Value ? __builtin_ctzll(Value) : 64;
|
|
221
|
+
#else
|
|
222
|
+
static const unsigned Mod67Position[] = {
|
|
223
|
+
64, 0, 1, 39, 2, 15, 40, 23, 3, 12, 16, 59, 41, 19, 24, 54,
|
|
224
|
+
4, 64, 13, 10, 17, 62, 60, 28, 42, 30, 20, 51, 25, 44, 55,
|
|
225
|
+
47, 5, 32, 65, 38, 14, 22, 11, 58, 18, 53, 63, 9, 61, 27,
|
|
226
|
+
29, 50, 43, 46, 31, 37, 21, 57, 52, 8, 26, 49, 45, 36, 56,
|
|
227
|
+
7, 48, 35, 6, 34, 33, 0
|
|
228
|
+
};
|
|
229
|
+
// Replace "-Value" by "1+~Value" in the following commented code to avoid
|
|
230
|
+
// MSVC warning C4146
|
|
231
|
+
// return Mod67Position[(-Value & Value) % 67];
|
|
232
|
+
return Mod67Position[((1 + ~Value) & Value) % 67];
|
|
233
|
+
#endif
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/// CountTrailingOnes_64 - This function performs the operation
|
|
237
|
+
/// of counting the number of ones from the least significant bit to the first
|
|
238
|
+
/// zero bit (64 bit edition.)
|
|
239
|
+
/// Returns 64 if the word is all ones.
|
|
240
|
+
static inline unsigned CountTrailingOnes_64(uint64_t Value) {
|
|
241
|
+
return CountTrailingZeros_64(~Value);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/// CountPopulation_32 - this function counts the number of set bits in a value.
|
|
245
|
+
/// Ex. CountPopulation(0xF000F000) = 8
|
|
246
|
+
/// Returns 0 if the word is zero.
|
|
247
|
+
static inline unsigned CountPopulation_32(uint32_t Value) {
|
|
248
|
+
#if __GNUC__ >= 4
|
|
249
|
+
return __builtin_popcount(Value);
|
|
250
|
+
#else
|
|
251
|
+
uint32_t v = Value - ((Value >> 1) & 0x55555555);
|
|
252
|
+
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
|
|
253
|
+
return (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
|
|
254
|
+
#endif
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/// CountPopulation_64 - this function counts the number of set bits in a value,
|
|
258
|
+
/// (64 bit edition.)
|
|
259
|
+
static inline unsigned CountPopulation_64(uint64_t Value) {
|
|
260
|
+
#if __GNUC__ >= 4
|
|
261
|
+
return __builtin_popcountll(Value);
|
|
262
|
+
#else
|
|
263
|
+
uint64_t v = Value - ((Value >> 1) & 0x5555555555555555ULL);
|
|
264
|
+
v = (v & 0x3333333333333333ULL) + ((v >> 2) & 0x3333333333333333ULL);
|
|
265
|
+
v = (v + (v >> 4)) & 0x0F0F0F0F0F0F0F0FULL;
|
|
266
|
+
return (uint64_t)((v * 0x0101010101010101ULL) >> 56);
|
|
267
|
+
#endif
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/// Log2_32 - This function returns the floor log base 2 of the specified value,
|
|
271
|
+
/// -1 if the value is zero. (32 bit edition.)
|
|
272
|
+
/// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2
|
|
273
|
+
static inline unsigned Log2_32(uint32_t Value) {
|
|
274
|
+
return 31 - CountLeadingZeros_32(Value);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/// Log2_64 - This function returns the floor log base 2 of the specified value,
|
|
278
|
+
/// -1 if the value is zero. (64 bit edition.)
|
|
279
|
+
static inline unsigned Log2_64(uint64_t Value) {
|
|
280
|
+
return 63 - CountLeadingZeros_64(Value);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/// Log2_32_Ceil - This function returns the ceil log base 2 of the specified
|
|
284
|
+
/// value, 32 if the value is zero. (32 bit edition).
|
|
285
|
+
/// Ex. Log2_32_Ceil(32) == 5, Log2_32_Ceil(1) == 0, Log2_32_Ceil(6) == 3
|
|
286
|
+
static inline unsigned Log2_32_Ceil(uint32_t Value) {
|
|
287
|
+
return 32-CountLeadingZeros_32(Value-1);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/// Log2_64_Ceil - This function returns the ceil log base 2 of the specified
|
|
291
|
+
/// value, 64 if the value is zero. (64 bit edition.)
|
|
292
|
+
static inline unsigned Log2_64_Ceil(uint64_t Value) {
|
|
293
|
+
return 64-CountLeadingZeros_64(Value-1);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/// GreatestCommonDivisor64 - Return the greatest common divisor of the two
|
|
297
|
+
/// values using Euclid's algorithm.
|
|
298
|
+
static inline uint64_t GreatestCommonDivisor64(uint64_t A, uint64_t B) {
|
|
299
|
+
while (B) {
|
|
300
|
+
uint64_t T = B;
|
|
301
|
+
B = A % B;
|
|
302
|
+
A = T;
|
|
303
|
+
}
|
|
304
|
+
return A;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/// BitsToDouble - This function takes a 64-bit integer and returns the bit
|
|
308
|
+
/// equivalent double.
|
|
309
|
+
static inline double BitsToDouble(uint64_t Bits) {
|
|
310
|
+
union {
|
|
311
|
+
uint64_t L;
|
|
312
|
+
double D;
|
|
313
|
+
} T;
|
|
314
|
+
T.L = Bits;
|
|
315
|
+
return T.D;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/// BitsToFloat - This function takes a 32-bit integer and returns the bit
|
|
319
|
+
/// equivalent float.
|
|
320
|
+
static inline float BitsToFloat(uint32_t Bits) {
|
|
321
|
+
union {
|
|
322
|
+
uint32_t I;
|
|
323
|
+
float F;
|
|
324
|
+
} T;
|
|
325
|
+
T.I = Bits;
|
|
326
|
+
return T.F;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/// DoubleToBits - This function takes a double and returns the bit
|
|
330
|
+
/// equivalent 64-bit integer. Note that copying doubles around
|
|
331
|
+
/// changes the bits of NaNs on some hosts, notably x86, so this
|
|
332
|
+
/// routine cannot be used if these bits are needed.
|
|
333
|
+
static inline uint64_t DoubleToBits(double Double) {
|
|
334
|
+
union {
|
|
335
|
+
uint64_t L;
|
|
336
|
+
double D;
|
|
337
|
+
} T;
|
|
338
|
+
T.D = Double;
|
|
339
|
+
return T.L;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/// FloatToBits - This function takes a float and returns the bit
|
|
343
|
+
/// equivalent 32-bit integer. Note that copying floats around
|
|
344
|
+
/// changes the bits of NaNs on some hosts, notably x86, so this
|
|
345
|
+
/// routine cannot be used if these bits are needed.
|
|
346
|
+
static inline uint32_t FloatToBits(float Float) {
|
|
347
|
+
union {
|
|
348
|
+
uint32_t I;
|
|
349
|
+
float F;
|
|
350
|
+
} T;
|
|
351
|
+
T.F = Float;
|
|
352
|
+
return T.I;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/// MinAlign - A and B are either alignments or offsets. Return the minimum
|
|
356
|
+
/// alignment that may be assumed after adding the two together.
|
|
357
|
+
static inline uint64_t MinAlign(uint64_t A, uint64_t B) {
|
|
358
|
+
// The largest power of 2 that divides both A and B.
|
|
359
|
+
//
|
|
360
|
+
// Replace "-Value" by "1+~Value" in the following commented code to avoid
|
|
361
|
+
// MSVC warning C4146
|
|
362
|
+
// return (A | B) & -(A | B);
|
|
363
|
+
return (A | B) & (1 + ~(A | B));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/// NextPowerOf2 - Returns the next power of two (in 64-bits)
|
|
367
|
+
/// that is strictly greater than A. Returns zero on overflow.
|
|
368
|
+
static inline uint64_t NextPowerOf2(uint64_t A) {
|
|
369
|
+
A |= (A >> 1);
|
|
370
|
+
A |= (A >> 2);
|
|
371
|
+
A |= (A >> 4);
|
|
372
|
+
A |= (A >> 8);
|
|
373
|
+
A |= (A >> 16);
|
|
374
|
+
A |= (A >> 32);
|
|
375
|
+
return A + 1;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/// Returns the next integer (mod 2**64) that is greater than or equal to
|
|
379
|
+
/// \p Value and is a multiple of \p Align. \p Align must be non-zero.
|
|
380
|
+
///
|
|
381
|
+
/// Examples:
|
|
382
|
+
/// \code
|
|
383
|
+
/// RoundUpToAlignment(5, 8) = 8
|
|
384
|
+
/// RoundUpToAlignment(17, 8) = 24
|
|
385
|
+
/// RoundUpToAlignment(~0LL, 8) = 0
|
|
386
|
+
/// \endcode
|
|
387
|
+
static inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align) {
|
|
388
|
+
return ((Value + Align - 1) / Align) * Align;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/// Returns the offset to the next integer (mod 2**64) that is greater than
|
|
392
|
+
/// or equal to \p Value and is a multiple of \p Align. \p Align must be
|
|
393
|
+
/// non-zero.
|
|
394
|
+
static inline uint64_t OffsetToAlignment(uint64_t Value, uint64_t Align) {
|
|
395
|
+
return RoundUpToAlignment(Value, Align) - Value;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/// abs64 - absolute value of a 64-bit int. Not all environments support
|
|
399
|
+
/// "abs" on whatever their name for the 64-bit int type is. The absolute
|
|
400
|
+
/// value of the largest negative number is undefined, as with "abs".
|
|
401
|
+
static inline int64_t abs64(int64_t x) {
|
|
402
|
+
return (x < 0) ? -x : x;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/// \brief Sign extend number in the bottom B bits of X to a 32-bit int.
|
|
406
|
+
/// Requires 0 < B <= 32.
|
|
407
|
+
static inline int32_t SignExtend32(uint32_t X, unsigned B) {
|
|
408
|
+
return (int32_t)(X << (32 - B)) >> (32 - B);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/// \brief Sign extend number in the bottom B bits of X to a 64-bit int.
|
|
412
|
+
/// Requires 0 < B <= 64.
|
|
413
|
+
static inline int64_t SignExtend64(uint64_t X, unsigned B) {
|
|
414
|
+
return (int64_t)(X << (64 - B)) >> (64 - B);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/// \brief Count number of 0's from the most significant bit to the least
|
|
418
|
+
/// stopping at the first 1.
|
|
419
|
+
///
|
|
420
|
+
/// Only unsigned integral types are allowed.
|
|
421
|
+
///
|
|
422
|
+
/// \param ZB the behavior on an input of 0. Only ZB_Width and ZB_Undefined are
|
|
423
|
+
/// valid arguments.
|
|
424
|
+
static inline unsigned int countLeadingZeros(int x)
|
|
425
|
+
{
|
|
426
|
+
int i;
|
|
427
|
+
const unsigned bits = sizeof(x) * 8;
|
|
428
|
+
unsigned count = bits;
|
|
429
|
+
|
|
430
|
+
if (x < 0) {
|
|
431
|
+
return 0;
|
|
432
|
+
}
|
|
433
|
+
for (i = bits; --i; ) {
|
|
434
|
+
if (x == 0) break;
|
|
435
|
+
count--;
|
|
436
|
+
x >>= 1;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return count;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
#endif
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/* Capstone Disassembly Engine */
|
|
2
|
+
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
|
|
3
|
+
|
|
4
|
+
#include <stdarg.h>
|
|
5
|
+
#if defined(CAPSTONE_HAS_OSXKERNEL)
|
|
6
|
+
#include <Availability.h>
|
|
7
|
+
#include <libkern/libkern.h>
|
|
8
|
+
#include <i386/limits.h>
|
|
9
|
+
#else
|
|
10
|
+
#include <stdio.h>
|
|
11
|
+
#include <limits.h>
|
|
12
|
+
#endif
|
|
13
|
+
#include <string.h>
|
|
14
|
+
|
|
15
|
+
#include <capstone/platform.h>
|
|
16
|
+
|
|
17
|
+
#include "SStream.h"
|
|
18
|
+
#include "cs_priv.h"
|
|
19
|
+
#include "utils.h"
|
|
20
|
+
|
|
21
|
+
#ifdef _MSC_VER
|
|
22
|
+
#pragma warning(disable: 4996) // disable MSVC's warning on strcpy()
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
void SStream_Init(SStream *ss)
|
|
26
|
+
{
|
|
27
|
+
ss->index = 0;
|
|
28
|
+
ss->buffer[0] = '\0';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
void SStream_concat0(SStream *ss, const char *s)
|
|
32
|
+
{
|
|
33
|
+
#ifndef CAPSTONE_DIET
|
|
34
|
+
unsigned int len = (unsigned int) strlen(s);
|
|
35
|
+
|
|
36
|
+
memcpy(ss->buffer + ss->index, s, len);
|
|
37
|
+
ss->index += len;
|
|
38
|
+
ss->buffer[ss->index] = '\0';
|
|
39
|
+
#endif
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void SStream_concat1(SStream *ss, const char c)
|
|
43
|
+
{
|
|
44
|
+
#ifndef CAPSTONE_DIET
|
|
45
|
+
ss->buffer[ss->index] = c;
|
|
46
|
+
ss->index++;
|
|
47
|
+
ss->buffer[ss->index] = '\0';
|
|
48
|
+
#endif
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void SStream_concat(SStream *ss, const char *fmt, ...)
|
|
52
|
+
{
|
|
53
|
+
#ifndef CAPSTONE_DIET
|
|
54
|
+
va_list ap;
|
|
55
|
+
int ret;
|
|
56
|
+
|
|
57
|
+
va_start(ap, fmt);
|
|
58
|
+
ret = cs_vsnprintf(ss->buffer + ss->index, sizeof(ss->buffer) - (ss->index + 1), fmt, ap);
|
|
59
|
+
va_end(ap);
|
|
60
|
+
ss->index += ret;
|
|
61
|
+
#endif
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// print number with prefix #
|
|
65
|
+
void printInt64Bang(SStream *O, int64_t val)
|
|
66
|
+
{
|
|
67
|
+
if (val >= 0) {
|
|
68
|
+
if (val > HEX_THRESHOLD)
|
|
69
|
+
SStream_concat(O, "#0x%"PRIx64, val);
|
|
70
|
+
else
|
|
71
|
+
SStream_concat(O, "#%"PRIu64, val);
|
|
72
|
+
} else {
|
|
73
|
+
if (val <- HEX_THRESHOLD) {
|
|
74
|
+
if (val == LONG_MIN)
|
|
75
|
+
SStream_concat(O, "#-0x%"PRIx64, (uint64_t)val);
|
|
76
|
+
else
|
|
77
|
+
SStream_concat(O, "#-0x%"PRIx64, (uint64_t)-val);
|
|
78
|
+
} else
|
|
79
|
+
SStream_concat(O, "#-%"PRIu64, -val);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
void printUInt64Bang(SStream *O, uint64_t val)
|
|
84
|
+
{
|
|
85
|
+
if (val > HEX_THRESHOLD)
|
|
86
|
+
SStream_concat(O, "#0x%"PRIx64, val);
|
|
87
|
+
else
|
|
88
|
+
SStream_concat(O, "#%"PRIu64, val);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// print number
|
|
92
|
+
void printInt64(SStream *O, int64_t val)
|
|
93
|
+
{
|
|
94
|
+
if (val >= 0) {
|
|
95
|
+
if (val > HEX_THRESHOLD)
|
|
96
|
+
SStream_concat(O, "0x%"PRIx64, val);
|
|
97
|
+
else
|
|
98
|
+
SStream_concat(O, "%"PRIu64, val);
|
|
99
|
+
} else {
|
|
100
|
+
if (val <- HEX_THRESHOLD) {
|
|
101
|
+
if (val == LONG_MIN)
|
|
102
|
+
SStream_concat(O, "-0x%"PRIx64, (uint64_t)val);
|
|
103
|
+
else
|
|
104
|
+
SStream_concat(O, "-0x%"PRIx64, (uint64_t)-val);
|
|
105
|
+
} else
|
|
106
|
+
SStream_concat(O, "-%"PRIu64, -val);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
void printUInt64(SStream *O, uint64_t val)
|
|
111
|
+
{
|
|
112
|
+
if (val > HEX_THRESHOLD)
|
|
113
|
+
SStream_concat(O, "0x%"PRIx64, val);
|
|
114
|
+
else
|
|
115
|
+
SStream_concat(O, "%"PRIu64, val);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// print number in decimal mode
|
|
119
|
+
void printInt32BangDec(SStream *O, int32_t val)
|
|
120
|
+
{
|
|
121
|
+
if (val >= 0)
|
|
122
|
+
SStream_concat(O, "#%u", val);
|
|
123
|
+
else {
|
|
124
|
+
if (val == INT_MIN)
|
|
125
|
+
SStream_concat(O, "#-%u", val);
|
|
126
|
+
else
|
|
127
|
+
SStream_concat(O, "#-%u", (uint32_t)-val);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
void printInt32Bang(SStream *O, int32_t val)
|
|
132
|
+
{
|
|
133
|
+
if (val >= 0) {
|
|
134
|
+
if (val > HEX_THRESHOLD)
|
|
135
|
+
SStream_concat(O, "#0x%x", val);
|
|
136
|
+
else
|
|
137
|
+
SStream_concat(O, "#%u", val);
|
|
138
|
+
} else {
|
|
139
|
+
if (val <- HEX_THRESHOLD) {
|
|
140
|
+
if (val == INT_MIN)
|
|
141
|
+
SStream_concat(O, "#-0x%x", (uint32_t)val);
|
|
142
|
+
else
|
|
143
|
+
SStream_concat(O, "#-0x%x", (uint32_t)-val);
|
|
144
|
+
} else
|
|
145
|
+
SStream_concat(O, "#-%u", -val);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
void printInt32(SStream *O, int32_t val)
|
|
150
|
+
{
|
|
151
|
+
if (val >= 0) {
|
|
152
|
+
if (val > HEX_THRESHOLD)
|
|
153
|
+
SStream_concat(O, "0x%x", val);
|
|
154
|
+
else
|
|
155
|
+
SStream_concat(O, "%u", val);
|
|
156
|
+
} else {
|
|
157
|
+
if (val <- HEX_THRESHOLD) {
|
|
158
|
+
if (val == INT_MIN)
|
|
159
|
+
SStream_concat(O, "-0x%x", (uint32_t)val);
|
|
160
|
+
else
|
|
161
|
+
SStream_concat(O, "-0x%x", (uint32_t)-val);
|
|
162
|
+
} else
|
|
163
|
+
SStream_concat(O, "-%u", -val);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
void printUInt32Bang(SStream *O, uint32_t val)
|
|
168
|
+
{
|
|
169
|
+
if (val > HEX_THRESHOLD)
|
|
170
|
+
SStream_concat(O, "#0x%x", val);
|
|
171
|
+
else
|
|
172
|
+
SStream_concat(O, "#%u", val);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
void printUInt32(SStream *O, uint32_t val)
|
|
176
|
+
{
|
|
177
|
+
if (val > HEX_THRESHOLD)
|
|
178
|
+
SStream_concat(O, "0x%x", val);
|
|
179
|
+
else
|
|
180
|
+
SStream_concat(O, "%u", val);
|
|
181
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* Capstone Disassembly Engine */
|
|
2
|
+
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
|
|
3
|
+
|
|
4
|
+
#ifndef CS_SSTREAM_H_
|
|
5
|
+
#define CS_SSTREAM_H_
|
|
6
|
+
|
|
7
|
+
#include "include/capstone/platform.h"
|
|
8
|
+
|
|
9
|
+
typedef struct SStream {
|
|
10
|
+
char buffer[512];
|
|
11
|
+
int index;
|
|
12
|
+
} SStream;
|
|
13
|
+
|
|
14
|
+
void SStream_Init(SStream *ss);
|
|
15
|
+
|
|
16
|
+
void SStream_concat(SStream *ss, const char *fmt, ...);
|
|
17
|
+
|
|
18
|
+
void SStream_concat0(SStream *ss, const char *s);
|
|
19
|
+
|
|
20
|
+
void SStream_concat1(SStream *ss, const char c);
|
|
21
|
+
|
|
22
|
+
void printInt64Bang(SStream *O, int64_t val);
|
|
23
|
+
|
|
24
|
+
void printUInt64Bang(SStream *O, uint64_t val);
|
|
25
|
+
|
|
26
|
+
void printInt64(SStream *O, int64_t val);
|
|
27
|
+
void printUInt64(SStream *O, uint64_t val);
|
|
28
|
+
|
|
29
|
+
void printInt32Bang(SStream *O, int32_t val);
|
|
30
|
+
|
|
31
|
+
void printInt32(SStream *O, int32_t val);
|
|
32
|
+
|
|
33
|
+
void printUInt32Bang(SStream *O, uint32_t val);
|
|
34
|
+
|
|
35
|
+
void printUInt32(SStream *O, uint32_t val);
|
|
36
|
+
|
|
37
|
+
// print number in decimal mode
|
|
38
|
+
void printInt32BangDec(SStream *O, int32_t val);
|
|
39
|
+
|
|
40
|
+
#endif
|