aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-03-31 14:36:19 -0400
committerCherry Zhang <cherryyz@google.com>2020-03-31 20:42:24 +0000
commitaef23f5be9c76c608562e4607dc707a07360526a (patch)
tree66c80cf8cffbd7aad73c5e94d563157743867b31
parent721716ca1cfac23787aa3c722a8eecd9a0d5b296 (diff)
downloadgo-aef23f5be9c76c608562e4607dc707a07360526a.tar.gz
go-aef23f5be9c76c608562e4607dc707a07360526a.zip
[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>
-rw-r--r--src/cmd/link/internal/ld/data.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go
index b1c03b97ef..f7d8d13863 100644
--- a/src/cmd/link/internal/ld/data.go
+++ b/src/cmd/link/internal/ld/data.go
@@ -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