Commit f84a1db1 authored by Matthew Dempsky's avatar Matthew Dempsky

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 165c15af
...@@ -781,10 +781,7 @@ func asmb(ctxt *ld.Link) { ...@@ -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()
} }
......
...@@ -829,10 +829,7 @@ func asmb(ctxt *ld.Link) { ...@@ -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()
} }
......
...@@ -465,10 +465,7 @@ func asmb(ctxt *ld.Link) { ...@@ -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()
} }
......
...@@ -1120,9 +1120,7 @@ func getElfEhdr() *ElfEhdr { ...@@ -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 { ...@@ -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)
......
...@@ -233,13 +233,10 @@ func putplan9sym(ctxt *Link, x *Symbol, s string, typ SymbolType, addr int64, go ...@@ -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
......
...@@ -258,10 +258,7 @@ func asmb(ctxt *ld.Link) { ...@@ -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()
} }
} }
......
...@@ -987,10 +987,7 @@ func asmb(ctxt *ld.Link) { ...@@ -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()
} }
} }
......
...@@ -709,10 +709,7 @@ func asmb(ctxt *ld.Link) { ...@@ -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()
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment