[Dwarf-Discuss] Help and suggestion on DWARF file format

John DelSignore jdelsign@totalviewtech.com
Mon Apr 20 13:09:41 GMT 2009


The DWARF produced by the GCC and (at least) Intel compilers is pretty much the same on Mac OS X as on Linux, but *how* the DWARF is stored in the image files is different.

On Linux, DWARF is stored in an ELF image, as part of either the executable, shared library, or separate symbol files <http://sources.redhat.com/gdb/current/onlinedocs/gdb_17.html#SEC166>. Depending on the compiler family, it is also sometimes necessary to read the ELF symbol table in order to get correct addressing information for certain kinds of program objects.

Mac OS X in a bit trickier because it uses Mach-O format image files, not ELF files so you'll need to deal with Mach-O format files and nlist symbol format. DWARF support was introduced in versions of Mac OS X Xcode 2.3 GCC 4.0.1 (and later). The basic approach is to leave the DWARF debug information in the object (.o) file, and have the linker construct a Debug Map. The Apple document that describes the scheme in detail is, "Apple Computer, Inc.; Development Technologies; DWARF Debug Format Implementation Engineering Specification". One of the DWARF Workgroup members posted an outline here <http://wiki.dwarfstd.org/index.php?title=Apple%27s_%22Lazy%22_DWARF_Scheme>.

Cheers, John D.


Arnab Ganguly wrote:
> Any idea about the DWARF generated from Mac and Linux are going to be
> identical or not?
> Arnab
> 
> On Mon, Apr 20, 2009 at 1:05 PM, Roland McGrath <roland at redhat.com
> <mailto:roland at redhat.com>> wrote:
> 
>     > Basically my intent is to write  a universal reader which can read the
>     > DWARF files and on basis of the program counters it should be able to
>     > tell the function name , line number and the file name.
> 
>     You may find you already have a program invoked as "addr2line -f -e" or
>     "eu-addr2line -f -e" that can do this.  MacOS might even have something
>     nearly identical.
> 
> 
>     Thanks,
>     Roland
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Dwarf-Discuss mailing list
> Dwarf-Discuss at lists.dwarfstd.org
> http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org




More information about the Dwarf-discuss mailing list