1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:04:42 -07:00

[dev.link] cmd/link: fix end-of-block padding

Make sure we write the entire address range we are asked to write,
with no holes between the blocks or at the end.

Should fix NetBSD build.

Change-Id: I13b1f551377cbc4bcde3650417ac95cba62ff807
Reviewed-on: https://go-review.googlesource.com/c/go/+/226617
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Cherry Zhang 2020-03-31 14:36:19 -04:00
parent 721716ca1c
commit aef23f5be9

View File

@ -826,7 +826,6 @@ func writeBlocks(out *OutBuf, sem chan int, syms []*sym.Symbol, addr, size int64
// We're gonna write this symbol.
idx = i
length = s.Value + s.Size - addr
// If we cross over the max size, we've got enough symbols.
if s.Value+s.Size > addr+max {
@ -839,6 +838,13 @@ func writeBlocks(out *OutBuf, sem chan int, syms []*sym.Symbol, addr, size int64
break
}
// Compute the length to write, including padding.
if idx+1 < len(syms) {
length = syms[idx+1].Value - addr
} else {
length = lastAddr - addr
}
// Start the block output operator.
if o, err := out.View(uint64(out.Offset() + written)); err == nil {
sem <- 1