• 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
..
addr2line Loading commit data...
api Loading commit data...
asm Loading commit data...
buildid Loading commit data...
cgo Loading commit data...
compile Loading commit data...
cover Loading commit data...
dist Loading commit data...
doc Loading commit data...
fix Loading commit data...
go Loading commit data...
gofmt Loading commit data...
internal Loading commit data...
link Loading commit data...
nm Loading commit data...
objdump Loading commit data...
pack Loading commit data...
pprof Loading commit data...
test2json Loading commit data...
trace Loading commit data...
vendor Loading commit data...
vet Loading commit data...