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

Empty mnemonic for ARM lsr instruction #2189

Closed
Quentin01 opened this issue Nov 8, 2023 · 1 comment · Fixed by #2192
Closed

Empty mnemonic for ARM lsr instruction #2189

Quentin01 opened this issue Nov 8, 2023 · 1 comment · Fixed by #2192
Assignees

Comments

@Quentin01
Copy link
Contributor

Quentin01 commented Nov 8, 2023

Hi,

On the branch next there is an issue with the disassembly of some instructions. The mnemonic is empty and is contained in op_str.

E.g for 30 02 a0 e1 the instruction should be lsr r0, r0, r2, lsr as mnemonic and r0, r0, r2 as op_str, but it's not the case, the mnemonic is empty and lsr is in op_str.

Here is a small code to reproduce the issue:

#include <capstone/capstone.h>

int main() {
	size_t handle = 0;
	if (cs_open(CS_ARCH_ARM, CS_MODE_ARM, &handle) != CS_ERR_OK) {
		printf("Couldn't create cs handle\n");
		return -1;
	}

	size_t pc = 0;
	const uint8_t *code = "\x30\x02\xa0\xe1";
	size_t size = sizeof(code);

	cs_insn *insn = cs_malloc(handle);
	if (!cs_disasm_iter(handle, &code, &size, &pc, insn)) {
		printf("Couldn't disassemble instruction");
		return -1;
	}

	printf("Instruction mnemonic: '%s'\n", insn->mnemonic);
	printf("Instruction operand str: '%s'\n", insn->op_str);

	cs_free(insn, 1);
	cs_close(&handle);

	return 0;
}

The output will be:

Instruction mnemonic: ''
Instruction operand str: 'lsr r0, r0, r2'

The same issue is happening in cstool.

I didn't test the version v5 if the issue is the same.

@Rot127
Copy link
Collaborator

Rot127 commented Nov 8, 2023

@kabeor assign me please to it.

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

Successfully merging a pull request may close this issue.

2 participants