keystone-engine / keystone

Keystone assembler framework: Core (Arm, Arm64, Hexagon, Mips, PowerPC, Sparc, SystemZ & X86) + bindings
http://www.keystone-engine.org
GNU General Public License v2.0
2.31k stars 459 forks source link

Cannot assemble LDC #238

Open brendabrandy opened 8 years ago

brendabrandy commented 8 years ago

I am currently doing some tests with keystone. I diassembled a binary with IDA and am trying to assemble the following instruction:

STC     p11, c0, [R0], {0x21}
BX      LR

and obtained the following error code when using kstool:

ERROR: failed on ks_asm() with count = 0, error = 'Invalid operand (KS_ERR_ASM_INVALIDOPERAND)' (code = 512)

Since I failed, I tried using capstone to disassemble the said binary to see what I got, and I obtained the following disassembly with capstone:

0xc79f4:    fstmiax r0, {d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14, d15}
0xc79f8:    bx  lr

However, when i did some digging into the stc and fstmiax, I found out that fstmiax is only mentioned up to ARM v4 reference while STC is still used in more modern versions of ARM. I also found out that it seems to be a bug in LLVM to begin with. Do you have any knowledge as to how I can work around this?

Thanks!

aquynh commented 8 years ago

please always provide the encoding, so i can verify the issue, thanks.

brendabrandy commented 8 years ago

OK, the encoding is:

[33, 11, 128, 236, 30, 255, 47, 225]

in little endian ARM.

Thanks @aquynh !