aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2016-03-11 18:54:37 -0800
committerMatthew Dempsky <mdempsky@google.com>2016-03-14 05:13:31 +0000
commitedde955d7fe610c2b0250efff548b89e22493349 (patch)
tree52aefb105a66dc3461d7850e69b505078e40f71a /src/cmd/internal
parent4f753e77f1cee1aaca5a2166ef38c47a61b142a4 (diff)
downloadgo-edde955d7fe610c2b0250efff548b89e22493349.tar.xz
cmd/internal/obj: support arbitrarily sized string data
Updates #14786. Change-Id: I5fe889886f772167386cd10390ac50abc1383937 Reviewed-on: https://go-review.googlesource.com/20607 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'src/cmd/internal')
-rw-r--r--src/cmd/internal/obj/data.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/cmd/internal/obj/data.go b/src/cmd/internal/obj/data.go
index 1f09c9de12..e6d116610c 100644
--- a/src/cmd/internal/obj/data.go
+++ b/src/cmd/internal/obj/data.go
@@ -54,7 +54,7 @@ func Symgrow(ctxt *Link, s *LSym, lsiz int64) {
// prepwrite prepares to write data of size siz into s at offset off.
func (s *LSym) prepwrite(ctxt *Link, off, siz int64) {
- if off < 0 || siz < 0 || off >= 1<<30 || siz >= 100 {
+ if off < 0 || siz < 0 || off >= 1<<30 {
log.Fatalf("prepwrite: bad off=%d siz=%d", off, siz)
}
if s.Type == SBSS || s.Type == STLSBSS {
@@ -80,7 +80,7 @@ func (s *LSym) WriteInt(ctxt *Link, off, siz int64, i int64) {
s.prepwrite(ctxt, off, siz)
switch siz {
default:
- ctxt.Diag("WriteInt bad integer: %d", siz)
+ ctxt.Diag("WriteInt: bad integer size: %d", siz)
case 1:
s.P[off] = byte(i)
case 2:
@@ -95,6 +95,9 @@ func (s *LSym) WriteInt(ctxt *Link, off, siz int64, i int64) {
// WriteAddr writes an address of size siz into s at offset off.
// rsym and roff specify the relocation for the address.
func (s *LSym) WriteAddr(ctxt *Link, off, siz int64, rsym *LSym, roff int64) {
+ if siz != int64(ctxt.Arch.Ptrsize) {
+ ctxt.Diag("WriteAddr: bad address size: %d", siz)
+ }
s.prepwrite(ctxt, off, siz)
r := Addrel(s)
r.Off = int32(off)
@@ -106,6 +109,9 @@ func (s *LSym) WriteAddr(ctxt *Link, off, siz int64, rsym *LSym, roff int64) {
// WriteString writes a string of size siz into s at offset off.
func (s *LSym) WriteString(ctxt *Link, off, siz int64, str string) {
+ if siz < int64(len(str)) {
+ ctxt.Diag("WriteString: bad string size: %d < %d", siz, len(str))
+ }
s.prepwrite(ctxt, off, siz)
copy(s.P[off:off+siz], str)
}