Skip to content

Commit fd50db2

Browse files
committed
cmd/internal/obj: remove unused code
Following on from CL 14350, remove the remaining dead code from data.go. Also leave a TODO to be addressed later (with a unit test) to reduce the overhead of SymGrow. Change-Id: Iebad775b1280b54b89e87a3a073ca8af19a8bfba Reviewed-on: https://go-review.googlesource.com/14359 Run-TryBot: Dave Cheney <dave@cheney.net> Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
1 parent 5cbca8d commit fd50db2

File tree

1 file changed

+4
-118
lines changed

1 file changed

+4
-118
lines changed

src/cmd/internal/obj/data.go

Lines changed: 4 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ import (
3636
"math"
3737
)
3838

39-
func mangle(file string) {
40-
log.Fatalf("%s: mangled input file", file)
41-
}
42-
4339
func Symgrow(ctxt *Link, s *LSym, lsiz int64) {
4440
siz := int(lsiz)
4541
if int64(siz) != lsiz {
@@ -48,17 +44,19 @@ func Symgrow(ctxt *Link, s *LSym, lsiz int64) {
4844
if len(s.P) >= siz {
4945
return
5046
}
47+
// TODO(dfc) append cap-len at once, rather than
48+
// one byte at a time.
5149
for cap(s.P) < siz {
5250
s.P = append(s.P[:cap(s.P)], 0)
5351
}
5452
s.P = s.P[:siz]
5553
}
5654

57-
func savedata(ctxt *Link, s *LSym, p *Prog, pn string) {
55+
func savedata(ctxt *Link, s *LSym, p *Prog, file string) {
5856
off := int32(p.From.Offset)
5957
siz := int32(p.From3.Offset)
6058
if off < 0 || siz < 0 || off >= 1<<30 || siz >= 100 {
61-
mangle(pn)
59+
log.Fatalf("%s: mangled input file", file)
6260
}
6361
if ctxt.Enforce_data_order != 0 && off < int32(len(s.P)) {
6462
ctxt.Diag("data out of order (already have %d)\n%v", len(s.P), p)
@@ -142,115 +140,3 @@ func Setuintxx(ctxt *Link, s *LSym, off int64, v uint64, wid int64) int64 {
142140

143141
return off + wid
144142
}
145-
146-
func adduintxx(ctxt *Link, s *LSym, v uint64, wid int) int64 {
147-
off := s.Size
148-
Setuintxx(ctxt, s, off, v, int64(wid))
149-
return off
150-
}
151-
152-
func adduint8(ctxt *Link, s *LSym, v uint8) int64 {
153-
return adduintxx(ctxt, s, uint64(v), 1)
154-
}
155-
156-
func adduint16(ctxt *Link, s *LSym, v uint16) int64 {
157-
return adduintxx(ctxt, s, uint64(v), 2)
158-
}
159-
160-
func Adduint32(ctxt *Link, s *LSym, v uint32) int64 {
161-
return adduintxx(ctxt, s, uint64(v), 4)
162-
}
163-
164-
func Adduint64(ctxt *Link, s *LSym, v uint64) int64 {
165-
return adduintxx(ctxt, s, v, 8)
166-
}
167-
168-
func setuint8(ctxt *Link, s *LSym, r int64, v uint8) int64 {
169-
return Setuintxx(ctxt, s, r, uint64(v), 1)
170-
}
171-
172-
func setuint16(ctxt *Link, s *LSym, r int64, v uint16) int64 {
173-
return Setuintxx(ctxt, s, r, uint64(v), 2)
174-
}
175-
176-
func setuint32(ctxt *Link, s *LSym, r int64, v uint32) int64 {
177-
return Setuintxx(ctxt, s, r, uint64(v), 4)
178-
}
179-
180-
func setuint64(ctxt *Link, s *LSym, r int64, v uint64) int64 {
181-
return Setuintxx(ctxt, s, r, v, 8)
182-
}
183-
184-
func addaddrplus(ctxt *Link, s *LSym, t *LSym, add int64) int64 {
185-
if s.Type == 0 {
186-
s.Type = SDATA
187-
}
188-
i := s.Size
189-
s.Size += int64(ctxt.Arch.Ptrsize)
190-
Symgrow(ctxt, s, s.Size)
191-
r := Addrel(s)
192-
r.Sym = t
193-
r.Off = int32(i)
194-
r.Siz = uint8(ctxt.Arch.Ptrsize)
195-
r.Type = R_ADDR
196-
r.Add = add
197-
return i + int64(r.Siz)
198-
}
199-
200-
func addpcrelplus(ctxt *Link, s *LSym, t *LSym, add int64) int64 {
201-
if s.Type == 0 {
202-
s.Type = SDATA
203-
}
204-
i := s.Size
205-
s.Size += 4
206-
Symgrow(ctxt, s, s.Size)
207-
r := Addrel(s)
208-
r.Sym = t
209-
r.Off = int32(i)
210-
r.Add = add
211-
r.Type = R_PCREL
212-
r.Siz = 4
213-
return i + int64(r.Siz)
214-
}
215-
216-
func addaddr(ctxt *Link, s *LSym, t *LSym) int64 {
217-
return addaddrplus(ctxt, s, t, 0)
218-
}
219-
220-
func setaddrplus(ctxt *Link, s *LSym, off int64, t *LSym, add int64) int64 {
221-
if s.Type == 0 {
222-
s.Type = SDATA
223-
}
224-
if off+int64(ctxt.Arch.Ptrsize) > s.Size {
225-
s.Size = off + int64(ctxt.Arch.Ptrsize)
226-
Symgrow(ctxt, s, s.Size)
227-
}
228-
229-
r := Addrel(s)
230-
r.Sym = t
231-
r.Off = int32(off)
232-
r.Siz = uint8(ctxt.Arch.Ptrsize)
233-
r.Type = R_ADDR
234-
r.Add = add
235-
return off + int64(r.Siz)
236-
}
237-
238-
func setaddr(ctxt *Link, s *LSym, off int64, t *LSym) int64 {
239-
return setaddrplus(ctxt, s, off, t, 0)
240-
}
241-
242-
func addaddrplus4(ctxt *Link, s *LSym, t *LSym, add int64) int64 {
243-
if s.Type == 0 {
244-
s.Type = SDATA
245-
}
246-
i := s.Size
247-
s.Size += 4
248-
Symgrow(ctxt, s, s.Size)
249-
r := Addrel(s)
250-
r.Sym = t
251-
r.Off = int32(i)
252-
r.Siz = 4
253-
r.Type = R_ADDR
254-
r.Add = add
255-
return i + int64(r.Siz)
256-
}

0 commit comments

Comments
 (0)