Skip to content

mips[el]32 disassembled from hex input returns missing instructions #6

@bowserjklol

Description

@bowserjklol

I fully recognize I could be doing something wrong so I welcome any pointers...

With this plugin, if you grab some mips32 assembly (you can use some shell code from msf for example):

  li      $t7, -6
  nor     $t7, $t7, $zero
  addi    $a0, $t7, -3
  addi    $a1, $t7, -3
  slti    $a2, $zero, -1
  li      $v0, 4183
  syscall 0x40404
  slt     $s0, $zero, $a3
  bne     $s0, $zero, failed
  sw      $v0, -4($sp) 

Go ahead and assemble it with hex output via the plugin:

Image

Now take that output and push it back through as input and disassemble it into mips mnemonics

Image

It looks like this happens because mips32 (per the docs) has the max_instr_length property set to 8.

the value for mips32 is currently 8 because multiple instructions are decoded looking for delay slots so they can be reordered.

Which the plugin, seemingly correctly, utilizes here:

instruction_length = len(bv.read(offset, self.arch.max_instr_length))

My workaround has been setting that property to 4 for the sake of outputting mnemonics I'm expecting...

Image

I don't have any great solutions (other API magic in binja to be called?) but wanted to report the issue as you'll probably have a better idea on how best to work around this sanely.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions