mirror of
https://github.com/capstone-engine/capstone.git
synced 2024-11-23 05:29:53 +00:00
Fix warnings when building with CAPSTONE_DIET (#2249)
This commit is contained in:
parent
c8c80091f2
commit
69d224167f
@ -21264,8 +21264,10 @@ getRegisterName(unsigned RegNo, unsigned AltIdx) {
|
||||
#ifdef PRINT_ALIAS_INSTR
|
||||
#undef PRINT_ALIAS_INSTR
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
static bool AArch64InstPrinterValidateMCOperand(const MCOperand *MCOp,
|
||||
unsigned PredicateIndex);
|
||||
#endif
|
||||
static bool printAliasInstr(MCInst *MI, uint64_t Address, SStream *OS) {
|
||||
#ifndef CAPSTONE_DIET
|
||||
static const PatternsForOpcode OpToPatterns[] = {
|
||||
@ -33325,11 +33327,11 @@ static bool printAliasInstr(MCInst *MI, uint64_t Address, SStream *OS) {
|
||||
#endif // CAPSTONE_DIET
|
||||
}
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
static void printCustomAliasOperand(
|
||||
MCInst *MI, uint64_t Address, unsigned OpIdx,
|
||||
unsigned PrintMethodIdx,
|
||||
SStream *OS) {
|
||||
#ifndef CAPSTONE_DIET
|
||||
switch (PrintMethodIdx) {
|
||||
default:
|
||||
assert(0 && "Unknown PrintMethod kind");
|
||||
@ -33524,9 +33526,10 @@ static void printCustomAliasOperand(
|
||||
printSysCROperand(MI, OpIdx, OS);
|
||||
break;
|
||||
}
|
||||
#endif // CAPSTONE_DIET
|
||||
}
|
||||
#endif // CAPSTONE_DIET
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
static bool AArch64InstPrinterValidateMCOperand(const MCOperand *MCOp,
|
||||
unsigned PredicateIndex) {
|
||||
switch (PredicateIndex) {
|
||||
@ -33610,5 +33613,6 @@ static bool AArch64InstPrinterValidateMCOperand(const MCOperand *MCOp,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // PRINT_ALIAS_INSTR
|
||||
|
@ -54,10 +54,12 @@
|
||||
|
||||
#define DEBUG_TYPE "asm-printer"
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
static void printCustomAliasOperand(
|
||||
MCInst *MI, uint64_t Address, unsigned OpIdx,
|
||||
unsigned PrintMethodIdx,
|
||||
SStream *OS);
|
||||
#endif
|
||||
|
||||
#define DECLARE_printComplexRotationOp(Angle, Remainder) \
|
||||
static void CONCAT(printComplexRotationOp, CONCAT(Angle, Remainder))( \
|
||||
|
@ -13336,10 +13336,10 @@ static bool printAliasInstr(MCInst *MI, uint64_t Address, SStream *OS)
|
||||
#endif // CAPSTONE_DIET
|
||||
}
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
void printCustomAliasOperand(MCInst *MI, uint64_t Address, unsigned OpIdx,
|
||||
unsigned PrintMethodIdx, SStream *OS)
|
||||
{
|
||||
#ifndef CAPSTONE_DIET
|
||||
switch (PrintMethodIdx) {
|
||||
default:
|
||||
assert(0 && "Unknown PrintMethod kind");
|
||||
@ -13354,7 +13354,7 @@ void printCustomAliasOperand(MCInst *MI, uint64_t Address, unsigned OpIdx,
|
||||
printMandatoryInvertedPredicateOperand(MI, OpIdx, OS);
|
||||
break;
|
||||
}
|
||||
#endif // CAPSTONE_DIET
|
||||
}
|
||||
#endif // CAPSTONE_DIET
|
||||
|
||||
#endif // PRINT_ALIAS_INSTR
|
||||
|
@ -52,9 +52,11 @@
|
||||
|
||||
// Static function declarations. These are functions which have the same identifiers
|
||||
// over all architectures. Therefor they need to be static.
|
||||
#ifndef CAPSTONE_DIET
|
||||
static void printCustomAliasOperand(MCInst *MI, uint64_t Address,
|
||||
unsigned OpIdx, unsigned PrintMethodIdx,
|
||||
SStream *O);
|
||||
#endif
|
||||
static void printOperand(MCInst *MI, unsigned OpNo, SStream *O);
|
||||
static void printPredicateOperand(MCInst *MI, unsigned OpNum, SStream *O);
|
||||
static void printRegName(SStream *OS, unsigned RegNo);
|
||||
|
@ -1501,9 +1501,7 @@ static const char *getRegisterName(unsigned RegNo) {
|
||||
#undef PRINT_ALIAS_INSTR
|
||||
|
||||
static bool printAliasInstr(MCInst *MI, uint64_t Address, SStream *OS) {
|
||||
#ifndef CAPSTONE_DIET
|
||||
return false;
|
||||
#endif // CAPSTONE_DIET
|
||||
}
|
||||
|
||||
#endif // PRINT_ALIAS_INSTR
|
||||
|
@ -283,6 +283,7 @@ static bpf_insn op2insn_jmp(unsigned opcode)
|
||||
return BPF_INS_INVALID;
|
||||
}
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
static void update_regs_access(cs_struct *ud, cs_detail *detail,
|
||||
bpf_insn insn_id, unsigned int opcode)
|
||||
{
|
||||
@ -357,6 +358,7 @@ static void update_regs_access(cs_struct *ud, cs_detail *detail,
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 1. Convert opcode(id) to BPF_INS_*
|
||||
@ -366,12 +368,12 @@ void BPF_get_insn_id(cs_struct *ud, cs_insn *insn, unsigned int opcode)
|
||||
{
|
||||
// No need to care the mode (cBPF or eBPF) since all checks has be done in
|
||||
// BPF_getInstruction, we can simply map opcode to BPF_INS_*.
|
||||
cs_detail *detail;
|
||||
bpf_insn id = BPF_INS_INVALID;
|
||||
#ifndef CAPSTONE_DIET
|
||||
cs_detail *detail;
|
||||
bpf_insn_group grp;
|
||||
|
||||
detail = insn->detail;
|
||||
#ifndef CAPSTONE_DIET
|
||||
#define PUSH_GROUP(grp) do { \
|
||||
if (detail) { \
|
||||
detail->groups[detail->groups_count] = grp; \
|
||||
@ -379,7 +381,7 @@ void BPF_get_insn_id(cs_struct *ud, cs_insn *insn, unsigned int opcode)
|
||||
} \
|
||||
} while(0)
|
||||
#else
|
||||
#define PUSH_GROUP
|
||||
#define PUSH_GROUP(grp) do {} while(0)
|
||||
#endif
|
||||
|
||||
switch (BPF_CLASS(opcode)) {
|
||||
@ -400,13 +402,15 @@ void BPF_get_insn_id(cs_struct *ud, cs_insn *insn, unsigned int opcode)
|
||||
PUSH_GROUP(BPF_GRP_ALU);
|
||||
break;
|
||||
case BPF_CLASS_JMP:
|
||||
grp = BPF_GRP_JUMP;
|
||||
id = op2insn_jmp(opcode);
|
||||
#ifndef CAPSTONE_DIET
|
||||
grp = BPF_GRP_JUMP;
|
||||
if (id == BPF_INS_CALL || id == BPF_INS_CALLX)
|
||||
grp = BPF_GRP_CALL;
|
||||
else if (id == BPF_INS_EXIT)
|
||||
grp = BPF_GRP_RETURN;
|
||||
PUSH_GROUP(grp);
|
||||
#endif
|
||||
break;
|
||||
case BPF_CLASS_RET:
|
||||
id = BPF_INS_RET;
|
||||
|
@ -15,7 +15,6 @@
|
||||
static const cs_evm insns[256] = {
|
||||
#include "EVMMappingInsn.inc"
|
||||
};
|
||||
#endif
|
||||
|
||||
// look for @id in @insns, given its size in @max.
|
||||
// return -1 if not found
|
||||
@ -30,6 +29,7 @@ static int evm_insn_find(const cs_evm *insns, unsigned int max, unsigned int id)
|
||||
|
||||
return (int)id;
|
||||
}
|
||||
#endif
|
||||
|
||||
// fill in details
|
||||
void EVM_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id)
|
||||
|
@ -20,11 +20,11 @@ static const struct OpInfo OpInfoTable[]= {
|
||||
|
||||
};
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
static const char* const RegNames[] = {
|
||||
"invalid", "A", "X", "Y", "P", "SP", "DP", "B", "K"
|
||||
};
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
static const char* const GroupNames[] = {
|
||||
NULL,
|
||||
"jump",
|
||||
|
@ -15721,11 +15721,11 @@ static bool printAliasInstr(MCInst *MI, uint64_t Address, SStream *OS) {
|
||||
#endif // CAPSTONE_DIET
|
||||
}
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
static void printCustomAliasOperand(
|
||||
MCInst *MI, uint64_t Address, unsigned OpIdx,
|
||||
unsigned PrintMethodIdx,
|
||||
SStream *OS) {
|
||||
#ifndef CAPSTONE_DIET
|
||||
switch (PrintMethodIdx) {
|
||||
default:
|
||||
assert(0 && "Unknown PrintMethod kind");
|
||||
@ -15755,7 +15755,7 @@ static void printCustomAliasOperand(
|
||||
printU5ImmOperand(MI, OpIdx, OS);
|
||||
break;
|
||||
}
|
||||
#endif // CAPSTONE_DIET
|
||||
}
|
||||
#endif // CAPSTONE_DIET
|
||||
|
||||
#endif // PRINT_ALIAS_INSTR
|
||||
|
@ -50,9 +50,11 @@
|
||||
|
||||
// Static function declarations. These are functions which have the same identifiers
|
||||
// over all architectures. Therefor they need to be static.
|
||||
#ifndef CAPSTONE_DIET
|
||||
static void printCustomAliasOperand(MCInst *MI, uint64_t Address,
|
||||
unsigned OpIdx, unsigned PrintMethodIdx,
|
||||
SStream *O);
|
||||
#endif
|
||||
static void printOperand(MCInst *MI, unsigned OpNo, SStream *O);
|
||||
static void printPredicateOperand(MCInst *MI, unsigned OpNo, SStream *O,
|
||||
const char *Modifier);
|
||||
|
@ -295,6 +295,7 @@ static void printInstruction(MCInst *MI, SStream *O, MCRegisterInfo *MRI) {
|
||||
0U
|
||||
};
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
static const char AsmStrs[] = {
|
||||
/* 0 */ 'n', 'o', 'p', 9, 9, 0,
|
||||
/* 6 */ 's', 'u', 'b', '2', 9, 0,
|
||||
@ -428,6 +429,7 @@ static void printInstruction(MCInst *MI, SStream *O, MCRegisterInfo *MRI) {
|
||||
/* 897 */ 'b', 9, 'n', 'r', 'p', 0,
|
||||
/* 903 */ 'l', 'i', 'f', 'e', 't', 'i', 'm', 'e', '_', 's', 't', 'a', 'r', 't', 0,
|
||||
};
|
||||
#endif
|
||||
|
||||
// Emit the opcode for the instruction.
|
||||
uint32_t Bits = OpInfo[MCInst_getOpcode(MI)];
|
||||
|
@ -1712,7 +1712,6 @@ static bool valid_bnd(cs_struct *h, unsigned int opcode)
|
||||
// not found
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// return true if the opcode is XCHG [mem]
|
||||
static bool xchg_mem(unsigned int opcode)
|
||||
@ -1727,6 +1726,7 @@ static bool xchg_mem(unsigned int opcode)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// given MCInst's id, find out if this insn is valid for REP prefix
|
||||
static bool valid_rep(cs_struct *h, unsigned int opcode)
|
||||
@ -1783,6 +1783,7 @@ static bool valid_rep(cs_struct *h, unsigned int opcode)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef CAPSTONE_DIET
|
||||
// given MCInst's id, find if this is a "repz ret" instruction
|
||||
// gcc generates "repz ret" (f3 c3) instructions in some cases as an
|
||||
// optimization for AMD platforms, see:
|
||||
@ -1800,6 +1801,7 @@ static bool valid_ret_repz(cs_struct *h, unsigned int opcode)
|
||||
// not found
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// given MCInst's id, find out if this insn is valid for REPE prefix
|
||||
static bool valid_repe(cs_struct *h, unsigned int opcode)
|
||||
|
2
cs.c
2
cs.c
@ -563,6 +563,7 @@ cs_err CAPSTONE_API cs_close(csh *handle)
|
||||
// replace str1 in target with str2; target starts with str1
|
||||
// output is put into result (which is array of char with size CS_MNEMONIC_SIZE)
|
||||
// return 0 on success, -1 on failure
|
||||
#ifndef CAPSTONE_DIET
|
||||
static int str_replace(char *result, char *target, const char *str1, char *str2)
|
||||
{
|
||||
// only perform replacement if the output fits into result
|
||||
@ -576,6 +577,7 @@ static int str_replace(char *result, char *target, const char *str1, char *str2)
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// The asm string sometimes has a leading space or tab.
|
||||
/// Here we remove it.
|
||||
|
Loading…
Reference in New Issue
Block a user