Fix nanomips decoding of jalrc (#2672)

This commit is contained in:
Giovanni 2025-04-06 22:17:55 +08:00 committed by GitHub
parent ae03cca4ef
commit 5b5c5ed856
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View File

@ -1498,7 +1498,9 @@ static DecodeStatus getInstruction(MCInst *Instr, uint64_t *Size, const uint8_t
Result = readInstruction16(Bytes, BytesLen, Address, Size, Result = readInstruction16(Bytes, BytesLen, Address, Size,
&Insn, IsBigEndian); &Insn, IsBigEndian);
if (Result != MCDisassembler_Fail) { if (Result != MCDisassembler_Fail) {
Result = decodeInstruction_2(DecoderTableNanoMips_Conflict_Space16, // Calling the auto-generated decoder function for NanoMips
// 16-bit instructions.
Result = decodeInstruction_2(DecoderTableNanoMips16,
Instr, Insn, Address, Instr, Insn, Address,
NULL); NULL);
if (Result != MCDisassembler_Fail) { if (Result != MCDisassembler_Fail) {
@ -1506,9 +1508,7 @@ static DecodeStatus getInstruction(MCInst *Instr, uint64_t *Size, const uint8_t
return Result; return Result;
} }
// Calling the auto-generated decoder function for NanoMips Result = decodeInstruction_2(DecoderTableNanoMips_Conflict_Space16,
// 16-bit instructions.
Result = decodeInstruction_2(DecoderTableNanoMips16,
Instr, Insn, Address, Instr, Insn, Address,
NULL); NULL);
if (Result != MCDisassembler_Fail) { if (Result != MCDisassembler_Fail) {

View File

@ -6092,4 +6092,12 @@ test_cases:
- asm_text: "bgezc $v1, 4" - asm_text: "bgezc $v1, 4"
- asm_text: "bltzc $v1, 8" - asm_text: "bltzc $v1, 8"
- input:
name: "Test nanomips jalrc rd rt is not beqc rd rt 0"
bytes: [ 0xd9, 0x90 ]
arch: "CS_ARCH_MIPS"
options: [ CS_MODE_NANOMIPS, CS_MODE_BIG_ENDIAN ]
address: 0x0
expected:
insns:
- asm_text: "jalrc $ra, $t0"