1
0
mirror of https://github.com/golang/go synced 2024-11-27 04:21:24 -07:00

cmd/link: replace unrolled Cput loops with Cwrite/Cwritestring

Passes toolstash-check -all.

Change-Id: I1c85a2c0390517f4e9cdbddddbf3c353edca65b3
Reviewed-on: https://go-review.googlesource.com/64051
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2017-09-15 11:38:24 -07:00
parent 165c15afa3
commit f84a1db19f
8 changed files with 10 additions and 35 deletions

View File

@ -781,10 +781,7 @@ func asmb(ctxt *ld.Link) {
sym := ctxt.Syms.Lookup("pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { ld.Cwrite(sym.P)
ld.Cput(sym.P[i])
}
ld.Cflush() ld.Cflush()
} }

View File

@ -829,10 +829,7 @@ func asmb(ctxt *ld.Link) {
sym := ctxt.Syms.Lookup("pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { ld.Cwrite(sym.P)
ld.Cput(sym.P[i])
}
ld.Cflush() ld.Cflush()
} }

View File

@ -465,10 +465,7 @@ func asmb(ctxt *ld.Link) {
sym := ctxt.Syms.Lookup("pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { ld.Cwrite(sym.P)
ld.Cput(sym.P[i])
}
ld.Cflush() ld.Cflush()
} }

View File

@ -1120,9 +1120,7 @@ func getElfEhdr() *ElfEhdr {
} }
func elf64writehdr() uint32 { func elf64writehdr() uint32 {
for i := 0; i < EI_NIDENT; i++ { Cwrite(ehdr.ident[:])
Cput(ehdr.ident[i])
}
Thearch.Wput(ehdr.type_) Thearch.Wput(ehdr.type_)
Thearch.Wput(ehdr.machine) Thearch.Wput(ehdr.machine)
Thearch.Lput(ehdr.version) Thearch.Lput(ehdr.version)
@ -1140,9 +1138,7 @@ func elf64writehdr() uint32 {
} }
func elf32writehdr() uint32 { func elf32writehdr() uint32 {
for i := 0; i < EI_NIDENT; i++ { Cwrite(ehdr.ident[:])
Cput(ehdr.ident[i])
}
Thearch.Wput(ehdr.type_) Thearch.Wput(ehdr.type_)
Thearch.Wput(ehdr.machine) Thearch.Wput(ehdr.machine)
Thearch.Lput(ehdr.version) Thearch.Lput(ehdr.version)

View File

@ -233,13 +233,10 @@ func putplan9sym(ctxt *Link, x *Symbol, s string, typ SymbolType, addr int64, go
Lputb(uint32(addr)) Lputb(uint32(addr))
Cput(uint8(t + 0x80)) /* 0x80 is variable length */ Cput(uint8(t + 0x80)) /* 0x80 is variable length */
var i int Cwritestring(s)
for i = 0; i < len(s); i++ {
Cput(s[i])
}
Cput(0) Cput(0)
Symsize += int32(l) + 1 + int32(i) + 1 Symsize += int32(l) + 1 + int32(len(s)) + 1
default: default:
return return

View File

@ -258,10 +258,7 @@ func asmb(ctxt *ld.Link) {
sym := ctxt.Syms.Lookup("pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { ld.Cwrite(sym.P)
ld.Cput(sym.P[i])
}
ld.Cflush() ld.Cflush()
} }
} }

View File

@ -987,10 +987,7 @@ func asmb(ctxt *ld.Link) {
sym := ctxt.Syms.Lookup("pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { ld.Cwrite(sym.P)
ld.Cput(sym.P[i])
}
ld.Cflush() ld.Cflush()
} }
} }

View File

@ -709,10 +709,7 @@ func asmb(ctxt *ld.Link) {
sym := ctxt.Syms.Lookup("pclntab", 0) sym := ctxt.Syms.Lookup("pclntab", 0)
if sym != nil { if sym != nil {
ld.Lcsize = int32(len(sym.P)) ld.Lcsize = int32(len(sym.P))
for i := 0; int32(i) < ld.Lcsize; i++ { ld.Cwrite(sym.P)
ld.Cput(sym.P[i])
}
ld.Cflush() ld.Cflush()
} }