Description
DWARF 5 has several advantages over previous versions of DWARF. Notably,
-
It supports position-independent representations, which significantly reduces the number of relocations in object files and hence the size of object files and the load on the linker. In the
go
binary, 49% of the 503,361 total relocations are in the DWARF. -
It supports much more compact location and range list formats. The location and range list sections are 6% of the 12MiB of the
go
binary, even when zlib compressed. -
It has an official language code for Go. :)
DWARF 5 is quite new, and I don't think the rest of the ecosystem is ready yet, but I wanted to get the idea floating. It is supported by the GNU and LLVM toolchains and some debuggers. Support was added in GCC 7.1 (May 2017) and GDB 8.0 (June 2017). It appears to be in the latest LLVM, which covers most of the Xcode tools, though I can't find when it was added.
It is currently not supported by LLDB or the macOS linker. We could potentially get around the macOS linker by leaving out the Go DWARF from the objects we pass to the system linker and then merging it in to the final binary (we already do a merge step). This is more feasible with DWARF5 because it's mostly position-independent, so we wouldn't need dsymutil to relocate it for us.
/cc @cherrymui @heschik @dr2chase @randall77 @ianlancetaylor