1
0
mirror of https://github.com/golang/go synced 2024-11-12 08:10:21 -07:00

cmd/internal/obj: convert Symgrow to a method

Passes toolstash -cmp.

Change-Id: I77a415a4e5d8de7eb902fb0866aaf8783259485a
Reviewed-on: https://go-review.googlesource.com/20770
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2016-03-16 14:10:51 -07:00
parent 5a34472d74
commit fb950cd778
6 changed files with 13 additions and 12 deletions

View File

@ -737,7 +737,7 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) {
p = cursym.Text
ctxt.Autosize = int32(p.To.Offset + 4)
obj.Symgrow(ctxt, cursym, cursym.Size)
cursym.Grow(cursym.Size)
bp := cursym.P
c = int32(p.Pc) // even p->link might need extra padding

View File

@ -629,7 +629,7 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) {
/*
* lay out the code, emitting code and data relocations.
*/
obj.Symgrow(ctxt, cursym, cursym.Size)
cursym.Grow(cursym.Size)
bp := cursym.P
psz := int32(0)
var i int

View File

@ -36,10 +36,11 @@ import (
"math"
)
func Symgrow(ctxt *Link, s *LSym, lsiz int64) {
// Grow increases the length of s.P to lsiz.
func (s *LSym) Grow(lsiz int64) {
siz := int(lsiz)
if int64(siz) != lsiz {
log.Fatalf("Symgrow size %d too long", lsiz)
log.Fatalf("LSym.Grow size %d too long", lsiz)
}
if len(s.P) >= siz {
return
@ -60,7 +61,7 @@ func (s *LSym) prepwrite(ctxt *Link, off int64, siz int) {
if s.Type == SBSS || s.Type == STLSBSS {
ctxt.Diag("cannot supply data for BSS var")
}
Symgrow(ctxt, s, off+int64(siz))
s.Grow(off + int64(siz))
}
// WriteFloat32 writes f into s at offset off.
@ -127,7 +128,7 @@ func Setuintxx(ctxt *Link, s *LSym, off int64, v uint64, wid int64) int64 {
}
if s.Size < off+wid {
s.Size = off + wid
Symgrow(ctxt, s, s.Size)
s.Grow(s.Size)
}
switch wid {

View File

@ -415,7 +415,7 @@ func span0(ctxt *obj.Link, cursym *obj.LSym) {
* lay out the code, emitting code and data relocations.
*/
obj.Symgrow(ctxt, cursym, cursym.Size)
cursym.Grow(cursym.Size)
bp := cursym.P
var i int32

View File

@ -506,7 +506,7 @@ func span9(ctxt *obj.Link, cursym *obj.LSym) {
* lay out the code, emitting code and data relocations.
*/
obj.Symgrow(ctxt, cursym, cursym.Size)
cursym.Grow(cursym.Size)
bp := cursym.P
var i int32

View File

@ -1748,7 +1748,7 @@ func fillnop(p []byte, n int) {
}
func naclpad(ctxt *obj.Link, s *obj.LSym, c int32, pad int32) int32 {
obj.Symgrow(ctxt, s, int64(c)+int64(pad))
s.Grow(int64(c) + int64(pad))
fillnop(s.P[c:], int(pad))
return c + pad
}
@ -1878,7 +1878,7 @@ func span6(ctxt *obj.Link, s *obj.LSym) {
v := -c & (LoopAlign - 1)
if v <= MaxLoopPad {
obj.Symgrow(ctxt, s, int64(c)+int64(v))
s.Grow(int64(c) + int64(v))
fillnop(s.P[c:], int(v))
c += v
}
@ -1915,7 +1915,7 @@ func span6(ctxt *obj.Link, s *obj.LSym) {
loop++
}
obj.Symgrow(ctxt, s, p.Pc+int64(m))
s.Grow(p.Pc + int64(m))
copy(s.P[p.Pc:], ctxt.AsmBuf.Bytes())
c += int32(m)
}
@ -1940,7 +1940,7 @@ func span6(ctxt *obj.Link, s *obj.LSym) {
// Pad functions with trap instruction, to catch invalid jumps
if c&(FuncAlign-1) != 0 {
v := -c & (FuncAlign - 1)
obj.Symgrow(ctxt, s, int64(c)+int64(v))
s.Grow(int64(c) + int64(v))
for i := c; i < c+v; i++ {
// 0xCC is INT $3 - breakpoint instruction
s.P[i] = uint8(0xCC)