From 1c0c185f5dafb8f70bd21880f29f2913cf4c74fb Mon Sep 17 00:00:00 2001 From: Rot127 Date: Tue, 30 May 2023 14:17:19 -0500 Subject: [PATCH] Hotfix for -DCAPSTONE_DIET build. --- arch/AArch64/AArch64GenAsmWriter.inc | 6 +++++- arch/AArch64/AArch64InstPrinter.c | 4 ++++ arch/PowerPC/PPCGenAsmWriter.inc | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/AArch64/AArch64GenAsmWriter.inc b/arch/AArch64/AArch64GenAsmWriter.inc index 572bb27989..6632b7492d 100644 --- a/arch/AArch64/AArch64GenAsmWriter.inc +++ b/arch/AArch64/AArch64GenAsmWriter.inc @@ -17,6 +17,7 @@ static uint64_t getMnemonic(MCInst *MI, SStream *O, unsigned int opcode) { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Woverlength-strings" #endif + #ifndef CAPSTONE_DIET static const char AsmStrs[] = { /* 0 */ "sha1su0\t\0" @@ -1131,6 +1132,8 @@ static uint64_t getMnemonic(MCInst *MI, SStream *O, unsigned int opcode) { /* 8739 */ "ld1w\t{\0" /* 8746 */ "st1w\t{\0" }; +#endif + #ifdef __GNUC__ #pragma GCC diagnostic pop #endif @@ -7480,7 +7483,6 @@ static uint64_t getMnemonic(MCInst *MI, SStream *O, unsigned int opcode) { 138527510U, // anonymous_5384 138527511U, // anonymous_5385 }; -#endif static const uint32_t OpInfo1[] = { 0U, // PHI @@ -13832,7 +13834,9 @@ static uint64_t getMnemonic(MCInst *MI, SStream *O, unsigned int opcode) { uint64_t Bits = 0; Bits |= (uint64_t)OpInfo0[opcode] << 0; Bits |= (uint64_t)OpInfo1[opcode] << 32; +#ifndef CAPSTONE_DIET SStream_concat0(O, AsmStrs+(Bits & 16383)-1); +#endif return Bits; } diff --git a/arch/AArch64/AArch64InstPrinter.c b/arch/AArch64/AArch64InstPrinter.c index 325ff8b145..6c42cc32c7 100644 --- a/arch/AArch64/AArch64InstPrinter.c +++ b/arch/AArch64/AArch64InstPrinter.c @@ -2481,6 +2481,7 @@ static void printMatrixTileVector(MCInst *MI, unsigned OpNum, SStream *O, bool I MCOperand *RegOp = MCInst_getOperand(MI, OpNum); // assert(MCOperand_isReg(RegOp) && "Unexpected operand type!"); unsigned Reg = MCOperand_getReg(RegOp); +#ifndef CAPSTONE_DIET const char *RegName = getRegisterName(Reg, AArch64_NoRegAltName); const size_t strLn = strlen(RegName); @@ -2499,6 +2500,7 @@ static void printMatrixTileVector(MCInst *MI, unsigned OpNum, SStream *O, bool I } } SStream_concat0(O, RegNameNew); +#endif if (MI->csh->detail) { #ifndef CAPSTONE_DIET @@ -2513,7 +2515,9 @@ static void printMatrixTileVector(MCInst *MI, unsigned OpNum, SStream *O, bool I MI->flat_insn->detail->arm64.operands[MI->flat_insn->detail->arm64.op_count].reg = Reg; MI->flat_insn->detail->arm64.op_count++; } +#ifndef CAPSTONE_DIET cs_mem_free(RegNameNew); +#endif } static const unsigned MatrixZADRegisterTable[] = { diff --git a/arch/PowerPC/PPCGenAsmWriter.inc b/arch/PowerPC/PPCGenAsmWriter.inc index 25f1cab47b..9b10793124 100644 --- a/arch/PowerPC/PPCGenAsmWriter.inc +++ b/arch/PowerPC/PPCGenAsmWriter.inc @@ -6135,7 +6135,9 @@ static void printInstruction(MCInst *MI, SStream *O) uint64_t Bits = 0; Bits |= (uint64_t)OpInfo0[opcode] << 0; Bits |= (uint64_t)OpInfo1[opcode] << 32; +#ifndef CAPSTONE_DIET SStream_concat0(O, AsmStrs+(Bits & 16383)-1); +#endif // Fragment 0 encoded into 5 bits for 19 unique commands.