var out [6 + 3]uint32
for {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f span1\n", obj.Cputime())
+ ctxt.Logf("%5.2f span1\n", obj.Cputime())
}
bflag = 0
c = 0
if autosize == 0 && cursym.Text.Mark&LEAF == 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "save suppressed in: %s\n", cursym.Name)
- ctxt.Bso.Flush()
+ ctxt.Logf("save suppressed in: %s\n", cursym.Name)
}
cursym.Text.Mark |= LEAF
*/
for bflag != 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f span1\n", obj.Cputime())
+ ctxt.Logf("%5.2f span1\n", obj.Cputime())
}
bflag = 0
c = 0
var o1 int32
if p.Pcond == nil { /* not in literal pool */
aclass(ctxt, a)
- fmt.Fprintf(ctxt.Bso, "omovlit add %d (%#x)\n", ctxt.Instoffset, uint64(ctxt.Instoffset))
+ ctxt.Logf("omovlit add %d (%#x)\n", ctxt.Instoffset, uint64(ctxt.Instoffset))
/* TODO: could be clever, and use general constant builder */
o1 = int32(opirr(ctxt, AADD))
* strip NOPs
* expand RET
*/
- ctxt.Bso.Flush()
q := (*obj.Prog)(nil)
var q1 *obj.Prog
for p := cursym.Text; p != nil; p = p.Link {
p.To.Offset = int64(ctxt.Autosize) - 8
if ctxt.Autosize == 0 && !(cursym.Text.Mark&LEAF != 0) {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "save suppressed in: %s\n", cursym.Text.From.Sym.Name)
- ctxt.Bso.Flush()
+ ctxt.Logf("save suppressed in: %s\n", cursym.Text.From.Sym.Name)
}
cursym.Text.Mark |= LEAF
}
import (
"bufio"
"cmd/internal/sys"
+ "fmt"
)
// An Addr is an argument to an instruction.
ctxt.DiagFunc(format, args...)
}
+func (ctxt *Link) Logf(format string, args ...interface{}) {
+ fmt.Fprintf(ctxt.Bso, format, args...)
+ ctxt.Bso.Flush()
+}
+
// The smallest possible offset from the hardware stack pointer to a local
// variable on the stack. Architectures that use a link register save its value
// on the stack in the function prologue and so always have a pointer between
var q *obj.Prog
for bflag != 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f span1\n", obj.Cputime())
+ ctxt.Logf("%5.2f span1\n", obj.Cputime())
}
bflag = 0
c = 0
* expand BECOME pseudo
*/
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f noops\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f noops\n", obj.Cputime())
}
var q *obj.Prog
} else if cursym.Text.Mark&LEAF == 0 {
if cursym.Text.From3.Offset&obj.NOSPLIT != 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "save suppressed in: %s\n", cursym.Name)
- ctxt.Bso.Flush()
+ ctxt.Logf("save suppressed in: %s\n", cursym.Name)
}
cursym.Text.Mark |= LEAF
package obj
-import (
- "fmt"
- "log"
-)
+import "log"
func addvarint(ctxt *Link, d *Pcdata, val uint32) {
var v uint32
dst.P = dst.P[:0]
if ctxt.Debugpcln != 0 {
- fmt.Fprintf(ctxt.Bso, "funcpctab %s [valfunc=%s]\n", func_.Name, desc)
+ ctxt.Logf("funcpctab %s [valfunc=%s]\n", func_.Name, desc)
}
val := int32(-1)
pc := func_.Text.Pc
if ctxt.Debugpcln != 0 {
- fmt.Fprintf(ctxt.Bso, "%6x %6d %v\n", uint64(pc), val, func_.Text)
+ ctxt.Logf("%6x %6d %v\n", uint64(pc), val, func_.Text)
}
started := int32(0)
if val == oldval && started != 0 {
val = valfunc(ctxt, func_, val, p, 1, arg)
if ctxt.Debugpcln != 0 {
- fmt.Fprintf(ctxt.Bso, "%6x %6s %v\n", uint64(p.Pc), "", p)
+ ctxt.Logf("%6x %6s %v\n", uint64(p.Pc), "", p)
}
continue
}
if p.Link != nil && p.Link.Pc == p.Pc {
val = valfunc(ctxt, func_, val, p, 1, arg)
if ctxt.Debugpcln != 0 {
- fmt.Fprintf(ctxt.Bso, "%6x %6s %v\n", uint64(p.Pc), "", p)
+ ctxt.Logf("%6x %6s %v\n", uint64(p.Pc), "", p)
}
continue
}
// where the 0x80 bit indicates that the integer continues.
if ctxt.Debugpcln != 0 {
- fmt.Fprintf(ctxt.Bso, "%6x %6d %v\n", uint64(p.Pc), val, p)
+ ctxt.Logf("%6x %6d %v\n", uint64(p.Pc), val, p)
}
if started != 0 {
if started != 0 {
if ctxt.Debugpcln != 0 {
- fmt.Fprintf(ctxt.Bso, "%6x done\n", uint64(func_.Text.Pc+func_.Size))
+ ctxt.Logf("%6x done\n", uint64(func_.Text.Pc+func_.Size))
}
addvarint(ctxt, dst, uint32((func_.Size-pc)/int64(ctxt.Arch.MinLC)))
addvarint(ctxt, dst, 0) // terminator
}
if ctxt.Debugpcln != 0 {
- fmt.Fprintf(ctxt.Bso, "wrote %d bytes to %p\n", len(dst.P), dst)
+ ctxt.Logf("wrote %d bytes to %p\n", len(dst.P), dst)
for i := 0; i < len(dst.P); i++ {
- fmt.Fprintf(ctxt.Bso, " %02x", dst.P[i])
+ ctxt.Logf(" %02x", dst.P[i])
}
- fmt.Fprintf(ctxt.Bso, "\n")
+ ctxt.Logf("\n")
}
ctxt.Debugpcln -= int32(dbg)
var q *obj.Prog
for bflag != 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f span1\n", obj.Cputime())
+ ctxt.Logf("%5.2f span1\n", obj.Cputime())
}
bflag = 0
c = 0
* expand BECOME pseudo
*/
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f noops\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f noops\n", obj.Cputime())
}
var q *obj.Prog
* expand BECOME pseudo
*/
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f noops\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f noops\n", obj.Cputime())
}
var q *obj.Prog
"cmd/internal/obj"
"cmd/link/internal/ld"
"debug/elf"
- "fmt"
"log"
)
func asmb(ctxt *ld.Link) {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f asmb\n", obj.Cputime())
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f codeblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f codeblk\n", obj.Cputime())
}
if ld.Iself {
if ld.Segrodata.Filelen > 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f rodatblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segrodata.Fileoff))
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f datblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segdata.Fileoff))
symo := int64(0)
if !*ld.FlagS {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f sym\n", obj.Cputime())
}
switch ld.HEADTYPE {
default:
ld.Cwrite(ld.Elfstrdat)
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
+ ctxt.Logf("%5.2f dwarf\n", obj.Cputime())
}
if ld.Linkmode == ld.LinkExternal {
case obj.Hwindows:
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
+ ctxt.Logf("%5.2f dwarf\n", obj.Cputime())
}
case obj.Hdarwin:
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f headr\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f headr\n", obj.Cputime())
}
ld.Cseek(0)
switch ld.HEADTYPE {
func asmb(ctxt *ld.Link) {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f asmb\n", obj.Cputime())
}
if ld.Iself {
if ld.Segrodata.Filelen > 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f rodatblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segrodata.Fileoff))
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f datblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segdata.Fileoff))
if !*ld.FlagS {
// TODO: rationalize
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f sym\n", obj.Cputime())
}
switch ld.HEADTYPE {
default:
default:
if ld.Iself {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
+ ctxt.Logf("%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
ld.Cflush()
ctxt.Cursym = nil
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f header\n", obj.Cputime())
}
ld.Cseek(0)
switch ld.HEADTYPE {
func asmb(ctxt *ld.Link) {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f asmb\n", obj.Cputime())
}
if ld.Iself {
if ld.Segrodata.Filelen > 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f rodatblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segrodata.Fileoff))
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f datblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segdata.Fileoff))
if !*ld.FlagS {
// TODO: rationalize
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f sym\n", obj.Cputime())
}
switch ld.HEADTYPE {
default:
default:
if ld.Iself {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
+ ctxt.Logf("%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
ld.Cflush()
ctxt.Cursym = nil
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f header\n", obj.Cputime())
}
ld.Cseek(0)
switch ld.HEADTYPE {
if os.IsNotExist(err) {
// It's OK if we don't have a libgcc file at all.
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "skipping libgcc file: %v\n", err)
+ ctxt.Logf("skipping libgcc file: %v\n", err)
}
return
}
func (ctxt *Link) reloc() {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f reloc\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f reloc\n", obj.Cputime())
}
for _, s := range ctxt.Textp {
return
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f reloc\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f reloc\n", obj.Cputime())
}
for _, s := range ctxt.Textp {
}
func CodeblkPad(ctxt *Link, addr int64, size int64, pad []byte) {
if *flagA {
- fmt.Fprintf(ctxt.Bso, "codeblk [%#x,%#x) at offset %#x\n", addr, addr+size, coutbuf.Offset())
+ ctxt.Logf("codeblk [%#x,%#x) at offset %#x\n", addr, addr+size, coutbuf.Offset())
}
blk(ctxt, ctxt.Textp, addr, size, pad)
}
if addr < sym.Value {
- fmt.Fprintf(ctxt.Bso, "%-20s %.8x|", "_", uint64(addr))
+ ctxt.Logf("%-20s %.8x|", "_", uint64(addr))
for ; addr < sym.Value; addr++ {
- fmt.Fprintf(ctxt.Bso, " %.2x", 0)
+ ctxt.Logf(" %.2x", 0)
}
- fmt.Fprintf(ctxt.Bso, "\n")
+ ctxt.Logf("\n")
}
- fmt.Fprintf(ctxt.Bso, "%.6x\t%-20s\n", uint64(addr), sym.Name)
+ ctxt.Logf("%.6x\t%-20s\n", uint64(addr), sym.Name)
q = sym.P
for len(q) >= 16 {
- fmt.Fprintf(ctxt.Bso, "%.6x\t% x\n", uint64(addr), q[:16])
+ ctxt.Logf("%.6x\t% x\n", uint64(addr), q[:16])
addr += 16
q = q[16:]
}
if len(q) > 0 {
- fmt.Fprintf(ctxt.Bso, "%.6x\t% x\n", uint64(addr), q)
+ ctxt.Logf("%.6x\t% x\n", uint64(addr), q)
addr += int64(len(q))
}
}
if addr < eaddr {
- fmt.Fprintf(ctxt.Bso, "%-20s %.8x|", "_", uint64(addr))
+ ctxt.Logf("%-20s %.8x|", "_", uint64(addr))
for ; addr < eaddr; addr++ {
- fmt.Fprintf(ctxt.Bso, " %.2x", 0)
+ ctxt.Logf(" %.2x", 0)
}
- ctxt.Bso.Flush()
}
}
func Datblk(ctxt *Link, addr int64, size int64) {
if *flagA {
- fmt.Fprintf(ctxt.Bso, "datblk [%#x,%#x) at offset %#x\n", addr, addr+size, coutbuf.Offset())
+ ctxt.Logf("datblk [%#x,%#x) at offset %#x\n", addr, addr+size, coutbuf.Offset())
}
blk(ctxt, datap, addr, size, zeros[:])
break
}
if addr < sym.Value {
- fmt.Fprintf(ctxt.Bso, "\t%.8x| 00 ...\n", uint64(addr))
+ ctxt.Logf("\t%.8x| 00 ...\n", uint64(addr))
addr = sym.Value
}
- fmt.Fprintf(ctxt.Bso, "%s\n\t%.8x|", sym.Name, uint64(addr))
+ ctxt.Logf("%s\n\t%.8x|", sym.Name, uint64(addr))
for i, b := range sym.P {
if i > 0 && i%16 == 0 {
- fmt.Fprintf(ctxt.Bso, "\n\t%.8x|", uint64(addr)+uint64(i))
+ ctxt.Logf("\n\t%.8x|", uint64(addr)+uint64(i))
}
- fmt.Fprintf(ctxt.Bso, " %.2x", b)
+ ctxt.Logf(" %.2x", b)
}
addr += int64(len(sym.P))
for ; addr < sym.Value+sym.Size; addr++ {
- fmt.Fprintf(ctxt.Bso, " %.2x", 0)
+ ctxt.Logf(" %.2x", 0)
}
- fmt.Fprintf(ctxt.Bso, "\n")
+ ctxt.Logf("\n")
if Linkmode != LinkExternal {
continue
case obj.R_CALL:
typ = "call"
}
- fmt.Fprintf(ctxt.Bso, "\treloc %.8x/%d %s %s+%#x [%#x]\n", uint(sym.Value+int64(r.Off)), r.Siz, typ, rsname, r.Add, r.Sym.Value+r.Add)
+ ctxt.Logf("\treloc %.8x/%d %s %s+%#x [%#x]\n", uint(sym.Value+int64(r.Off)), r.Siz, typ, rsname, r.Add, r.Sym.Value+r.Add)
}
}
if addr < eaddr {
- fmt.Fprintf(ctxt.Bso, "\t%.8x| 00 ...\n", uint(addr))
+ ctxt.Logf("\t%.8x| 00 ...\n", uint(addr))
}
- fmt.Fprintf(ctxt.Bso, "\t%.8x|\n", uint(eaddr))
+ ctxt.Logf("\t%.8x|\n", uint(eaddr))
}
func Dwarfblk(ctxt *Link, addr int64, size int64) {
if *flagA {
- fmt.Fprintf(ctxt.Bso, "dwarfblk [%#x,%#x) at offset %#x\n", addr, addr+size, coutbuf.Offset())
+ ctxt.Logf("dwarfblk [%#x,%#x) at offset %#x\n", addr, addr+size, coutbuf.Offset())
}
blk(ctxt, dwarfp, addr, size, zeros[:])
func (ctxt *Link) dodata() {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f dodata\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f dodata\n", obj.Cputime())
}
// Collect data symbols by type into data.
// Any unreached text symbols are removed from ctxt.Textp.
func deadcode(ctxt *Link) {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f deadcode\n", obj.Cputime())
+ ctxt.Logf("%5.2f deadcode\n", obj.Cputime())
}
d := &deadcodepass{
r.Type = obj.R_ADDROFF
} else {
if d.ctxt.Debugvlog > 1 {
- fmt.Fprintf(d.ctxt.Bso, "removing method %s\n", r.Sym.Name)
+ d.ctxt.Logf("removing method %s\n", r.Sym.Name)
}
r.Sym = nil
r.Siz = 0
d.markQueue = d.markQueue[1:]
if s.Type == obj.STEXT {
if d.ctxt.Debugvlog > 1 {
- fmt.Fprintf(d.ctxt.Bso, "marktext %s\n", s.Name)
+ d.ctxt.Logf("marktext %s\n", s.Name)
}
if s.FuncInfo != nil {
for _, a := range s.FuncInfo.Autom {
if decodetypeKind(s)&kindMask == kindInterface {
for _, sig := range decodeIfaceMethods(d.ctxt.Arch, s) {
if d.ctxt.Debugvlog > 1 {
- fmt.Fprintf(d.ctxt.Bso, "reached iface method: %s\n", sig)
+ d.ctxt.Logf("reached iface method: %s\n", sig)
}
d.ifaceMethod[sig] = true
}
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
+ ctxt.Logf("%5.2f dwarf\n", obj.Cputime())
}
// Forctxt.Diagnostic messages.
import (
"cmd/internal/obj"
- "fmt"
"io/ioutil"
"os"
"path"
pname = path.Clean(pname)
- if ctxt.Debugvlog > 1 && ctxt.Bso != nil {
- fmt.Fprintf(ctxt.Bso, "%5.2f addlib: %s %s pulls in %s isshlib %v\n", elapsed(), obj, src, pname, isshlib)
+ if ctxt.Debugvlog > 1 {
+ ctxt.Logf("%5.2f addlib: %s %s pulls in %s isshlib %v\n", elapsed(), obj, src, pname, isshlib)
}
if isshlib {
}
}
- if ctxt.Debugvlog > 1 && ctxt.Bso != nil {
- fmt.Fprintf(ctxt.Bso, "%5.2f addlibpath: srcref: %s objref: %s file: %s pkg: %s shlibnamefile: %s\n", obj.Cputime(), srcref, objref, file, pkg, shlibnamefile)
+ if ctxt.Debugvlog > 1 {
+ ctxt.Logf("%5.2f addlibpath: srcref: %s objref: %s file: %s pkg: %s shlibnamefile: %s\n", obj.Cputime(), srcref, objref, file, pkg, shlibnamefile)
}
ctxt.Library = append(ctxt.Library, &Library{})
ehdr.flags = 0x5000202
}
if data[0] != 'A' {
- fmt.Fprintf(ctxt.Bso, ".ARM.attributes has unexpected format %c\n", data[0])
+ // TODO(dfc) should this be ctxt.Diag ?
+ ctxt.Logf(".ARM.attributes has unexpected format %c\n", data[0])
return
}
data = data[1:]
nulIndex := bytes.IndexByte(sectiondata, 0)
if nulIndex < 0 {
- fmt.Fprintf(ctxt.Bso, "corrupt .ARM.attributes (section name not NUL-terminated)\n")
+ // TODO(dfc) should this be ctxt.Diag ?
+ ctxt.Logf("corrupt .ARM.attributes (section name not NUL-terminated)\n")
return
}
name := string(sectiondata[:nulIndex])
}
}
if attrList.err != nil {
- fmt.Fprintf(ctxt.Bso, "could not parse .ARM.attributes\n")
+ // TODO(dfc) should this be ctxt.Diag ?
+ ctxt.Logf("could not parse .ARM.attributes\n")
}
}
}
func ldelf(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f ldelf %s\n", obj.Cputime(), pn)
+ ctxt.Logf("%5.2f ldelf %s\n", obj.Cputime(), pn)
}
ctxt.IncVersion()
func ldpe(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f ldpe %s\n", obj.Cputime(), pn)
+ ctxt.Logf("%5.2f ldpe %s\n", obj.Cputime(), pn)
}
var sect *PeSect
if *FlagLinkshared {
shlibname := filepath.Join(ctxt.Libdir[i], name+".shlibname")
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "searching for %s.a in %s\n", name, shlibname)
+ ctxt.Logf("searching for %s.a in %s\n", name, shlibname)
}
if _, err := os.Stat(shlibname); err == nil {
addlibpath(ctxt, "internal", "internal", "", name, shlibname)
}
pname := filepath.Join(ctxt.Libdir[i], name+".a")
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "searching for %s.a in %s\n", name, pname)
+ ctxt.Logf("searching for %s.a in %s\n", name, pname)
}
if _, err := os.Stat(pname); err == nil {
addlibpath(ctxt, "internal", "internal", pname, name, "")
}
if found == 0 {
- fmt.Fprintf(ctxt.Bso, "warning: unable to find %s.a\n", name)
+ ctxt.Logf("warning: unable to find %s.a\n", name)
}
}
iscgo = iscgo || ctxt.Library[i].Pkg == "runtime/cgo"
if ctxt.Library[i].Shlib == "" {
if ctxt.Debugvlog > 1 {
- fmt.Fprintf(ctxt.Bso, "%5.2f autolib: %s (from %s)\n", obj.Cputime(), ctxt.Library[i].File, ctxt.Library[i].Objref)
+ ctxt.Logf("%5.2f autolib: %s (from %s)\n", obj.Cputime(), ctxt.Library[i].File, ctxt.Library[i].Objref)
}
objfile(ctxt, ctxt.Library[i])
}
for i = 0; i < len(ctxt.Library); i++ {
if ctxt.Library[i].Shlib != "" {
if ctxt.Debugvlog > 1 {
- fmt.Fprintf(ctxt.Bso, "%5.2f autolib: %s (from %s)\n", obj.Cputime(), ctxt.Library[i].Shlib, ctxt.Library[i].Objref)
+ ctxt.Logf("%5.2f autolib: %s (from %s)\n", obj.Cputime(), ctxt.Library[i].Shlib, ctxt.Library[i].Objref)
}
ldshlibsyms(ctxt, ctxt.Library[i].Shlib)
}
args := hostlinkArchArgs()
args = append(args, "--print-libgcc-file-name")
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%s %v\n", *flagExtld, args)
+ ctxt.Logf("%s %v\n", *flagExtld, args)
}
out, err := exec.Command(*flagExtld, args...).Output()
if err != nil {
if ctxt.Debugvlog != 0 {
- fmt.Fprintln(ctxt.Bso, "not using a libgcc file because compiler failed")
- fmt.Fprintf(ctxt.Bso, "%v\n%s\n", err, out)
+ ctxt.Logf("not using a libgcc file because compiler failed\n%v\n%s\n", err, out)
}
*flagLibGCC = "none"
} else {
pkg := pathtoprefix(lib.Pkg)
if ctxt.Debugvlog > 1 {
- fmt.Fprintf(ctxt.Bso, "%5.2f ldobj: %s (%s)\n", obj.Cputime(), lib.File, pkg)
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f ldobj: %s (%s)\n", obj.Cputime(), lib.File, pkg)
}
f, err := bio.Open(lib.File)
if err != nil {
argv = append(argv, hostobjCopy()...)
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "archive: %s\n", strings.Join(argv, " "))
- ctxt.Bso.Flush()
+ ctxt.Logf("archive: %s\n", strings.Join(argv, " "))
}
if out, err := exec.Command(argv[0], argv[1:]...).CombinedOutput(); err != nil {
}
if l.Debugvlog != 0 {
- fmt.Fprintf(l.Bso, "host link:")
+ l.Logf("host link:")
for _, v := range argv {
- fmt.Fprintf(l.Bso, " %q", v)
+ l.Logf(" %q", v)
}
- fmt.Fprintf(l.Bso, "\n")
- l.Bso.Flush()
+ l.Logf("\n")
}
if out, err := exec.Command(argv[0], argv[1:]...).CombinedOutput(); err != nil {
Exitf("running %s failed: %v\n%s", argv[0], err, out)
} else if l.Debugvlog != 0 && len(out) > 0 {
- fmt.Fprintf(l.Bso, "%s", out)
- l.Bso.Flush()
+ l.Logf("%s", out)
}
if !*FlagS && !debug_s && HEADTYPE == obj.Hdarwin {
return
}
}
- if ctxt.Debugvlog > 1 && ctxt.Bso != nil {
- fmt.Fprintf(ctxt.Bso, "%5.2f ldshlibsyms: found library with name %s at %s\n", obj.Cputime(), shlib, libpath)
- ctxt.Bso.Flush()
+ if ctxt.Debugvlog > 1 {
+ ctxt.Logf("%5.2f ldshlibsyms: found library with name %s at %s\n", obj.Cputime(), shlib, libpath)
}
f, err := elf.Open(libpath)
// Otherwise, off is addressing the saved program counter.
// Something underhanded is going on. Say nothing.
if ctxt.Debugvlog != 0 || *flagN {
- fmt.Fprintf(ctxt.Bso, "%5.2f symsize = %d\n", obj.Cputime(), uint32(Symsize))
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f symsize = %d\n", obj.Cputime(), uint32(Symsize))
}
}
continue
}
if (r.Type == obj.R_CALL || r.Type == obj.R_CALLARM || r.Type == obj.R_CALLPOWER || r.Type == obj.R_CALLMIPS) && r.Sym.Type == obj.STEXT {
- fmt.Fprintf(ctxt.Bso, "%s calls %s\n", s.Name, r.Sym.Name)
+ ctxt.Logf("%s calls %s\n", s.Name, r.Sym.Name)
}
}
}
l.Hash = append(l.Hash, make(map[string]*Symbol))
}
+func (l *Link) Logf(format string, args ...interface{}) {
+ fmt.Fprintf(l.Bso, format, args...)
+ l.Bso.Flush()
+}
+
type Library struct {
Objref string
Srcref string
obj.Flagparse(usage)
startProfile()
- ctxt.Bso = ctxt.Bso
if flagShared {
if Buildmode == BuildmodeUnset {
Buildmode = BuildmodeCShared
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "HEADER = -H%d -T0x%x -D0x%x -R0x%x\n", HEADTYPE, uint64(*FlagTextAddr), uint64(*FlagDataAddr), uint32(*FlagRound))
- ctxt.Bso.Flush()
+ ctxt.Logf("HEADER = -H%d -T0x%x -D0x%x -R0x%x\n", HEADTYPE, uint64(*FlagTextAddr), uint64(*FlagDataAddr), uint32(*FlagRound))
}
if Buildmode == BuildmodeShared {
ctxt.hostlink()
ctxt.archive()
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f cpu time\n", obj.Cputime())
- fmt.Fprintf(ctxt.Bso, "%d symbols\n", len(ctxt.Allsym))
- fmt.Fprintf(ctxt.Bso, "%d liveness data\n", liveness)
+ ctxt.Logf("%5.2f cpu time\n", obj.Cputime())
+ ctxt.Logf("%d symbols\n", len(ctxt.Allsym))
+ ctxt.Logf("%d liveness data\n", liveness)
}
ctxt.Bso.Flush()
import (
"cmd/internal/obj"
- "fmt"
"log"
"os"
"path/filepath"
ftab.Size = int64(len(ftab.P))
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f pclntab=%d bytes, funcdata total %d bytes\n", obj.Cputime(), ftab.Size, funcdataBytes)
+ ctxt.Logf("%5.2f pclntab=%d bytes, funcdata total %d bytes\n", obj.Cputime(), ftab.Size, funcdataBytes)
}
}
func asmb(ctxt *ld.Link) {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f asmb\n", obj.Cputime())
}
if ld.Iself {
if ld.Segrodata.Filelen > 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f rodatblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segrodata.Fileoff))
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f datblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segdata.Fileoff))
if !*ld.FlagS {
// TODO: rationalize
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f sym\n", obj.Cputime())
}
switch ld.HEADTYPE {
default:
default:
if ld.Iself {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
+ ctxt.Logf("%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
ld.Cflush()
ctxt.Cursym = nil
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f header\n", obj.Cputime())
}
ld.Cseek(0)
switch ld.HEADTYPE {
func asmb(ctxt *ld.Link) {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f asmb\n", obj.Cputime())
}
if ld.Iself {
if ld.Segrodata.Filelen > 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f rodatblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segrodata.Fileoff))
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f datblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segdata.Fileoff))
if !*ld.FlagS {
// TODO: rationalize
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f sym\n", obj.Cputime())
}
switch ld.HEADTYPE {
default:
default:
if ld.Iself {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
+ ctxt.Logf("%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
ld.Cflush()
ctxt.Cursym = nil
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f header\n", obj.Cputime())
}
ld.Cseek(0)
switch ld.HEADTYPE {
func asmb(ctxt *ld.Link) {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f asmb\n", obj.Cputime())
}
if ld.Iself {
if ld.Segrodata.Filelen > 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f rodatblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segrodata.Fileoff))
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f datblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segdata.Fileoff))
ctxt.Diag("unsupported executable format")
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f sym\n", obj.Cputime())
}
symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
symo = uint32(ld.Rnd(int64(symo), int64(*ld.FlagRound)))
ld.Cseek(int64(symo))
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
+ ctxt.Logf("%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
ld.Cflush()
ld.Cwrite(ld.Elfstrdat)
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
+ ctxt.Logf("%5.2f dwarf\n", obj.Cputime())
}
if ld.Linkmode == ld.LinkExternal {
ctxt.Cursym = nil
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f header\n", obj.Cputime())
}
ld.Cseek(0)
switch ld.HEADTYPE {
import (
"cmd/internal/obj"
"cmd/link/internal/ld"
- "fmt"
"log"
)
func asmb(ctxt *ld.Link) {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f asmb\n", obj.Cputime())
}
if ld.Iself {
if ld.Segrodata.Filelen > 0 {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f rodatblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segrodata.Fileoff))
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f datblk\n", obj.Cputime())
}
ld.Cseek(int64(ld.Segdata.Fileoff))
if !*ld.FlagS {
// TODO: rationalize
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f sym\n", obj.Cputime())
}
switch ld.HEADTYPE {
default:
default:
if ld.Iself {
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
+ ctxt.Logf("%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
ld.Cflush()
case obj.Hwindows:
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
+ ctxt.Logf("%5.2f dwarf\n", obj.Cputime())
}
case obj.Hdarwin:
}
if ctxt.Debugvlog != 0 {
- fmt.Fprintf(ctxt.Bso, "%5.2f headr\n", obj.Cputime())
- ctxt.Bso.Flush()
+ ctxt.Logf("%5.2f headr\n", obj.Cputime())
}
ld.Cseek(0)
switch ld.HEADTYPE {