16

I have an ELF object file. I want to know which type of debugging info it contains. It was compiled with the Diab compiler (C source) for the PPC architecture. I'm pretty sure it was built with debugging symbols.

I have tried extracting the debugging info with dwarfdump but I doesn't work so I guess the debugging information is not of type DWARF.

$ dwarfdump file.elf
No DWARF information present in file.elf

Using objdump to show debugging information comes up empty.

$ objdump -g file.elf 
file.elf:     file format elf32-powerpc

Can it be that this ELF file does not contain debugging info even though the ELF file has sections called .debug_sfnames, .debug_srcinfo and .debug.srcinfo? Or is the debugging info stored in a format that objdump can't handle?

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
johnj33
  • 161
  • 1
  • 1
  • 3
  • 1
    Can you post the file somewhere? – Martin Carpenter Aug 17 '11 at 23:05
  • 3
    try with "objdump -W file.elf" as well, just in case. I think objdump -g won't be happy unless the info is STABS – NullPointer Aug 18 '11 at 09:37
  • 1
    Ok I figured it out. Well I still don't really know what type of debugging information the ELF file contains, but I found the command to extract it. ddump2 -D elffile does the trick. I think ddump2 belongs to the toolchain that came with the diab compiler. – johnj33 Aug 20 '11 at 23:25

3 Answers3

7

You should probably use the nm

The nm utility shall display symbolic information appearing in the object file, executable file, or object-file library named by file. If no symbolic information is available for a valid input file, the nm utility shall report that fact, but not consider it an error condition.

Alternatively you can use tools like ldd to see what libraries are required by a binary.

Community
  • 1
  • 1
Lelouch Lamperouge
  • 8,171
  • 8
  • 49
  • 60
6

It doesn't seem like anyone ever answered your actual question, which is: how to programmatically determine the flavor of debug symbols present in a given ELF binary. As best as I can tell, this isn't given explicitly within ELF; however, it can be inferred by the presence of specific section names within the ELF file. For example: a section named ".debug_info" implies DWARF2 or better, whereas ".stab" implies stabs. A quick googling of your ".debug_sfnames" suggests DWARF1. (I don't know why your 'dwarfdump' didn't identify that... perhaps your dwarfdump is for newer DWARFs, and dumped backwards compatibility?)

Cognitive Hazard
  • 1,072
  • 10
  • 25
6

In GNU/Linux:

$ readelf --debug-dump=info /absolute/path/to/file | grep "Version" | uniq

Returns the DWARF symbols version used in the binary.

Diego Pino
  • 11,278
  • 1
  • 55
  • 57