keystone
keystone copied to clipboard
MIPS: Dummy nop after a jump instruction
I know MIPS's branch instructions need another instruction follows (a.k.a. branch delay slot), but keystone (or, llvm) always adds a dummy nop after branch instructions even there's one.
If no instruction follows, this output is ok:
$ kstool mipsbe 'jal 0x40025c'
# jal 0x40025c = [ 0c 10 00 97 00 00 00 00 ]
But with an instruction follows, a dummy nop is still inserted:
$ kstool mipsbe 'jal 0x40025c ; add $at, $at, $zero'
# jal 0x40025c ; add $at, $at, $zero = [ 0c 10 00 97 00 00 00 00 00 20 08 20 ]
expected:
$ kstool mipsbe 'jal 0x40025c ; add $at, $at, $zero'
# jal 0x40025c ; add $at, $at, $zero = [ 0c 10 00 97 00 20 08 20 ]
No NOP needed to be inserted if an instruction already follows.
I guess the same issue appears in Sparc as well.
imo keystone should never insert dummy instructions in such cases. It is the programmer's job to understand that a delay slot is used, not keystone's job to read the programmer's mind