fn = func(ctxt *Link, sect *sym.Section, syms []loader.Sym) {
wg.Add(1)
sem <- 1
- out, err := ctxt.Out.View(sect.Reloff)
- if err != nil {
- panic(err)
- }
+ out := ctxt.Out.View(sect.Reloff)
go func() {
relocSect(ctxt, out, sect, syms)
wg.Done()
}
// Start the block output operator.
- if o, err := out.View(uint64(out.Offset() + written)); err == nil {
+ if ctxt.Out.isMmapped() {
+ o := out.View(uint64(out.Offset() + written))
sem <- 1
wg.Add(1)
go func(o *OutBuf, ldr *loader.Loader, syms []loader.Sym, addr, size int64, pad []byte) {
// writeParallel handles scheduling parallel execution of data write functions.
func writeParallel(wg *sync.WaitGroup, fn writeFn, ctxt *Link, seek, vaddr, length uint64) {
- if out, err := ctxt.Out.View(seek); err != nil {
- ctxt.Out.SeekSet(int64(seek))
- fn(ctxt, ctxt.Out, int64(vaddr), int64(length))
- } else {
+ if ctxt.Out.isMmapped() {
+ out := ctxt.Out.View(seek)
wg.Add(1)
go func() {
defer wg.Done()
fn(ctxt, out, int64(vaddr), int64(length))
}()
+ } else {
+ ctxt.Out.SeekSet(int64(seek))
+ fn(ctxt, ctxt.Out, int64(vaddr), int64(length))
}
}
}
}
-var viewError = errors.New("output not mmapped")
-
-func (out *OutBuf) View(start uint64) (*OutBuf, error) {
+func (out *OutBuf) View(start uint64) *OutBuf {
return &OutBuf{
arch: out.arch,
name: out.name,
heap: out.heap,
off: int64(start),
isView: true,
- }, nil
+ }
}
var viewCloseError = errors.New("cannot Close OutBuf from View")