2

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

3

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)
1
  • I tried your code and unfortunately got the same results. Could be due to my binary. Thanks though! – R-E Jun 3 at 1:24

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.