Skip to content

Commit 69a143e

Browse files
committed
cmd/internal/obj: remove dead code and small cleanups
Change-Id: I88fa0cc245a2141af04acced8716e08b1133abd1 Reviewed-on: https://go-review.googlesource.com/14350 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 74a123f commit 69a143e

File tree

14 files changed

+22
-123
lines changed

14 files changed

+22
-123
lines changed

src/cmd/compile/internal/gc/lex.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ func Main() {
319319
dclcontext = PEXTERN
320320
nerrors = 0
321321
lexlineno = 1
322+
const BOM = 0xFEFF
322323

323324
for _, infile = range flag.Args() {
324325
linehistpush(infile)
@@ -338,7 +339,7 @@ func Main() {
338339
curio.last = 0
339340

340341
// Skip initial BOM if present.
341-
if obj.Bgetrune(curio.bin) != obj.BOM {
342+
if obj.Bgetrune(curio.bin) != BOM {
342343
obj.Bungetrune(curio.bin)
343344
}
344345

@@ -601,11 +602,11 @@ func findpkg(name string) (file string, ok bool) {
601602
// if there is an array.6 in the array.a library,
602603
// want to find all of array.a, not just array.6.
603604
file = fmt.Sprintf("%s.a", name)
604-
if obj.Access(file, 0) >= 0 {
605+
if _, err := os.Stat(file); err == nil {
605606
return file, true
606607
}
607608
file = fmt.Sprintf("%s.o", name)
608-
if obj.Access(file, 0) >= 0 {
609+
if _, err := os.Stat(file); err == nil {
609610
return file, true
610611
}
611612
return "", false
@@ -623,11 +624,11 @@ func findpkg(name string) (file string, ok bool) {
623624

624625
for p := idirs; p != nil; p = p.link {
625626
file = fmt.Sprintf("%s/%s.a", p.dir, name)
626-
if obj.Access(file, 0) >= 0 {
627+
if _, err := os.Stat(file); err == nil {
627628
return file, true
628629
}
629630
file = fmt.Sprintf("%s/%s.o", p.dir, name)
630-
if obj.Access(file, 0) >= 0 {
631+
if _, err := os.Stat(file); err == nil {
631632
return file, true
632633
}
633634
}
@@ -644,11 +645,11 @@ func findpkg(name string) (file string, ok bool) {
644645
}
645646

646647
file = fmt.Sprintf("%s/pkg/%s_%s%s%s/%s.a", goroot, goos, goarch, suffixsep, suffix, name)
647-
if obj.Access(file, 0) >= 0 {
648+
if _, err := os.Stat(file); err == nil {
648649
return file, true
649650
}
650651
file = fmt.Sprintf("%s/pkg/%s_%s%s%s/%s.o", goroot, goos, goarch, suffixsep, suffix, name)
651-
if obj.Access(file, 0) >= 0 {
652+
if _, err := os.Stat(file); err == nil {
652653
return file, true
653654
}
654655
}

src/cmd/internal/obj/arm64/asm7.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ func OPBIT(x uint32) uint32 {
147147
const (
148148
LFROM = 1 << 0
149149
LTO = 1 << 1
150-
LPOOL = 1 << 2
151150
)
152151

153152
var optab = []Optab{

src/cmd/internal/obj/data.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,6 @@ func setaddr(ctxt *Link, s *LSym, off int64, t *LSym) int64 {
239239
return setaddrplus(ctxt, s, off, t, 0)
240240
}
241241

242-
func addsize(ctxt *Link, s *LSym, t *LSym) int64 {
243-
if s.Type == 0 {
244-
s.Type = SDATA
245-
}
246-
i := s.Size
247-
s.Size += int64(ctxt.Arch.Ptrsize)
248-
Symgrow(ctxt, s, s.Size)
249-
r := Addrel(s)
250-
r.Sym = t
251-
r.Off = int32(i)
252-
r.Siz = uint8(ctxt.Arch.Ptrsize)
253-
r.Type = R_SIZE
254-
return i + int64(r.Siz)
255-
}
256-
257242
func addaddrplus4(ctxt *Link, s *LSym, t *LSym, add int64) int64 {
258243
if s.Type == 0 {
259244
s.Type = SDATA

src/cmd/internal/obj/fmt.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,11 @@ package obj
1717
const (
1818
FmtWidth = 1 << iota
1919
FmtLeft
20-
FmtPrec
2120
FmtSharp
22-
FmtSpace
2321
FmtSign
24-
FmtApost
25-
FmtZero
2622
FmtUnsigned
2723
FmtShort
2824
FmtLong
29-
FmtVLong
3025
FmtComma
3126
FmtByte
32-
FmtLDouble
33-
FmtFlag
3427
)

src/cmd/internal/obj/funcdata.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,5 @@ const (
7474
PCDATA_StackMapIndex = 0
7575
FUNCDATA_ArgsPointerMaps = 0
7676
FUNCDATA_LocalsPointerMaps = 1
77-
FUNCDATA_DeadValueMaps = 2
7877
ArgsSizeUnknown = -0x80000000
7978
)

src/cmd/internal/obj/libc.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/cmd/internal/obj/mgc0.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/cmd/internal/obj/objfile.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ import (
107107
"strings"
108108
)
109109

110-
var outfile string
111-
112110
// The Go and C compilers, and the assembler, call writeobj to write
113111
// out a Go object file. The linker does not call this; the linker
114112
// does not write out object files.

src/cmd/internal/obj/sym.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,7 @@ func Linknew(arch *LinkArch) *Link {
107107

108108
// On arm, record goarm.
109109
if ctxt.Arch.Thechar == '5' {
110-
p := Getgoarm()
111-
if p != "" {
112-
ctxt.Goarm = int32(Atoi(p))
113-
} else {
114-
ctxt.Goarm = 6
115-
}
110+
ctxt.Goarm = Getgoarm()
116111
}
117112

118113
return ctxt

src/cmd/internal/obj/util.go

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"io"
1212
"log"
1313
"os"
14-
"strconv"
1514
"strings"
1615
"time"
1716
)
@@ -166,17 +165,6 @@ func Brdstr(b *Biobuf, delim int, cut int) string {
166165
return s
167166
}
168167

169-
func Access(name string, mode int) int {
170-
if mode != 0 {
171-
panic("bad access")
172-
}
173-
_, err := os.Stat(name)
174-
if err != nil {
175-
return -1
176-
}
177-
return 0
178-
}
179-
180168
func Blinelen(b *Biobuf) int {
181169
return b.linelen
182170
}
@@ -212,10 +200,14 @@ func Getgoos() string {
212200
return envOr("GOOS", defaultGOOS)
213201
}
214202

215-
func Getgoarm() string {
203+
func Getgoarm() int32 {
216204
switch v := envOr("GOARM", defaultGOARM); v {
217-
case "5", "6", "7":
218-
return v
205+
case "5":
206+
return 5
207+
case "6":
208+
return 6
209+
case "7":
210+
return 7
219211
}
220212
// Fail here, rather than validate at multiple call sites.
221213
log.Fatalf("Invalid GOARM value. Must be 5, 6, or 7.")
@@ -235,11 +227,6 @@ func Getgoversion() string {
235227
return version
236228
}
237229

238-
func Atoi(s string) int {
239-
i, _ := strconv.Atoi(s)
240-
return i
241-
}
242-
243230
func (p *Prog) Line() string {
244231
return p.Ctxt.LineHist.LineString(int(p.Lineno))
245232
}

src/cmd/internal/obj/x86/asm6.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ import (
4040
// Instruction layout.
4141

4242
const (
43-
MaxAlign = 32 // max data alignment
44-
4543
// Loop alignment constants:
4644
// want to align loop entry to LoopAlign-byte boundary,
4745
// and willing to insert at most MaxLoopPad bytes of NOP to do so.
@@ -175,7 +173,6 @@ const (
175173
Zil_rp
176174
Ziq_rp
177175
Zilo_m
178-
Ziqo_m
179176
Zjmp
180177
Zjmpcon
181178
Zloop
@@ -225,14 +222,10 @@ const (
225222
Py1 = 0x81 // symbolic; exact value doesn't matter
226223
Py3 = 0x83 // symbolic; exact value doesn't matter
227224

228-
Rxf = 1 << 9 /* internal flag for Rxr on from */
229-
Rxt = 1 << 8 /* internal flag for Rxr on to */
230225
Rxw = 1 << 3 /* =1, 64-bit operand size */
231226
Rxr = 1 << 2 /* extend modrm reg */
232227
Rxx = 1 << 1 /* extend sib index */
233228
Rxb = 1 << 0 /* extend modrm r/m, sib base, or opcode reg */
234-
235-
Maxand = 10 /* in -a output width of the byte codes */
236229
)
237230

238231
var ycover [Ymax * Ymax]uint8
@@ -245,11 +238,6 @@ var ynone = []ytab{
245238
{Ynone, Ynone, Ynone, Zlit, 1},
246239
}
247240

248-
var ysahf = []ytab{
249-
{Ynone, Ynone, Ynone, Zlit, 2},
250-
{Ynone, Ynone, Ynone, Zlit, 1},
251-
}
252-
253241
var ytext = []ytab{
254242
{Ymb, Ynone, Ytextsize, Zpseudo, 0},
255243
{Ymb, Yi32, Ytextsize, Zpseudo, 1},

src/cmd/link/internal/ld/ldpe.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"fmt"
1111
"log"
1212
"sort"
13+
"strconv"
1314
"strings"
1415
)
1516

@@ -191,8 +192,8 @@ func ldpe(f *obj.Biobuf, pkg string, length int64, pn string) {
191192
if peobj.sect[i].name[0] != '/' {
192193
continue
193194
}
194-
l = uint32(obj.Atoi(peobj.sect[i].name[1:]))
195-
peobj.sect[i].name = cstring(peobj.snames[l:])
195+
n, _ := strconv.Atoi(peobj.sect[i].name[1:])
196+
peobj.sect[i].name = cstring(peobj.snames[n:])
196197
}
197198

198199
// read symbols

src/cmd/link/internal/ld/lib.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ func loadinternal(name string) {
421421
if Debug['v'] != 0 {
422422
fmt.Fprintf(&Bso, "searching for %s.a in %s\n", name, shlibname)
423423
}
424-
if obj.Access(shlibname, obj.AEXIST) >= 0 {
424+
if _, err := os.Stat(shlibname); err == nil {
425425
addlibpath(Ctxt, "internal", "internal", "", name, shlibname)
426426
found = 1
427427
break
@@ -431,7 +431,7 @@ func loadinternal(name string) {
431431
if Debug['v'] != 0 {
432432
fmt.Fprintf(&Bso, "searching for %s.a in %s\n", name, pname)
433433
}
434-
if obj.Access(pname, obj.AEXIST) >= 0 {
434+
if _, err := os.Stat(pname); err == nil {
435435
addlibpath(Ctxt, "internal", "internal", pname, name, "")
436436
found = 1
437437
break

src/cmd/link/internal/ld/sym.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,7 @@ func linknew(arch *LinkArch) *Link {
144144

145145
// On arm, record goarm.
146146
if ctxt.Arch.Thechar == '5' {
147-
p := obj.Getgoarm()
148-
if p != "" {
149-
ctxt.Goarm = int32(obj.Atoi(p))
150-
} else {
151-
ctxt.Goarm = 6
152-
}
147+
ctxt.Goarm = obj.Getgoarm()
153148
}
154149

155150
return ctxt

0 commit comments

Comments
 (0)