We already check mmap errors on some code paths, but we missed
one. Add error check there.
Change-Id: Ic0e9cb0eb03c805de40802cfc5d5500e3e065d99
Reviewed-on: https://go-review.googlesource.com/c/go/+/319290
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
}
}
filesz := ctxt.Out.Offset() + sz
- ctxt.Out.Mmap(uint64(filesz))
+ err := ctxt.Out.Mmap(uint64(filesz))
+ if err != nil {
+ Exitf("mapping output file failed: %v", err)
+ }
}
// relocSectFn wraps the function writing relocations of a section
// Don't mmap if we're building for Wasm. Wasm file
// layout is very different so filesize is meaningless.
if err := ctxt.Out.Mmap(filesize); err != nil {
- panic(err)
+ Exitf("mapping output file failed: %v", err)
}
}
// asmb will redirect symbols to the output file mmap, and relocations
total := uint64(bufLen + heapLen)
if heapLen != 0 {
if err := out.Mmap(total); err != nil { // Mmap will copy out.heap over to out.buf
- panic(err)
+ Exitf("mapping output file failed: %v", err)
}
}
return true