0

I figured it'd be more appropriate to ask this question here:

https://github.com/NationalSecurityAgency/ghidra/issues/2530#issuecomment-785007613

Given this linear address space a particular MCU:

V850 mem space

It's not easily definable as-is on the memory manager, see:

memory = currentProgram.getMemory()
fb = memory.getAllFileBytes()   
blk = memory.getBlock(toAddr(0x0))
memory.removeBlock(blk, monitor)

memory.createUninitializedBlock("internal_ram",toAddr(0x3ff8000),0x2fff,False)
memory.createUninitializedBlock("peripherals", toAddr(0x3ffefff),0xfff, False)
memory.createInitializedBlock("rom", toAddr(0x0), fb[0], 0, 0x1000000, False)
disassemble(toAddr(0x0))

Yields:

Traceback (most recent call last):
  File "python", line 1, in <module>
    at ghidra.program.database.mem.MemoryMapDB.checkBlock(MemoryMapDB.java:1043)
    at ghidra.program.database.mem.MemoryMapDB.removeBlock(MemoryMapDB.java:1850)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Blocks do not belong to this program
ghidra.program.database.mem.MemoryBlockDB@6f03ae13
ghidra.program.database.mem.MemoryBlockDB@38d5ac1c
ghidra.program.database.mem.MemoryBlockDB@6ad8b9ac

What would be the correct sequence of arguments/flags/(instruction ordering?) to have a correct representation of a loaded V850 16MB firmware (size 0x1000000) on Ghidra? What am I doing wrong?

Here's the MCU PDF address space section for reference

3
  • 1
    If it's really Ghidra-specific it might be better handled over there. If you think it's a generic RE problem, please state it as such and provide the actual question instead of a link which may be wrong or dead in several years. – Igor Skochinsky Feb 24 at 11:59
  • Oh, sorry about that, I thought that the ghidra tag was meant for specific Ghidra questions as I was directed here a while ago in stackoverflow.com/questions/65314484/… – brainstorm Feb 24 at 12:05
  • 2
    sure we can (try to) answer RE questions in the context of Ghidra. But this is not an official support site for it. – Igor Skochinsky Feb 24 at 12:06
1

Note to self, when running memory.removeBlock(blk, monitor) make sure that the memory map is not empty from previous wipes/redefinitions (iterations of the script).

In other words, opening a file creates a default memory map, but the script wasn't contemplating the case where the address map was empty to begin with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.