Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIPS: add/fix support for "rdhwr" instruction #1780

Open
kittennbfive opened this issue Aug 28, 2021 · 0 comments
Open

MIPS: add/fix support for "rdhwr" instruction #1780

kittennbfive opened this issue Aug 28, 2021 · 0 comments

Comments

@kittennbfive
Copy link

Hello,

the rdhwr-instruction is currently not disassembled by Capstone, but it is disassembled by mips-linux-gnu-objdump.

Testcase:

#include <stdio.h>
#include <inttypes.h>

#include <capstone/capstone.h>

#define CODE "\x3B\x08\x06\x7C"

/*
MIPS32LE

output from GCC objdump:
7c06083b 	rdhwr	a2,hwr_synci_step

output from Capstone:
(error)
*/

int main(void)
{
	csh handle;
	cs_insn *insn;
	size_t count;

	if (cs_open(CS_ARCH_MIPS, CS_MODE_MIPS32+CS_MODE_LITTLE_ENDIAN, &handle) != CS_ERR_OK)
		return -1;
	count = cs_disasm(handle, CODE, sizeof(CODE)-1, 0x1000, 0, &insn);
	if (count > 0) {
		size_t j;
		for (j = 0; j < count; j++) {
			printf("0x%"PRIx64":\t%s\t\t%s\n", insn[j].address, insn[j].mnemonic,
					insn[j].op_str);
		}

		cs_free(insn, count);
	} else
		printf("ERROR: Failed to disassemble given code!\n");

	cs_close(&handle);

    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant