Skip to content

Fix multiple hangs, require view selection, and minor improvements to lifting#18

Open
zznop wants to merge 1 commit intofluxchief:masterfrom
zznop:master
Open

Fix multiple hangs, require view selection, and minor improvements to lifting#18
zznop wants to merge 1 commit intofluxchief:masterfrom
zznop:master

Conversation

@zznop
Copy link
Copy Markdown

@zznop zznop commented May 8, 2025

  • Fixes multiple bugs that cause Binja to hang during analysis
  • Forces the user to select the AVR view in open with options
  • Some minor improvements to lifting
  • Some changes to RAM / ROM sizes for iotn88

* Fixes multiple bugs that cause Binja to hang during analysis
* Forces the user to select the AVR view in open with options
* Some minor improvements to lifting
Comment thread chips/iotn88.py
Comment on lines +10 to +11
RAM_SIZE = 1024 * 16
ROM_SIZE = 32 * 1024
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are incorrect

@fluxchief
Copy link
Copy Markdown
Owner

Thanks for the PR

Left a few comments, some context on a few of the changes would be great.
Also the BN flag test change is hard to verify without educated guessing what these BN constants mean, is there a better source than the BN API documentation?

Comment thread __init__.py
Comment on lines 425 to +429
def is_valid_for_data(self, data):
return False # Must be force loaded with "Open with Options"

@classmethod
def is_force_loadable(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self should probably be cls for both of these

Copy link
Copy Markdown
Owner

@fluxchief fluxchief left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out I didn't know how to a review "github style" so my comments never showed up.. Anyways, here you go.

Comment thread __init__.py
class AVR(binaryninja.Architecture):
name = 'AVR'
address_size = 3
address_size = 2
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you changing this?
Two bytes is not enough to cover the address space of all AVR chips

Comment thread __init__.py
return nfo

nfo.length = ins.length()
return None
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tried this change, how does this behave if BN encounters this situation?
IIRC in the past it would just crash and that would not be acceptable

Comment thread __init__.py
nfo.add_branch(BranchType.FunctionReturn)
elif (isinstance(ins, instructions.Instruction_RCALL)):
v = addr + ins.operands[0].immediate_value
if v == (addr + 2):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this optimization is something BN itself should do?

Comment thread __init__.py
elif (isinstance(ins, instructions.Instruction_ICALL) or
isinstance(ins, instructions.Instruction_EICALL) or
isinstance(ins, instructions.Instruction_IJMP) or
elif (isinstance(ins, instructions.Instruction_IJMP) or
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing (E)ICALL?

Comment thread chips/iotn88.py
CHIP_ALIASES = ["iotn88", "ATtiny88"]
RAM_SIZE = 256 * 2
ROM_SIZE = 4 * 1024 * 2
RAM_SIZE = 1024 * 16
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values are incorrect. Attiny88 has 8K flash and 512b SRAM:
https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/8008S.pdf

Comment thread instructions.py
def get_llil(self, il):
v = self._operands[0].immediate_value + self._addr
if v == (self._addr + 2):
il.append(il.push(2, il.const(2, v)))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar question as above (shouldn't BN figure this out), but also some devices will push 3 bytes instead of two.

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

Successfully merging this pull request may close these issues.

3 participants