Skip to content
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

MIPS: Dummy nop after a jump instruction #405

Open
david942j opened this issue Feb 20, 2019 · 2 comments
Open

MIPS: Dummy nop after a jump instruction #405

david942j opened this issue Feb 20, 2019 · 2 comments

Comments

@david942j
Copy link

david942j commented Feb 20, 2019

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.

@david942j
Copy link
Author

I guess the same issue appears in Sparc as well.

@cseagle
Copy link

cseagle commented Jul 6, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants