]> Cypherpunks repositories - gostls13.git/commit
cmd/link: emit include directories in DWARF line table prologue
authorThan McIntosh <thanm@google.com>
Fri, 16 Oct 2020 13:22:31 +0000 (09:22 -0400)
committerThan McIntosh <thanm@google.com>
Fri, 30 Oct 2020 18:01:54 +0000 (18:01 +0000)
commitfb184a383e756cb57267590ac290be0d3bb64874
tree5724424b3d307f99ea52ba75a100e92c5dab0f6a
parente02ab89eb8994fa6f2dfa2924cdadb097633fcc1
cmd/link: emit include directories in DWARF line table prologue

This patch changes the way the linker emits the DWARF line table
prologue, specifically the file table. Previously files were left
unmodified, and the directory table was empty. For each compilation
unit we now scan the unit file table and build up a common set of
directories, emit them into the directory table, and then emit file
entries that refer to the dirs. This provides a modest binary size
savings.

For kubernetes kubelet:

$ objdump -h /tmp/kubelet.old | fgrep debug_line
 36 .zdebug_line  019a55f5  0000000000000000  0000000000000000  084a5123  2**0
$ objdump -h /tmp/kubelet.new | fgrep debug_line
 36 .zdebug_line  01146fd2  0000000000000000  0000000000000000  084a510a  2**0

[where the value following the section name above is the section size
in hex, so roughly a 30% decrease in this case.]

The actual savings will depend on the length of the pathnames
involved, so it's hard to really pin down how much savings we'll see
here. In addition, emitting the files this way reduces the
"compressibility" of the line table, so there could even be cases
where we don't win at all.

Updates #6853, #19784, #36495.

Change-Id: I298d8561da5ed3ebc9d38aa772874851baa2f4f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/263017
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/dwarf.go
src/debug/dwarf/line.go
src/debug/dwarf/line_test.go