• Austin Clements's avatar
    cmd/link: separate virtual address layout from file layout · bd837745
    Austin Clements authored
    Currently these two forms of layout are done in a single pass. This
    makes it difficult to compress DWARF sections because that must be
    done after relocations are applied, which must happen after virtual
    address layout, but we can't layout the file until we've compressed
    the DWARF sections.
    
    Fix this by separating the two layout steps. In the process, we can
    also unify the copy-pasted code in Link.address to compute file
    offsets. Currently, each instance of this is slightly different, but
    there's no reason for it to be. For example, we don't perform
    PEFILEALIGN alignment on Segrodata or Selreltodata even when HeadType
    == Hwindows, but it turns out it doesn't matter whether you do or
    don't because these segments simply don't exist on Windows. Hence, in
    the unified code path, we do this alignment for all segments.
    Likewise, there are two ways of computing Fileoff:
      seg.Vaddr - prev.Vaddr + prev.Fileoff
    and
      prev.Fileoff + uint64(Rnd(int64(prev.Filelen), int64(*FlagRound)))
    At the moment, these always have the same value, but the latter will
    continue to work after we start compressing sections on disk.
    
    Tested by comparing test binaries for all packages in std before and
    after this change for GOOS={linux,windows,darwin,plan9}. All binaries
    are identical.
    
    For #11799.
    
    Change-Id: If09f28771bb4d78dd392fd58b8d7c9d5f22b0b9f
    Reviewed-on: https://go-review.googlesource.com/111682
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarHeschi Kreinick <heschi@google.com>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    bd837745
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...