From: Cherry Zhang Date: Tue, 31 Mar 2020 18:36:19 +0000 (-0400) Subject: [dev.link] cmd/link: fix end-of-block padding X-Git-Tag: go1.15beta1~679^2~14 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=aef23f5be9c76c608562e4607dc707a07360526a;p=gostls13.git [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 TryBot-Result: Gobot Gobot Reviewed-by: Than McIntosh Reviewed-by: Jeremy Faller --- 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