Skip to content

Commit 9cc0f9c

Browse files
callthingsoffgopherbot
authored andcommitted
internal/xcoff: change zeroReaderAt to nobitsSectionReader for .bss with all 0s
Fixes #63337 Change-Id: I239315047e6e4325e2f471108fd764f8dbb7d5b2 GitHub-Last-Rev: cacdf0a GitHub-Pull-Request: #64952 Reviewed-on: https://go-review.googlesource.com/c/go/+/553616 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Than McIntosh <[email protected]>
1 parent 2413629 commit 9cc0f9c

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/internal/xcoff/file.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package xcoff
88
import (
99
"debug/dwarf"
1010
"encoding/binary"
11+
"errors"
1112
"fmt"
1213
"internal/saferio"
1314
"io"
@@ -261,7 +262,7 @@ func NewFile(r io.ReaderAt) (*File, error) {
261262
}
262263
r2 := r
263264
if scnptr == 0 { // .bss must have all 0s
264-
r2 = zeroReaderAt{}
265+
r2 = &nobitsSectionReader{}
265266
}
266267
s.sr = io.NewSectionReader(r2, int64(scnptr), int64(s.Size))
267268
s.ReaderAt = s.sr
@@ -451,15 +452,10 @@ func NewFile(r io.ReaderAt) (*File, error) {
451452
return f, nil
452453
}
453454

454-
// zeroReaderAt is ReaderAt that reads 0s.
455-
type zeroReaderAt struct{}
455+
type nobitsSectionReader struct{}
456456

457-
// ReadAt writes len(p) 0s into p.
458-
func (w zeroReaderAt) ReadAt(p []byte, off int64) (n int, err error) {
459-
for i := range p {
460-
p[i] = 0
461-
}
462-
return len(p), nil
457+
func (*nobitsSectionReader) ReadAt(p []byte, off int64) (n int, err error) {
458+
return 0, errors.New("unexpected read from section with uninitialized data")
463459
}
464460

465461
// Data reads and returns the contents of the XCOFF section s.

0 commit comments

Comments
 (0)