mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: do not write slices/strings > 2g
The linker will refuse to work on objects larger than 2e9 bytes (see issue #9862 for why). With this change, the compiler gives a useful error message explaining this, instead of leaving it to the linker to give a cryptic message later. Fixes #1700. Change-Id: I3933ce08ef846721ece7405bdba81dff644cb004 Reviewed-on: https://go-review.googlesource.com/74330 Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
8fc64a3060
commit
d7ac9bb992
4 changed files with 20 additions and 9 deletions
|
|
@ -1008,11 +1008,13 @@ func (d bySizeAndName) Less(i, j int) bool {
|
|||
return s1.name < s2.name
|
||||
}
|
||||
|
||||
const cutoff int64 = 2e9 // 2 GB (or so; looks better in errors than 2^31)
|
||||
// cutoff is the maximum data section size permitted by the linker
|
||||
// (see issue #9862).
|
||||
const cutoff = 2e9 // 2 GB (or so; looks better in errors than 2^31)
|
||||
|
||||
func checkdatsize(ctxt *Link, datsize int64, symn sym.SymKind) {
|
||||
if datsize > cutoff {
|
||||
Errorf(nil, "too much data in section %v (over %d bytes)", symn, cutoff)
|
||||
Errorf(nil, "too much data in section %v (over %v bytes)", symn, cutoff)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue