mirror of
https://github.com/golang/go.git
synced 2025-10-19 19:13:18 +00:00
cmd/link: fix outdated output mmap check
This commit is contained in:
parent
bb0c14b895
commit
6449f2973d
3 changed files with 10 additions and 13 deletions
|
@ -195,10 +195,7 @@ func relocSectFn(ctxt *Link, relocSect func(*Link, *OutBuf, *sym.Section, []load
|
||||||
fn = func(ctxt *Link, sect *sym.Section, syms []loader.Sym) {
|
fn = func(ctxt *Link, sect *sym.Section, syms []loader.Sym) {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
sem <- 1
|
sem <- 1
|
||||||
out, err := ctxt.Out.View(sect.Reloff)
|
out := ctxt.Out.View(sect.Reloff)
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
go func() {
|
go func() {
|
||||||
relocSect(ctxt, out, sect, syms)
|
relocSect(ctxt, out, sect, syms)
|
||||||
wg.Done()
|
wg.Done()
|
||||||
|
|
|
@ -1063,7 +1063,8 @@ func writeBlocks(ctxt *Link, out *OutBuf, sem chan int, ldr *loader.Loader, syms
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the block output operator.
|
// 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
|
sem <- 1
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(o *OutBuf, ldr *loader.Loader, syms []loader.Sym, addr, size int64, pad []byte) {
|
go func(o *OutBuf, ldr *loader.Loader, syms []loader.Sym, addr, size int64, pad []byte) {
|
||||||
|
@ -1142,15 +1143,16 @@ type writeFn func(*Link, *OutBuf, int64, int64)
|
||||||
|
|
||||||
// writeParallel handles scheduling parallel execution of data write functions.
|
// writeParallel handles scheduling parallel execution of data write functions.
|
||||||
func writeParallel(wg *sync.WaitGroup, fn writeFn, ctxt *Link, seek, vaddr, length uint64) {
|
func writeParallel(wg *sync.WaitGroup, fn writeFn, ctxt *Link, seek, vaddr, length uint64) {
|
||||||
if out, err := ctxt.Out.View(seek); err != nil {
|
if ctxt.Out.isMmapped() {
|
||||||
ctxt.Out.SeekSet(int64(seek))
|
out := ctxt.Out.View(seek)
|
||||||
fn(ctxt, ctxt.Out, int64(vaddr), int64(length))
|
|
||||||
} else {
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
fn(ctxt, out, int64(vaddr), int64(length))
|
fn(ctxt, out, int64(vaddr), int64(length))
|
||||||
}()
|
}()
|
||||||
|
} else {
|
||||||
|
ctxt.Out.SeekSet(int64(seek))
|
||||||
|
fn(ctxt, ctxt.Out, int64(vaddr), int64(length))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,9 +92,7 @@ func NewOutBuf(arch *sys.Arch) *OutBuf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewError = errors.New("output not mmapped")
|
func (out *OutBuf) View(start uint64) *OutBuf {
|
||||||
|
|
||||||
func (out *OutBuf) View(start uint64) (*OutBuf, error) {
|
|
||||||
return &OutBuf{
|
return &OutBuf{
|
||||||
arch: out.arch,
|
arch: out.arch,
|
||||||
name: out.name,
|
name: out.name,
|
||||||
|
@ -102,7 +100,7 @@ func (out *OutBuf) View(start uint64) (*OutBuf, error) {
|
||||||
heap: out.heap,
|
heap: out.heap,
|
||||||
off: int64(start),
|
off: int64(start),
|
||||||
isView: true,
|
isView: true,
|
||||||
}, nil
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewCloseError = errors.New("cannot Close OutBuf from View")
|
var viewCloseError = errors.New("cannot Close OutBuf from View")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue