Merge branch 'next' of https://github.com/aquynh/capstone into next
This commit is contained in:
commit
5696d98f63
|
@ -280,7 +280,7 @@ void AArch64_init(MCRegisterInfo *MRI)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static DecodeStatus _getInstruction(MCInst *MI,
|
static DecodeStatus _getInstruction(cs_struct *ud, MCInst *MI,
|
||||||
const uint8_t *code, size_t code_len,
|
const uint8_t *code, size_t code_len,
|
||||||
uint16_t *Size,
|
uint16_t *Size,
|
||||||
uint64_t Address, MCRegisterInfo *MRI)
|
uint64_t Address, MCRegisterInfo *MRI)
|
||||||
|
@ -291,9 +291,13 @@ static DecodeStatus _getInstruction(MCInst *MI,
|
||||||
return MCDisassembler_Fail;
|
return MCDisassembler_Fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encoded as a small-endian 32-bit word in the stream.
|
uint32_t insn;
|
||||||
uint32_t insn = (code[3] << 24) | (code[2] << 16) |
|
if (ud->big_endian)
|
||||||
(code[1] << 8) | (code[0] << 0);
|
insn = (code[3] << 0) | (code[2] << 8) |
|
||||||
|
(code[1] << 16) | (code[0] << 24);
|
||||||
|
else
|
||||||
|
insn = (code[3] << 24) | (code[2] << 16) |
|
||||||
|
(code[1] << 8) | (code[0] << 0);
|
||||||
|
|
||||||
//printf("insn: %u\n", insn);
|
//printf("insn: %u\n", insn);
|
||||||
// Calling the auto-generated decoder function.
|
// Calling the auto-generated decoder function.
|
||||||
|
@ -311,7 +315,7 @@ static DecodeStatus _getInstruction(MCInst *MI,
|
||||||
|
|
||||||
bool AArch64_getInstruction(csh ud, unsigned char *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *info)
|
bool AArch64_getInstruction(csh ud, unsigned char *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *info)
|
||||||
{
|
{
|
||||||
DecodeStatus status = _getInstruction(instr,
|
DecodeStatus status = _getInstruction((cs_struct *)ud, instr,
|
||||||
code, code_len,
|
code, code_len,
|
||||||
size,
|
size,
|
||||||
address, (MCRegisterInfo *)info);
|
address, (MCRegisterInfo *)info);
|
||||||
|
|
|
@ -447,11 +447,17 @@ static DecodeStatus _ARM_getInstruction(cs_struct *ud, MCInst *MI, const uint8_t
|
||||||
|
|
||||||
memcpy(bytes, code, 4);
|
memcpy(bytes, code, 4);
|
||||||
|
|
||||||
// Encoded as a small-endian 32-bit word in the stream.
|
uint32_t insn;
|
||||||
uint32_t insn = (bytes[3] << 24) |
|
if (ud->big_endian)
|
||||||
(bytes[2] << 16) |
|
insn = (bytes[3] << 0) |
|
||||||
(bytes[1] << 8) |
|
(bytes[2] << 8) |
|
||||||
(bytes[0] << 0);
|
(bytes[1] << 16) |
|
||||||
|
(bytes[0] << 24);
|
||||||
|
else
|
||||||
|
insn = (bytes[3] << 24) |
|
||||||
|
(bytes[2] << 16) |
|
||||||
|
(bytes[1] << 8) |
|
||||||
|
(bytes[0] << 0);
|
||||||
|
|
||||||
// Calling the auto-generated decoder function.
|
// Calling the auto-generated decoder function.
|
||||||
DecodeStatus result = decodeInstruction_4(DecoderTableARM32, MI, insn, Address, ud->mode);
|
DecodeStatus result = decodeInstruction_4(DecoderTableARM32, MI, insn, Address, ud->mode);
|
||||||
|
@ -666,7 +672,12 @@ static DecodeStatus _Thumb_getInstruction(cs_struct *ud, MCInst *MI, const uint8
|
||||||
|
|
||||||
memcpy(bytes, code, 2);
|
memcpy(bytes, code, 2);
|
||||||
|
|
||||||
uint16_t insn16 = (bytes[1] << 8) | bytes[0];
|
uint16_t insn16;
|
||||||
|
if (ud->big_endian)
|
||||||
|
insn16 = (bytes[0] << 8) | bytes[1];
|
||||||
|
else
|
||||||
|
insn16 = (bytes[1] << 8) | bytes[0];
|
||||||
|
|
||||||
DecodeStatus result = decodeInstruction_2(DecoderTableThumb16, MI, insn16, Address, ud->mode);
|
DecodeStatus result = decodeInstruction_2(DecoderTableThumb16, MI, insn16, Address, ud->mode);
|
||||||
if (result != MCDisassembler_Fail) {
|
if (result != MCDisassembler_Fail) {
|
||||||
*Size = 2;
|
*Size = 2;
|
||||||
|
@ -717,10 +728,18 @@ static DecodeStatus _Thumb_getInstruction(cs_struct *ud, MCInst *MI, const uint8
|
||||||
|
|
||||||
memcpy(bytes, code, 4);
|
memcpy(bytes, code, 4);
|
||||||
|
|
||||||
uint32_t insn32 = (bytes[3] << 8) |
|
uint32_t insn32;
|
||||||
(bytes[2] << 0) |
|
if (ud->big_endian)
|
||||||
(bytes[1] << 24) |
|
insn32 = (bytes[3] << 24) |
|
||||||
(bytes[0] << 16);
|
(bytes[2] << 16) |
|
||||||
|
(bytes[1] << 8) |
|
||||||
|
(bytes[0] << 0);
|
||||||
|
else
|
||||||
|
insn32 = (bytes[3] << 8) |
|
||||||
|
(bytes[2] << 0) |
|
||||||
|
(bytes[1] << 24) |
|
||||||
|
(bytes[0] << 16);
|
||||||
|
|
||||||
MCInst_clear(MI);
|
MCInst_clear(MI);
|
||||||
result = decodeInstruction_4(DecoderTableThumb32, MI, insn32, Address, ud->mode);
|
result = decodeInstruction_4(DecoderTableThumb32, MI, insn32, Address, ud->mode);
|
||||||
if (result != MCDisassembler_Fail) {
|
if (result != MCDisassembler_Fail) {
|
||||||
|
|
Loading…
Reference in New Issue