aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/goobj2/objfile.go
diff options
context:
space:
mode:
authorDmitri Shuralyov <dmitshur@golang.org>2021-02-05 19:53:15 +0000
committerDmitri Shuralyov <dmitshur@golang.org>2021-02-05 19:53:15 +0000
commit2a0dd053ecfa528adc0f763a546519a7257ed8cd (patch)
tree11af29257d714309eae879573ff3b7f6000e227c /src/cmd/internal/goobj2/objfile.go
parent79ea7a16d7e3bc36e98a4b7afd997bb315e80a1c (diff)
parentfa6752a5370735b8c2404d6de5191f2eea67130f (diff)
downloadgo-2a0dd053ecfa528adc0f763a546519a7257ed8cd.tar.gz
go-2a0dd053ecfa528adc0f763a546519a7257ed8cd.zip
[dev.boringcrypto.go1.15] all: merge go1.15.8 into dev.boringcrypto.go1.15
Change-Id: Ife009bce76e8aecb2255c69dbb5cadb61c22d2c3
Diffstat (limited to 'src/cmd/internal/goobj2/objfile.go')
-rw-r--r--src/cmd/internal/goobj2/objfile.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/internal/goobj2/objfile.go b/src/cmd/internal/goobj2/objfile.go
index 7f728e4f76..aba9b9856e 100644
--- a/src/cmd/internal/goobj2/objfile.go
+++ b/src/cmd/internal/goobj2/objfile.go
@@ -379,6 +379,11 @@ func (a *Aux) Write(w *Writer) { w.Bytes(a[:]) }
// for testing
func (a *Aux) fromBytes(b []byte) { copy(a[:], b) }
+// Used to construct an artifically large array type when reading an
+// item from the object file relocs section or aux sym section (needs
+// to work on 32-bit as well as 64-bit). See issue 41621.
+const huge = (1<<31 - 1) / RelocSize
+
// Referenced symbol name.
//
// Serialized format:
@@ -652,7 +657,7 @@ func (r *Reader) Reloc(i int, j int) *Reloc {
func (r *Reader) Relocs(i int) []Reloc {
off := r.RelocOff(i, 0)
n := r.NReloc(i)
- return (*[1 << 20]Reloc)(unsafe.Pointer(&r.b[off]))[:n:n]
+ return (*[huge]Reloc)(unsafe.Pointer(&r.b[off]))[:n:n]
}
// NAux returns the number of aux symbols of the i-th symbol.
@@ -678,7 +683,7 @@ func (r *Reader) Aux(i int, j int) *Aux {
func (r *Reader) Auxs(i int) []Aux {
off := r.AuxOff(i, 0)
n := r.NAux(i)
- return (*[1 << 20]Aux)(unsafe.Pointer(&r.b[off]))[:n:n]
+ return (*[huge]Aux)(unsafe.Pointer(&r.b[off]))[:n:n]
}
// DataOff returns the offset of the i-th symbol's data.