-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
5.0.1 has broken ARM operand information (in Python 2) #2144
Comments
Seems to be a side effect of d2a39a2 When I remove the lines I get the correct result again: cd /tmp
python3 -m venv venv
source venv/bin/activate
# Get pip archive https://pypi.org/project/capstone/#files
https://files.pythonhosted.org/packages/7a/fe/e6cdc4ad6e0d9603fa662d1ccba6301c0cb762a1c90a42c7146a538c24e9/capstone-5.0.1.tar.gz
tar xzf capstone-5.0.1.tar.gz
cd capstone-5.0.1
# edit files
python3 setup.py install
# Assumes your code is in test-cs.py
python3 test-cs.py
cs_version() = (5, 0, 1280)
0x1000: ldr r1, [r2]
op#0: type=1 (ARM_OP_REG)
op#1: type=3 (ARM_OP_MEM) @gerph Could you try this as well. Just so we are sure. |
Following your instructions, with 'edit files' being a reversion of the change you reference, I now see:
which is correct :-) So for this ticket, this addresses the issue :-) Thanks! |
Yes, I also encountered this mistake |
bump, with >>> insn
<CsInsn 0x56572570 [e8febce5]: ldr pc, [ip, #0xee8]!>
>>> insn
<CsInsn 0x56572570 [e8febce5]: ldr pc, [ip, #0xee8]!>
>>> insn.mnemonic
'ldr'
>>> insn.op_str
'pc, [ip, #0xee8]!'
>>> insn.operands[1]
Traceback (most recent call last):
File "<console>", line 1, in <module>
IndexError: list index out of range |
@amaanq Sorry for the late answer. Have you tried to use the latest |
seems to be good now, thanks for checking in! I tried on both the next and v5 branch w/ the following snippet: from capstone import *
c = Cs(CS_ARCH_ARM, CS_MODE_ARM)
c.detail = True
insn = next(c.disasm(b"\xe8\xfe\xbc\xe5", 0)) # ldr pc, [ip, #0xee8]!
print(f"{insn.mnemonic}\t{insn.op_str}")
print(insn.reg_name(insn.operands[0].reg)) # pc
print(insn.reg_name(insn.operands[1].reg)) # ip
print(hex(insn.operands[1].mem.disp)) # 0xee8 this can be closed probably |
@amaanq
|
yeah sorry I meant both worked |
I added it to the v5.0.2 milestone, so it will be part of the |
Summary
I've just had my CI update to the recently released 5.0.1 and many of my tests have failed.
One of the reasons is that the operand structure for LDR in 32bit ARM, for 5.0.1 is no longer returning the same values.
Where previously the instruction
LDR r1, [r2]
had two operands, it now only has one. Tested on macOS and on Linux.Additionally, the cs_version() has not changed between 5.0.0 and 5.0.1.
Test code
Test output for 4.0.2
Test output for 5.0.0
Test output for 5.0.1
Expected output
The expected output is like the 5.0.0 - we should have two operands described by the
operands
list in the decoded instruction.Additionally, notice that the test output is showing
5, 0, 1280
as the cs_version() for both 5.0.0 and 5.0.1, which makes it hard for me to recognise and reject the library that isn't behaving correctly.The text was updated successfully, but these errors were encountered: