This functionality exports Ghidra’s program information into a DWARF file. This exported information includes function names, types, stack variables, etc.
You can use this extension in different ways as documented below: This extension provides a DWARF exporter that can be used by right-clicking on the binary to export, then: From the You can also use the Java API from a (headless) script to export a given Ghidra program: This extension tries to convert as much as possible of Ghidra’s internal binary representation into DWARF structures, but this support is not exhaustive; here is an overview of what is and is not exported. ghidra.program.model.listing.Program Function Data Variables Types Comments ghidra.program.model.listing.Function Name Address range Parameters Type of parameters Return type Stack variables Types of stack variables Comments CodeUnits ghidra.program.model.listing.Data Name Type Address Comments ghidra.program.model.data.DataType Any types not mentioned here are not supported. https://github.com/NationalSecurityAgency/ghidra/issues/2687Project Manager¶
Export > Format > DWARF:
CodeBrowser¶
CodeBrowser tool, you can left-click on the LIEF menu and select Export as DWARF:
Scripts¶
import lief.ghidra.core.dwarf.export.Manager;
import lief.ghidra.core.NativeBridge;
public class LiefDwarfExportScript extends GhidraScript {
@Override
protected void run() throws Exception {
NativeBridge.init();
Manager manager = new Manager(currentProgram);
File output = new File("/home/romain/output.dwarf");
manager.export(output);
}
}
Support & Limitations¶
ghidra.program.model.data.VoidDataTypeghidra.program.model.data.AbstractIntegerDataTypeghidra.program.model.data.Arrayghidra.program.model.data.TypeDefghidra.program.model.data.Compositeghidra.program.model.data.Enumghidra.program.model.data.FunctionDefinitionghidra.program.model.data.PointerReferences¶