• Heschi Kreinick's avatar
    cmd/link: compress DWARF sections in ELF binaries · 594eae5a
    Heschi Kreinick authored
    Forked from CL 111895.
    
    The trickiest part of this is that the binary layout code (blk,
    elfshbits, and various other things) assumes a constant offset between
    symbols' and sections' file locations and their virtual addresses.
    Compression, of course, breaks this constant offset. But we need to
    assign virtual addresses to everything before compression in order to
    resolve relocations before compression. As a result, compression needs
    to re-compute the "address" of the DWARF sections and symbols based on
    their compressed size. Luckily, these are at the end of the file, so
    this doesn't perturb any other sections or symbols. (And there is, of
    course, a surprising amount of code that assumes the DWARF segment
    comes last, so what's one more place?)
    
    Relevant benchmarks:
    name        old time/op     new time/op     delta
    StdCmd          10.3s ± 2%      10.8s ± 1%   +5.43%  (p=0.000 n=30+30)
    
    name        old text-bytes  new text-bytes  delta
    HelloSize       746kB ± 0%      746kB ± 0%     ~     (all equal)
    CmdGoSize      8.41MB ± 0%     8.41MB ± 0%     ~     (all equal)
    [Geo mean]     2.50MB          2.50MB        +0.00%
    
    name        old data-bytes  new data-bytes  delta
    HelloSize      10.6kB ± 0%     10.6kB ± 0%     ~     (all equal)
    CmdGoSize       252kB ± 0%      252kB ± 0%     ~     (all equal)
    [Geo mean]     51.5kB          51.5kB        +0.00%
    
    name        old bss-bytes   new bss-bytes   delta
    HelloSize       125kB ± 0%      125kB ± 0%     ~     (all equal)
    CmdGoSize       145kB ± 0%      145kB ± 0%     ~     (all equal)
    [Geo mean]      135kB           135kB        +0.00%
    
    name        old exe-bytes   new exe-bytes   delta
    HelloSize      1.60MB ± 0%     1.05MB ± 0%  -34.39%  (p=0.000 n=30+30)
    CmdGoSize      16.5MB ± 0%     11.3MB ± 0%  -31.76%  (p=0.000 n=30+30)
    [Geo mean]     5.14MB          3.44MB       -33.08%
    
    Fixes #11799.
    Updates #6853.
    
    Change-Id: I64197afe4c01a237523a943088051ee056331c6f
    Reviewed-on: https://go-review.googlesource.com/118276
    Run-TryBot: Heschi Kreinick <heschi@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarAustin Clements <austin@google.com>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    594eae5a
Name
Last commit
Last update
..
README Loading commit data...
build.go Loading commit data...
buildgo.go Loading commit data...
buildruntime.go Loading commit data...
buildtool.go Loading commit data...
cpuid_386.s Loading commit data...
cpuid_amd64.s Loading commit data...
cpuid_default.s Loading commit data...
doc.go Loading commit data...
imports.go Loading commit data...
main.go Loading commit data...
sys_default.go Loading commit data...
sys_windows.go Loading commit data...
test.go Loading commit data...
test_linux.go Loading commit data...
util.go Loading commit data...
util_gc.go Loading commit data...
util_gccgo.go Loading commit data...
vfp_arm.s Loading commit data...
vfp_default.s Loading commit data...