Skip to content

Commit 7b0f430

Browse files
committed
cmd/link/internal/ld: Clarify comment
1 parent 127454a commit 7b0f430

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

  • src/cmd/link/internal/ld

src/cmd/link/internal/ld/pe.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,10 +1516,11 @@ func Asmbpe(ctxt *Link) {
15161516
}
15171517

15181518
if rsrcsym != 0 {
1519-
// rsrc.P resides in mmap'd memory, which could be munmap'd
1520-
// underneath us before it comes time to actually use it.
1521-
// To avoid any issues we copy the data to the heap to ensure
1522-
// we don't segfault later when trying to access it.
1519+
// The resource symbol may have been copied to the mmap'd
1520+
// output buffer. If so, certain conditions can cause that
1521+
// mmap'd output buffer to be munmap'd before we get a chance
1522+
// to use it. To avoid any issues we copy the data to the heap
1523+
// when the resource symbol exists.
15231524
rsrc := ctxt.loader.Syms[rsrcsym]
15241525
data := make([]byte, len(rsrc.P))
15251526
copy(data, rsrc.P)

0 commit comments

Comments
 (0)