aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/ld/outbuf.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/link/internal/ld/outbuf.go')
-rw-r--r--src/cmd/link/internal/ld/outbuf.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cmd/link/internal/ld/outbuf.go b/src/cmd/link/internal/ld/outbuf.go
index 09162ae90f..7bc89540c6 100644
--- a/src/cmd/link/internal/ld/outbuf.go
+++ b/src/cmd/link/internal/ld/outbuf.go
@@ -187,7 +187,9 @@ func (out *OutBuf) writeLoc(lenToWrite int64) (int64, []byte) {
// See if our heap would grow to be too large, and if so, copy it to the end
// of the mmapped area.
if heapLen > maxOutBufHeapLen && out.copyHeap() {
- heapPos, heapLen, lenNeeded = 0, 0, lenToWrite
+ heapPos -= heapLen
+ lenNeeded = heapPos + lenToWrite
+ heapLen = 0
}
out.heap = append(out.heap, make([]byte, lenNeeded-heapLen)...)
}