Revert "[dev.link] cmd/link: remove buffered file I/O from OutBuf"

This reverts commit b2def42d9e.

Reason for revert: trybots failing

Change-Id: I920be6d8de158b1e513154ac0eb0c8fa0cffa9f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/228657
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Jeremy Faller 2020-04-16 23:33:11 +00:00
parent b2def42d9e
commit 7fe3f30bbb
15 changed files with 135 additions and 41 deletions

View file

@ -32,6 +32,7 @@
package ld
import (
"bufio"
"bytes"
"cmd/internal/gcprog"
"cmd/internal/objabi"
@ -957,10 +958,11 @@ func Datblk(ctxt *Link, out *OutBuf, addr, size int64) {
// Used only on Wasm for now.
func DatblkBytes(ctxt *Link, addr int64, size int64) []byte {
buf := make([]byte, size)
out := &OutBuf{heap: buf}
buf := bytes.NewBuffer(make([]byte, 0, size))
out := &OutBuf{w: bufio.NewWriter(buf)}
writeDatblkToOutBuf(ctxt, out, addr, size)
return buf
out.Flush()
return buf.Bytes()
}
func writeDatblkToOutBuf(ctxt *Link, out *OutBuf, addr int64, size int64) {