This functionality exports Ghidra’s Program information into a DWARF file. This exported information include function’s 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: Export > Format > DWARF
:
From the CodeBrowser
tool, you can left click on the LIEF menu and select
Export as DWARF
:
You can also use the Java API from a (headless) script to export a given Ghidra’s Program:
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);
}
}
This extension tries to convert as much as possible Ghidra’s internal binary representation into DWARF structures, but this support can’t be exhaustive so here is an overview of what is exported and what is not.
ghidra.program.model.listing.Program
Function
Data Variables
Types
Comments
ghidra.program.model.listing.Function
Name
Addresses 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
ghidra.program.model.data.VoidDataType
ghidra.program.model.data.AbstractIntegerDataType
ghidra.program.model.data.Array
ghidra.program.model.data.TypeDef
ghidra.program.model.data.Composite
ghidra.program.model.data.Enum
ghidra.program.model.data.FunctionDefinition
ghidra.program.model.data.Pointer
Any types not mentioned here are not supported.
https://github.com/NationalSecurityAgency/ghidra/issues/2687