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.26k stars 454 forks source link

PowerPC cannot branch through negative offsets #239

Open brendabrandy opened 8 years ago

brendabrandy commented 8 years ago

I am currently trying to assemble the following instruction in powerpc 32 bit big endian: blx -0xf17c from the address 0x100e4db0 The encoding is: 4B FF 0E B5 And the error given by kstool is:

ERROR: failed on ks_asm() with count = 0, error = 'Invalid mnemonic (KS_ERR_ASM_MNEMONICFAIL)' (code = 514)
aquynh commented 8 years ago

this encoding is for BL, not BLX.

it seems you are right that negative offset is not correctly handled now. will fix that.

brendabrandy commented 8 years ago

@aquynh There are multiple patches that I would like to implement, I was looking at the autogenerated ARMGenAsmMatcher.inc file, where is it autogenerated from?

Thanks!

aquynh commented 8 years ago

that comes from LLVM. you can compile from source, and get that file.