I am trying to create a DWARFProgram for a Ghidra program. I would like to extract the function debug symbols. I get an error when constructing the DWARFProgram.

The constructor prints the following and then throws a NullPointerException:

Elf symbol table section .dynsym linked to string table section .dynstr
Elf symbol table section .symtab linked to string table section .strtab
Elf relocation table section .rel.dyn linked to symbol table section .dynsym affecting PT_LOAD
Reading DWARF debug string table

My code (using Jython):

monitor = ConsoleTaskMonitor()
program = ghidraProject.openProgram('/', programName, False)
binfile = File(programDir + programName)
options = DWARFImportOptions()
sectionProvider = ElfSectionProvider(binfile)
dwarfProg = DWARFProgram(program, options, monitor, sectionProvider)

Screenshot of console: DwarfProgram Error Message

1 Answer 1


I think you should debug your script on smaller programs first. It is possible that the arguments you are passing are incorrect (I don't have your complete program so that I can tell). It is also possible that the dwarf section is damaged on unrecognizable.

The following program runs fine on my machine.

monitor = ConsoleTaskMonitor()
options = DWARFImportOptions()
sectionProvider = ElfSectionProvider.createSectionProviderFor(currentProgram)
dwarfProg = DWARFProgram(currentProgram, options, monitor, sectionProvider)
  • I tried your code and unfortunately got the same results. Could be due to my binary. Thanks though!
    – rbe
    Jun 3, 2021 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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