]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: fix end-of-block padding
authorCherry Zhang <cherryyz@google.com>
Tue, 31 Mar 2020 18:36:19 +0000 (14:36 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 31 Mar 2020 20:42:24 +0000 (20:42 +0000)
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>
src/cmd/link/internal/ld/data.go

index b1c03b97ef4ca4d15e5d7644107fcd095c11c9ee..f7d8d13863b41845eaf020ea369ce7c7a762e020 100644 (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