Skip to content

Commit cf0852e

Browse files
committed
WIP [mips] R5900 support: fix compiler warnings/errors on non-macOS
1 parent e874f93 commit cf0852e

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

arch/mips/arch_mips.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ class MipsArchitecture: public Architecture
806806
const char* operation_name = get_operation(instr.operation);
807807
if (operation_name == NULL)
808808
return false;
809-
strlcpy(operation, operation_name, sizeof(operation));
809+
strncpy(operation, operation_name, sizeof(operation));
810810

811811
if (instr.operands[0].operandClass == V_DEST)
812812
{

arch/mips/il.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ using namespace mips;
77

88
#define INVALID_EXPRID ((uint32_t)-1)
99

10+
#define INVALID_OPERATION \
11+
default: \
12+
LogWarn("Invalid operation"); \
13+
il.AddInstruction(il.Unimplemented()); \
14+
return false
15+
16+
1017
typedef enum {
1118
ZeroExtend,
1219
SignExtend,
@@ -508,6 +515,7 @@ ExprId GetConditionForInstruction(LowLevelILFunction& il, Instruction& instr, st
508515
case MIPS_BGEZ:
509516
case MIPS_BGEZL:
510517
case MIPS_BGEZAL:
518+
case MIPS_BGEZALL:
511519
return il.CompareSignedGreaterEqual(registerSize(op1), ReadILOperand(il, instr, 1, registerSize(op1)), il.Const(registerSize(op1), 0));
512520
case MIPS_BGTZ:
513521
case MIPS_BGTZL:
@@ -518,6 +526,7 @@ ExprId GetConditionForInstruction(LowLevelILFunction& il, Instruction& instr, st
518526
case MIPS_BLTZ:
519527
case MIPS_BLTZL:
520528
case MIPS_BLTZAL:
529+
case MIPS_BLTZALL:
521530
return il.CompareSignedLessThan(registerSize(op1), ReadILOperand(il, instr, 1, registerSize(op1)), il.Const(registerSize(op1), 0));
522531
case MIPS_BC1F:
523532
case MIPS_BC1FL:
@@ -1129,9 +1138,6 @@ bool GetLowLevelILForInstruction(Architecture* arch, uint64_t addr, LowLevelILFu
11291138
InstructionOperand& op4 = instr.operands[3];
11301139
LowLevelILLabel trueCode, falseCode, again;
11311140
size_t bytes = 4;
1132-
bool max = false;
1133-
// size_t registerSize = addrSize;
1134-
// std::function<size_t (*)(const InstructionOperand& op)>
11351141
bool signedFlag = false;
11361142
ExtendType extendType = SignExtend;
11371143
bool saturate = false;
@@ -4697,6 +4703,12 @@ bool GetLowLevelILForInstruction(Architecture* arch, uint64_t addr, LowLevelILFu
46974703
case MIPS_VFTOI15: shift = 15; break;
46984704
case MIPS_VFTOI12: shift = 12; break;
46994705
case MIPS_VFTOI4: shift = 4; break;
4706+
default: shift = 0;
4707+
}
4708+
if (shift == 0)
4709+
{
4710+
il.AddInstruction((il.Unimplemented()));
4711+
break;
47004712
}
47014713
unsigned char dest = op1.reg;
47024714
if (dest & (1 << 3))
@@ -4719,6 +4731,12 @@ bool GetLowLevelILForInstruction(Architecture* arch, uint64_t addr, LowLevelILFu
47194731
case MIPS_VITOF15: shift = 15; break;
47204732
case MIPS_VITOF12: shift = 12; break;
47214733
case MIPS_VITOF4: shift = 4; break;
4734+
default: shift = 0;
4735+
}
4736+
if (shift == 0)
4737+
{
4738+
il.AddInstruction((il.Unimplemented()));
4739+
break;
47224740
}
47234741
unsigned char dest = op1.reg;
47244742
if (dest & (1 << 3))

arch/mips/mips/mips.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3699,7 +3699,7 @@ uint32_t mips_disassemble(
36993699
int first_operand = 0;
37003700
const char* reg = NULL;
37013701

3702-
strlcpy(operation, OperationStrings[instruction->operation], sizeof(operation));
3702+
strncpy(operation, OperationStrings[instruction->operation], sizeof(operation));
37033703
if (instruction->operands[0].operandClass == V_DEST)
37043704
{
37053705
char* p = dest;

arch/mips/mips/test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ int main(int ac, char **av)
174174
result = -1;
175175
goto cleanup;
176176
}
177+
#ifndef WIN32
177178
if (version == MIPS_R5900)
178179
insword = ntohl(insword);
180+
#endif
179181
if (0 == disassemble(insword, baseaddr, version, flags, instxt))
180182
{
181183
printf("%08llX: %08X %s\n", baseaddr, insword, instxt);

0 commit comments

Comments
 (0)