ghidra icon indicating copy to clipboard operation
ghidra copied to clipboard

Add MicroBlaze CPUs support

Open AJIOB opened this issue 9 months ago • 2 comments

Xilinx/AMD FPGAs support Microblaze soft CPU (IP core).

What about support it's assembly/elf files?

Processor reference guide with ISA & opcodes can be found here.

I need to analyze some parts of generated assembly code, and a Ghidra is a nice tool to do this.

P.S. Microblaze uses GCC toolchain for building it's elf files. It can be installed as a part of the Vitis/Vivado SDK and looks like it free of charge. P.P.S. Looks like somebody tries to implement it here. It looks like the nice start point, but I have no ideas how it should be integrated via the latest Ghidra version. I prefer to have a default integration, because I don't want to rebuild Ghidra from the sources.

AJIOB avatar Oct 04 '23 13:10 AJIOB

You don't need to compile Ghidra from source to add a new processor. Assuming the above linked Microblaze processor module works, clone the repo to your Ghidra/Processors/ directory.

When you import your binary, manually select "Microblaze" from the list.

pjsoberoi avatar Oct 05 '23 05:10 pjsoberoi

@pjsoberoi, thanks!

Your suggestion was helpful.

But as I can see, the suggested repository have few issues:

  1. It is supported only 32-bit CPUs, while v11 specification support both 32 & 64-bit CPUs
  2. It is not a part of the default Ghidra distribution
  3. While importing an elf file, I received this error:
Exception reading mb:LE:32:default/default(mb.cspec): <pentry> tags within a group must be distinguished by size or type
ghidra.program.model.lang.CompilerSpecNotFoundException: Exception reading mb:LE:32:default/default(mb.cspec): <pentry> tags within a group must be distinguished by size or type
	at ghidra.program.model.lang.BasicCompilerSpec.<init>(BasicCompilerSpec.java:153)
	at ghidra.app.plugin.processors.sleigh.SleighLanguage.getCompilerSpecByID(SleighLanguage.java:1184)
	at ghidra.app.util.opinion.AbstractLibrarySupportLoader.doLoad(AbstractLibrarySupportLoader.java:829)
	at ghidra.app.util.opinion.AbstractLibrarySupportLoader.loadProgram(AbstractLibrarySupportLoader.java:99)
	at ghidra.app.util.opinion.AbstractProgramLoader.load(AbstractProgramLoader.java:131)
	at ghidra.plugin.importer.ImporterUtilities.importSingleFile(ImporterUtilities.java:395)
	at ghidra.plugin.importer.ImporterDialog.lambda$okCallback$7(ImporterDialog.java:336)
	at ghidra.util.task.TaskBuilder$TaskBuilderTask.run(TaskBuilder.java:306)
	at ghidra.util.task.Task.monitoredRun(Task.java:134)
	at ghidra.util.task.TaskRunner.lambda$startTaskThread$0(TaskRunner.java:106)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: ghidra.xml.XmlParseException: <pentry> tags within a group must be distinguished by size or type
	at ghidra.program.model.lang.ParamEntry.orderWithinGroup(ParamEntry.java:730)
	at ghidra.program.model.lang.ParamListStandardOut.restoreXml(ParamListStandardOut.java:82)
	at ghidra.program.model.lang.PrototypeModel.restoreXml(PrototypeModel.java:612)
	at ghidra.program.model.lang.BasicCompilerSpec.addPrototypeModel(BasicCompilerSpec.java:1073)
	at ghidra.program.model.lang.BasicCompilerSpec.restoreXml(BasicCompilerSpec.java:625)
	at ghidra.program.model.lang.BasicCompilerSpec.initialize(BasicCompilerSpec.java:244)
	at ghidra.program.model.lang.BasicCompilerSpec.<init>(BasicCompilerSpec.java:131)
	... 12 more

---------------------------------------------------
Build Date: 2023-Sep-28 1301 EDT
Ghidra Version: 10.4
Java Home: C:\Program Files\Eclipse Adoptium\jdk-17.0.4.101-hotspot
JVM Version: Eclipse Adoptium 17.0.4.1
OS: Windows 10 10.0 amd64
Workstation: ALEX-PC-Y700

Looks like it is a broken backward compatibility. More info may be found here: https://github.com/mumbel/ghidra_i960/issues/7, https://github.com/sualk/ghidra-blackfin/issues/1 and so on.

AJIOB avatar Oct 05 '23 10:10 AJIOB