keystone
keystone copied to clipboard
keystone failing on certain instructions
When I get assembly this way from gcc:
$echo " " |gcc -xc -S -o- - -m64
.file ""
.text
.ident "GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0"
.section .note.GNU-stack,"",@progbits
.section .note.gnu.property,"a"
.align 8
.long 1f - 0f
.long 4f - 1f
.long 5
0:
.string "GNU"
1:
.align 8
.long 0xc0000002
.long 3f - 2f
2:
.long 0x3
3:
.align 8
4:
The .long lines without 0x are causing issues:
$ kstool x64 '.long 3f - 2f'
ERROR: failed on ks_asm() with count = 0, error = 'Invalid directive (KS_ERR_ASM_DIRECTIVE_INVALID)' (code = 139)
But if they are reformatted:
$ kstool x64 '.long 0x3f - 0x2f'
.long 0x3f - 0x2f = [ 10 00 00 00 ]
It's fine.
Additionally I have errors on these as well:
kstool x64 'movb (%rcx,%rdx), %dl'
ERROR: failed on ks_asm() with count = 0, error = 'Invalid operand (KS_ERR_ASM_INVALIDOPERAND)' (code = 512)
and
kstool x64 'leal -48(%rax,%rdx), %eax'
ERROR: failed on ks_asm() with count = 0, error = 'Invalid operand (KS_ERR_ASM_INVALIDOPERAND)' (code = 512)