Commit 0a15d950 authored by Michael Matloob's avatar Michael Matloob

cmd/link: use standard library flag package where possible

The obj library's flag functions are (mostly) light wrappers
around the standard library flag package. Use the flag package
directly where possible.

Most uses of the 'count'-type flags (except for -v) only check
against 0, so they can safely be replaced by bools. Only -v
and the flagfns haven't been replaced.

Debug has been turned into a slice of bools rather than ints.
There was a copy of the -v verbosity in ctxt.Debugvlog, so don't use
Debug['v'] and just use ctxt.Debugvlog.

Updates #16818

Change-Id: Icf6473a4823c9d35513bbd0c34ea02d5676d782a
Reviewed-on: https://go-review.googlesource.com/27471
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 65c5d624
...@@ -599,12 +599,12 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -599,12 +599,12 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) {
} }
func asmb(ctxt *ld.Link) { func asmb(ctxt *ld.Link) {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f codeblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f codeblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -623,7 +623,7 @@ func asmb(ctxt *ld.Link) { ...@@ -623,7 +623,7 @@ func asmb(ctxt *ld.Link) {
} }
if ld.Segrodata.Filelen > 0 { if ld.Segrodata.Filelen > 0 {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -632,7 +632,7 @@ func asmb(ctxt *ld.Link) { ...@@ -632,7 +632,7 @@ func asmb(ctxt *ld.Link) {
ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen)) ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
} }
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -657,7 +657,7 @@ func asmb(ctxt *ld.Link) { ...@@ -657,7 +657,7 @@ func asmb(ctxt *ld.Link) {
break break
case obj.Hdarwin: case obj.Hdarwin:
ld.Debug['8'] = 1 /* 64-bit addresses */ ld.Debug['8'] = true /* 64-bit addresses */
case obj.Hlinux, case obj.Hlinux,
obj.Hfreebsd, obj.Hfreebsd,
...@@ -665,7 +665,7 @@ func asmb(ctxt *ld.Link) { ...@@ -665,7 +665,7 @@ func asmb(ctxt *ld.Link) {
obj.Hopenbsd, obj.Hopenbsd,
obj.Hdragonfly, obj.Hdragonfly,
obj.Hsolaris: obj.Hsolaris:
ld.Debug['8'] = 1 /* 64-bit addresses */ ld.Debug['8'] = true /* 64-bit addresses */
case obj.Hnacl, case obj.Hnacl,
obj.Hwindows: obj.Hwindows:
...@@ -676,15 +676,15 @@ func asmb(ctxt *ld.Link) { ...@@ -676,15 +676,15 @@ func asmb(ctxt *ld.Link) {
ld.Spsize = 0 ld.Spsize = 0
ld.Lcsize = 0 ld.Lcsize = 0
symo := int64(0) symo := int64(0)
if ld.Debug['s'] == 0 { if !ld.Debug['s'] {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
switch ld.HEADTYPE { switch ld.HEADTYPE {
default: default:
case obj.Hplan9: case obj.Hplan9:
ld.Debug['s'] = 1 ld.Debug['s'] = true
symo = int64(ld.Segdata.Fileoff + ld.Segdata.Filelen) symo = int64(ld.Segdata.Fileoff + ld.Segdata.Filelen)
case obj.Hdarwin: case obj.Hdarwin:
...@@ -714,7 +714,7 @@ func asmb(ctxt *ld.Link) { ...@@ -714,7 +714,7 @@ func asmb(ctxt *ld.Link) {
ld.Cflush() ld.Cflush()
ld.Cwrite(ld.Elfstrdat) ld.Cwrite(ld.Elfstrdat)
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
} }
...@@ -738,7 +738,7 @@ func asmb(ctxt *ld.Link) { ...@@ -738,7 +738,7 @@ func asmb(ctxt *ld.Link) {
} }
case obj.Hwindows: case obj.Hwindows:
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
} }
...@@ -749,7 +749,7 @@ func asmb(ctxt *ld.Link) { ...@@ -749,7 +749,7 @@ func asmb(ctxt *ld.Link) {
} }
} }
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f headr\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f headr\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
......
...@@ -166,7 +166,7 @@ func archinit(ctxt *ld.Link) { ...@@ -166,7 +166,7 @@ func archinit(ctxt *ld.Link) {
case obj.Hnacl: case obj.Hnacl:
ld.Elfinit(ctxt) ld.Elfinit(ctxt)
ld.Debug['w']++ // disable dwarf, which gets confused and is useless anyway ld.Debug['w'] = true // disable dwarf, which gets confused and is useless anyway
ld.HEADR = 0x10000 ld.HEADR = 0x10000
ld.Funcalign = 32 ld.Funcalign = 32
if ld.INITTEXT == -1 { if ld.INITTEXT == -1 {
......
...@@ -582,7 +582,7 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -582,7 +582,7 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) {
} }
func asmb(ctxt *ld.Link) { func asmb(ctxt *ld.Link) {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -600,7 +600,7 @@ func asmb(ctxt *ld.Link) { ...@@ -600,7 +600,7 @@ func asmb(ctxt *ld.Link) {
} }
if ld.Segrodata.Filelen > 0 { if ld.Segrodata.Filelen > 0 {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -609,7 +609,7 @@ func asmb(ctxt *ld.Link) { ...@@ -609,7 +609,7 @@ func asmb(ctxt *ld.Link) {
ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen)) ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
} }
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -630,9 +630,9 @@ func asmb(ctxt *ld.Link) { ...@@ -630,9 +630,9 @@ func asmb(ctxt *ld.Link) {
ld.Lcsize = 0 ld.Lcsize = 0
symo := uint32(0) symo := uint32(0)
if ld.Debug['s'] == 0 { if !ld.Debug['s'] {
// TODO: rationalize // TODO: rationalize
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -654,7 +654,7 @@ func asmb(ctxt *ld.Link) { ...@@ -654,7 +654,7 @@ func asmb(ctxt *ld.Link) {
switch ld.HEADTYPE { switch ld.HEADTYPE {
default: default:
if ld.Iself { if ld.Iself {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
} }
ld.Asmelfsym(ctxt) ld.Asmelfsym(ctxt)
...@@ -688,7 +688,7 @@ func asmb(ctxt *ld.Link) { ...@@ -688,7 +688,7 @@ func asmb(ctxt *ld.Link) {
} }
ctxt.Cursym = nil ctxt.Cursym = nil
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -717,7 +717,7 @@ func asmb(ctxt *ld.Link) { ...@@ -717,7 +717,7 @@ func asmb(ctxt *ld.Link) {
} }
ld.Cflush() ld.Cflush()
if ld.Debug['c'] != 0 { if ld.Debug['c'] {
fmt.Printf("textsize=%d\n", ld.Segtext.Filelen) fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
fmt.Printf("datsize=%d\n", ld.Segdata.Filelen) fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen) fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
......
...@@ -126,7 +126,7 @@ func archinit(ctxt *ld.Link) { ...@@ -126,7 +126,7 @@ func archinit(ctxt *ld.Link) {
obj.Hfreebsd, obj.Hfreebsd,
obj.Hnetbsd, obj.Hnetbsd,
obj.Hopenbsd: obj.Hopenbsd:
ld.Debug['d'] = 0 ld.Debug['d'] = false
// with dynamic linking // with dynamic linking
ld.Elfinit(ctxt) ld.Elfinit(ctxt)
ld.HEADR = ld.ELFRESERVE ld.HEADR = ld.ELFRESERVE
...@@ -155,7 +155,7 @@ func archinit(ctxt *ld.Link) { ...@@ -155,7 +155,7 @@ func archinit(ctxt *ld.Link) {
} }
case obj.Hdarwin: /* apple MACH */ case obj.Hdarwin: /* apple MACH */
ld.Debug['w'] = 1 // disable DWARF generation ld.Debug['w'] = true // disable DWARF generation
ld.Machoinit() ld.Machoinit()
ld.HEADR = ld.INITIAL_MACHO_HEADR ld.HEADR = ld.INITIAL_MACHO_HEADR
if ld.INITTEXT == -1 { if ld.INITTEXT == -1 {
......
...@@ -391,7 +391,7 @@ func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 { ...@@ -391,7 +391,7 @@ func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
} }
func asmb(ctxt *ld.Link) { func asmb(ctxt *ld.Link) {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -409,7 +409,7 @@ func asmb(ctxt *ld.Link) { ...@@ -409,7 +409,7 @@ func asmb(ctxt *ld.Link) {
} }
if ld.Segrodata.Filelen > 0 { if ld.Segrodata.Filelen > 0 {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -418,7 +418,7 @@ func asmb(ctxt *ld.Link) { ...@@ -418,7 +418,7 @@ func asmb(ctxt *ld.Link) {
ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen)) ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
} }
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -439,9 +439,9 @@ func asmb(ctxt *ld.Link) { ...@@ -439,9 +439,9 @@ func asmb(ctxt *ld.Link) {
ld.Lcsize = 0 ld.Lcsize = 0
symo := uint32(0) symo := uint32(0)
if ld.Debug['s'] == 0 { if !ld.Debug['s'] {
// TODO: rationalize // TODO: rationalize
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -463,7 +463,7 @@ func asmb(ctxt *ld.Link) { ...@@ -463,7 +463,7 @@ func asmb(ctxt *ld.Link) {
switch ld.HEADTYPE { switch ld.HEADTYPE {
default: default:
if ld.Iself { if ld.Iself {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
} }
ld.Asmelfsym(ctxt) ld.Asmelfsym(ctxt)
...@@ -497,7 +497,7 @@ func asmb(ctxt *ld.Link) { ...@@ -497,7 +497,7 @@ func asmb(ctxt *ld.Link) {
} }
ctxt.Cursym = nil ctxt.Cursym = nil
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -526,7 +526,7 @@ func asmb(ctxt *ld.Link) { ...@@ -526,7 +526,7 @@ func asmb(ctxt *ld.Link) {
} }
ld.Cflush() ld.Cflush()
if ld.Debug['c'] != 0 { if ld.Debug['c'] {
fmt.Printf("textsize=%d\n", ld.Segtext.Filelen) fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
fmt.Printf("datsize=%d\n", ld.Segdata.Filelen) fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen) fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
......
...@@ -138,7 +138,7 @@ func archinit(ctxt *ld.Link) { ...@@ -138,7 +138,7 @@ func archinit(ctxt *ld.Link) {
} }
case obj.Hdarwin: /* apple MACH */ case obj.Hdarwin: /* apple MACH */
ld.Debug['w'] = 1 // disable DWARF generation ld.Debug['w'] = true // disable DWARF generation
ld.Machoinit() ld.Machoinit()
ld.HEADR = ld.INITIAL_MACHO_HEADR ld.HEADR = ld.INITIAL_MACHO_HEADR
if ld.INITTEXT == -1 { if ld.INITTEXT == -1 {
......
...@@ -68,7 +68,7 @@ func hostArchive(ctxt *Link, name string) { ...@@ -68,7 +68,7 @@ func hostArchive(ctxt *Link, name string) {
if err != nil { if err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
// It's OK if we don't have a libgcc file at all. // It's OK if we don't have a libgcc file at all.
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "skipping libgcc file: %v\n", err) fmt.Fprintf(ctxt.Bso, "skipping libgcc file: %v\n", err)
} }
return return
......
...@@ -652,7 +652,7 @@ func relocsym(ctxt *Link, s *Symbol) { ...@@ -652,7 +652,7 @@ func relocsym(ctxt *Link, s *Symbol) {
} }
func (ctxt *Link) reloc() { func (ctxt *Link) reloc() {
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f reloc\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f reloc\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -725,10 +725,10 @@ func dynrelocsym(ctxt *Link, s *Symbol) { ...@@ -725,10 +725,10 @@ func dynrelocsym(ctxt *Link, s *Symbol) {
func dynreloc(ctxt *Link, data *[obj.SXREF][]*Symbol) { func dynreloc(ctxt *Link, data *[obj.SXREF][]*Symbol) {
// -d suppresses dynamic loader format, so we may as well not // -d suppresses dynamic loader format, so we may as well not
// compute these sections or mark their symbols as reachable. // compute these sections or mark their symbols as reachable.
if Debug['d'] != 0 && HEADTYPE != obj.Hwindows { if Debug['d'] && HEADTYPE != obj.Hwindows {
return return
} }
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f reloc\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f reloc\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -750,14 +750,14 @@ func Codeblk(ctxt *Link, addr int64, size int64) { ...@@ -750,14 +750,14 @@ func Codeblk(ctxt *Link, addr int64, size int64) {
CodeblkPad(ctxt, addr, size, zeros[:]) CodeblkPad(ctxt, addr, size, zeros[:])
} }
func CodeblkPad(ctxt *Link, addr int64, size int64, pad []byte) { func CodeblkPad(ctxt *Link, addr int64, size int64, pad []byte) {
if Debug['a'] != 0 { if Debug['a'] {
fmt.Fprintf(ctxt.Bso, "codeblk [%#x,%#x) at offset %#x\n", addr, addr+size, Cpos()) fmt.Fprintf(ctxt.Bso, "codeblk [%#x,%#x) at offset %#x\n", addr, addr+size, Cpos())
} }
blk(ctxt, ctxt.Textp, addr, size, pad) blk(ctxt, ctxt.Textp, addr, size, pad)
/* again for printing */ /* again for printing */
if Debug['a'] == 0 { if !Debug['a'] {
return return
} }
...@@ -862,14 +862,14 @@ func blk(ctxt *Link, syms []*Symbol, addr, size int64, pad []byte) { ...@@ -862,14 +862,14 @@ func blk(ctxt *Link, syms []*Symbol, addr, size int64, pad []byte) {
} }
func Datblk(ctxt *Link, addr int64, size int64) { func Datblk(ctxt *Link, addr int64, size int64) {
if Debug['a'] != 0 { if Debug['a'] {
fmt.Fprintf(ctxt.Bso, "datblk [%#x,%#x) at offset %#x\n", addr, addr+size, Cpos()) fmt.Fprintf(ctxt.Bso, "datblk [%#x,%#x) at offset %#x\n", addr, addr+size, Cpos())
} }
blk(ctxt, datap, addr, size, zeros[:]) blk(ctxt, datap, addr, size, zeros[:])
/* again for printing */ /* again for printing */
if Debug['a'] == 0 { if !Debug['a'] {
return return
} }
...@@ -933,7 +933,7 @@ func Datblk(ctxt *Link, addr int64, size int64) { ...@@ -933,7 +933,7 @@ func Datblk(ctxt *Link, addr int64, size int64) {
} }
func Dwarfblk(ctxt *Link, addr int64, size int64) { func Dwarfblk(ctxt *Link, addr int64, size int64) {
if Debug['a'] != 0 { if Debug['a'] {
fmt.Fprintf(ctxt.Bso, "dwarfblk [%#x,%#x) at offset %#x\n", addr, addr+size, Cpos()) fmt.Fprintf(ctxt.Bso, "dwarfblk [%#x,%#x) at offset %#x\n", addr, addr+size, Cpos())
} }
...@@ -1194,7 +1194,7 @@ func checkdatsize(ctxt *Link, datsize int64, symn int) { ...@@ -1194,7 +1194,7 @@ func checkdatsize(ctxt *Link, datsize int64, symn int) {
var datap []*Symbol var datap []*Symbol
func (ctxt *Link) dodata() { func (ctxt *Link) dodata() {
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dodata\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f dodata\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -1439,7 +1439,7 @@ func (ctxt *Link) dodata() { ...@@ -1439,7 +1439,7 @@ func (ctxt *Link) dodata() {
if len(data[obj.STLSBSS]) > 0 { if len(data[obj.STLSBSS]) > 0 {
var sect *Section var sect *Section
if Iself && (Linkmode == LinkExternal || Debug['d'] == 0) && HEADTYPE != obj.Hopenbsd { if Iself && (Linkmode == LinkExternal || !Debug['d']) && HEADTYPE != obj.Hopenbsd {
sect = addsection(&Segdata, ".tbss", 06) sect = addsection(&Segdata, ".tbss", 06)
sect.Align = int32(SysArch.PtrSize) sect.Align = int32(SysArch.PtrSize)
sect.Vaddr = 0 sect.Vaddr = 0
......
...@@ -45,7 +45,7 @@ import ( ...@@ -45,7 +45,7 @@ import (
// //
// Any unreached text symbols are removed from ctxt.Textp. // Any unreached text symbols are removed from ctxt.Textp.
func deadcode(ctxt *Link) { func deadcode(ctxt *Link) {
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f deadcode\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f deadcode\n", obj.Cputime())
} }
...@@ -180,7 +180,7 @@ func (d *deadcodepass) cleanupReloc(r *Reloc) { ...@@ -180,7 +180,7 @@ func (d *deadcodepass) cleanupReloc(r *Reloc) {
if r.Sym.Attr.Reachable() { if r.Sym.Attr.Reachable() {
r.Type = obj.R_ADDROFF r.Type = obj.R_ADDROFF
} else { } else {
if Debug['v'] > 1 { if d.ctxt.Debugvlog > 1 {
fmt.Fprintf(d.ctxt.Bso, "removing method %s\n", r.Sym.Name) fmt.Fprintf(d.ctxt.Bso, "removing method %s\n", r.Sym.Name)
} }
r.Sym = nil r.Sym = nil
...@@ -264,7 +264,7 @@ func (d *deadcodepass) flood() { ...@@ -264,7 +264,7 @@ func (d *deadcodepass) flood() {
s := d.markQueue[0] s := d.markQueue[0]
d.markQueue = d.markQueue[1:] d.markQueue = d.markQueue[1:]
if s.Type == obj.STEXT { if s.Type == obj.STEXT {
if Debug['v'] > 1 { if d.ctxt.Debugvlog > 1 {
fmt.Fprintf(d.ctxt.Bso, "marktext %s\n", s.Name) fmt.Fprintf(d.ctxt.Bso, "marktext %s\n", s.Name)
} }
if s.FuncInfo != nil { if s.FuncInfo != nil {
...@@ -278,7 +278,7 @@ func (d *deadcodepass) flood() { ...@@ -278,7 +278,7 @@ func (d *deadcodepass) flood() {
if strings.HasPrefix(s.Name, "type.") && s.Name[5] != '.' { if strings.HasPrefix(s.Name, "type.") && s.Name[5] != '.' {
if decodetype_kind(s)&kindMask == kindInterface { if decodetype_kind(s)&kindMask == kindInterface {
for _, sig := range decodetype_ifacemethods(d.ctxt.Arch, s) { for _, sig := range decodetype_ifacemethods(d.ctxt.Arch, s) {
if Debug['v'] > 1 { if d.ctxt.Debugvlog > 1 {
fmt.Fprintf(d.ctxt.Bso, "reached iface method: %s\n", sig) fmt.Fprintf(d.ctxt.Bso, "reached iface method: %s\n", sig)
} }
d.ifaceMethod[sig] = true d.ifaceMethod[sig] = true
......
...@@ -1398,10 +1398,10 @@ var prototypedies map[string]*dwarf.DWDie ...@@ -1398,10 +1398,10 @@ var prototypedies map[string]*dwarf.DWDie
* *
*/ */
func dwarfgeneratedebugsyms(ctxt *Link) { func dwarfgeneratedebugsyms(ctxt *Link) {
if Debug['w'] != 0 { // disable dwarf if Debug['w'] { // disable dwarf
return return
} }
if Debug['s'] != 0 && HEADTYPE != obj.Hdarwin { if Debug['s'] && HEADTYPE != obj.Hdarwin {
return return
} }
if HEADTYPE == obj.Hplan9 { if HEADTYPE == obj.Hplan9 {
...@@ -1414,7 +1414,7 @@ func dwarfgeneratedebugsyms(ctxt *Link) { ...@@ -1414,7 +1414,7 @@ func dwarfgeneratedebugsyms(ctxt *Link) {
} }
} }
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
} }
...@@ -1483,7 +1483,7 @@ func dwarfgeneratedebugsyms(ctxt *Link) { ...@@ -1483,7 +1483,7 @@ func dwarfgeneratedebugsyms(ctxt *Link) {
* Elf. * Elf.
*/ */
func dwarfaddshstrings(ctxt *Link, shstrtab *Symbol) { func dwarfaddshstrings(ctxt *Link, shstrtab *Symbol) {
if Debug['w'] != 0 { // disable dwarf if Debug['w'] { // disable dwarf
return return
} }
...@@ -1508,7 +1508,7 @@ func dwarfaddshstrings(ctxt *Link, shstrtab *Symbol) { ...@@ -1508,7 +1508,7 @@ func dwarfaddshstrings(ctxt *Link, shstrtab *Symbol) {
// Add section symbols for DWARF debug info. This is called before // Add section symbols for DWARF debug info. This is called before
// dwarfaddelfheaders. // dwarfaddelfheaders.
func dwarfaddelfsectionsyms(ctxt *Link) { func dwarfaddelfsectionsyms(ctxt *Link) {
if Debug['w'] != 0 { // disable dwarf if Debug['w'] { // disable dwarf
return return
} }
if Linkmode != LinkExternal { if Linkmode != LinkExternal {
...@@ -1528,7 +1528,7 @@ func dwarfaddelfsectionsyms(ctxt *Link) { ...@@ -1528,7 +1528,7 @@ func dwarfaddelfsectionsyms(ctxt *Link) {
* Windows PE * Windows PE
*/ */
func dwarfaddpeheaders(ctxt *Link) { func dwarfaddpeheaders(ctxt *Link) {
if Debug['w'] != 0 { // disable dwarf if Debug['w'] { // disable dwarf
return return
} }
for sect := Segdwarf.Sect; sect != nil; sect = sect.Next { for sect := Segdwarf.Sect; sect != nil; sect = sect.Next {
......
...@@ -1837,7 +1837,7 @@ func (ctxt *Link) doelf() { ...@@ -1837,7 +1837,7 @@ func (ctxt *Link) doelf() {
// binutils could correctly calculate PT_TLS size. // binutils could correctly calculate PT_TLS size.
// see https://golang.org/issue/5200. // see https://golang.org/issue/5200.
if HEADTYPE != obj.Hopenbsd { if HEADTYPE != obj.Hopenbsd {
if Debug['d'] == 0 || Linkmode == LinkExternal { if !Debug['d'] || Linkmode == LinkExternal {
Addstring(ctxt, shstrtab, ".tbss") Addstring(ctxt, shstrtab, ".tbss")
} }
} }
...@@ -1867,7 +1867,7 @@ func (ctxt *Link) doelf() { ...@@ -1867,7 +1867,7 @@ func (ctxt *Link) doelf() {
Addstring(ctxt, shstrtab, relro_prefix+".gopclntab") Addstring(ctxt, shstrtab, relro_prefix+".gopclntab")
if Linkmode == LinkExternal { if Linkmode == LinkExternal {
Debug['d'] = 1 Debug['d'] = true
Addstring(ctxt, shstrtab, elfRelType+".text") Addstring(ctxt, shstrtab, elfRelType+".text")
Addstring(ctxt, shstrtab, elfRelType+".rodata") Addstring(ctxt, shstrtab, elfRelType+".rodata")
...@@ -1904,7 +1904,7 @@ func (ctxt *Link) doelf() { ...@@ -1904,7 +1904,7 @@ func (ctxt *Link) doelf() {
Addstring(ctxt, shstrtab, elfRelType+".init_array") Addstring(ctxt, shstrtab, elfRelType+".init_array")
} }
if Debug['s'] == 0 { if !Debug['s'] {
Addstring(ctxt, shstrtab, ".symtab") Addstring(ctxt, shstrtab, ".symtab")
Addstring(ctxt, shstrtab, ".strtab") Addstring(ctxt, shstrtab, ".strtab")
dwarfaddshstrings(ctxt, shstrtab) dwarfaddshstrings(ctxt, shstrtab)
...@@ -1912,7 +1912,7 @@ func (ctxt *Link) doelf() { ...@@ -1912,7 +1912,7 @@ func (ctxt *Link) doelf() {
Addstring(ctxt, shstrtab, ".shstrtab") Addstring(ctxt, shstrtab, ".shstrtab")
if Debug['d'] == 0 { /* -d suppresses dynamic loader format */ if !Debug['d'] { /* -d suppresses dynamic loader format */
Addstring(ctxt, shstrtab, ".interp") Addstring(ctxt, shstrtab, ".interp")
Addstring(ctxt, shstrtab, ".hash") Addstring(ctxt, shstrtab, ".hash")
Addstring(ctxt, shstrtab, ".got") Addstring(ctxt, shstrtab, ".got")
...@@ -2198,7 +2198,7 @@ func Asmbelf(ctxt *Link, symo int64) { ...@@ -2198,7 +2198,7 @@ func Asmbelf(ctxt *Link, symo int64) {
Segtext.Filelen += uint64(o) Segtext.Filelen += uint64(o)
} }
if Debug['d'] == 0 { /* -d suppresses dynamic loader format */ if !Debug['d'] { /* -d suppresses dynamic loader format */
/* interpreter */ /* interpreter */
sh := elfshname(ctxt, ".interp") sh := elfshname(ctxt, ".interp")
...@@ -2286,7 +2286,7 @@ func Asmbelf(ctxt *Link, symo int64) { ...@@ -2286,7 +2286,7 @@ func Asmbelf(ctxt *Link, symo int64) {
elfphload(ctxt, &Segdata) elfphload(ctxt, &Segdata)
/* Dynamic linking sections */ /* Dynamic linking sections */
if Debug['d'] == 0 { if !Debug['d'] {
sh := elfshname(ctxt, ".dynsym") sh := elfshname(ctxt, ".dynsym")
sh.type_ = SHT_DYNSYM sh.type_ = SHT_DYNSYM
sh.flags = SHF_ALLOC sh.flags = SHF_ALLOC
...@@ -2471,7 +2471,7 @@ elfobj: ...@@ -2471,7 +2471,7 @@ elfobj:
eh.shstrndx = uint16(sh.shnum) eh.shstrndx = uint16(sh.shnum)
// put these sections early in the list // put these sections early in the list
if Debug['s'] == 0 { if !Debug['s'] {
elfshname(ctxt, ".symtab") elfshname(ctxt, ".symtab")
elfshname(ctxt, ".strtab") elfshname(ctxt, ".strtab")
} }
...@@ -2515,7 +2515,7 @@ elfobj: ...@@ -2515,7 +2515,7 @@ elfobj:
sh.flags = 0 sh.flags = 0
} }
if Debug['s'] == 0 { if !Debug['s'] {
sh := elfshname(ctxt, ".symtab") sh := elfshname(ctxt, ".symtab")
sh.type_ = SHT_SYMTAB sh.type_ = SHT_SYMTAB
sh.off = uint64(symo) sh.off = uint64(symo)
...@@ -2581,7 +2581,7 @@ elfobj: ...@@ -2581,7 +2581,7 @@ elfobj:
a += int64(elfwritehdr()) a += int64(elfwritehdr())
a += int64(elfwritephdrs()) a += int64(elfwritephdrs())
a += int64(elfwriteshdrs()) a += int64(elfwriteshdrs())
if Debug['d'] == 0 { if !Debug['d'] {
a += int64(elfwriteinterp(ctxt)) a += int64(elfwriteinterp(ctxt))
} }
if Linkmode != LinkExternal { if Linkmode != LinkExternal {
......
...@@ -31,13 +31,13 @@ func expandpkg(t0 string, pkg string) string { ...@@ -31,13 +31,13 @@ func expandpkg(t0 string, pkg string) string {
func ldpkg(ctxt *Link, f *bio.Reader, pkg string, length int64, filename string, whence int) { func ldpkg(ctxt *Link, f *bio.Reader, pkg string, length int64, filename string, whence int) {
var p0, p1 int var p0, p1 int
if Debug['g'] != 0 { if Debug['g'] {
return return
} }
if int64(int(length)) != length { if int64(int(length)) != length {
fmt.Fprintf(os.Stderr, "%s: too much pkg data in %s\n", os.Args[0], filename) fmt.Fprintf(os.Stderr, "%s: too much pkg data in %s\n", os.Args[0], filename)
if Debug['u'] != 0 { if Debug['u'] {
errorexit() errorexit()
} }
return return
...@@ -52,7 +52,7 @@ func ldpkg(ctxt *Link, f *bio.Reader, pkg string, length int64, filename string, ...@@ -52,7 +52,7 @@ func ldpkg(ctxt *Link, f *bio.Reader, pkg string, length int64, filename string,
bdata := make([]byte, length) bdata := make([]byte, length)
if _, err := io.ReadFull(f, bdata); err != nil { if _, err := io.ReadFull(f, bdata); err != nil {
fmt.Fprintf(os.Stderr, "%s: short pkg read %s\n", os.Args[0], filename) fmt.Fprintf(os.Stderr, "%s: short pkg read %s\n", os.Args[0], filename)
if Debug['u'] != 0 { if Debug['u'] {
errorexit() errorexit()
} }
return return
...@@ -84,7 +84,7 @@ func ldpkg(ctxt *Link, f *bio.Reader, pkg string, length int64, filename string, ...@@ -84,7 +84,7 @@ func ldpkg(ctxt *Link, f *bio.Reader, pkg string, length int64, filename string,
if pkg == "main" && !isMain { if pkg == "main" && !isMain {
Exitf("%s: not package main", filename) Exitf("%s: not package main", filename)
} }
if Debug['u'] != 0 && whence != ArchiveObj && !isSafe { if Debug['u'] && whence != ArchiveObj && !isSafe {
Exitf("load of unsafe package %s", filename) Exitf("load of unsafe package %s", filename)
} }
} }
...@@ -101,7 +101,7 @@ func ldpkg(ctxt *Link, f *bio.Reader, pkg string, length int64, filename string, ...@@ -101,7 +101,7 @@ func ldpkg(ctxt *Link, f *bio.Reader, pkg string, length int64, filename string,
i := strings.IndexByte(data[p0+1:], '\n') i := strings.IndexByte(data[p0+1:], '\n')
if i < 0 { if i < 0 {
fmt.Fprintf(os.Stderr, "%s: found $$ // cgo but no newline in %s\n", os.Args[0], filename) fmt.Fprintf(os.Stderr, "%s: found $$ // cgo but no newline in %s\n", os.Args[0], filename)
if Debug['u'] != 0 { if Debug['u'] {
errorexit() errorexit()
} }
return return
...@@ -114,7 +114,7 @@ func ldpkg(ctxt *Link, f *bio.Reader, pkg string, length int64, filename string, ...@@ -114,7 +114,7 @@ func ldpkg(ctxt *Link, f *bio.Reader, pkg string, length int64, filename string,
} }
if p1 < 0 { if p1 < 0 {
fmt.Fprintf(os.Stderr, "%s: cannot find end of // cgo section in %s\n", os.Args[0], filename) fmt.Fprintf(os.Stderr, "%s: cannot find end of // cgo section in %s\n", os.Args[0], filename)
if Debug['u'] != 0 { if Debug['u'] {
errorexit() errorexit()
} }
return return
...@@ -163,7 +163,7 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) { ...@@ -163,7 +163,7 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) {
lib = f[3] lib = f[3]
} }
if Debug['d'] != 0 { if Debug['d'] {
fmt.Fprintf(os.Stderr, "%s: %s: cannot use dynamic imports with -d flag\n", os.Args[0], file) fmt.Fprintf(os.Stderr, "%s: %s: cannot use dynamic imports with -d flag\n", os.Args[0], file)
nerrors++ nerrors++
return return
...@@ -267,7 +267,7 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) { ...@@ -267,7 +267,7 @@ func loadcgo(ctxt *Link, file string, pkg string, p string) {
goto err goto err
} }
if Debug['I'] == 0 { if !Debug['I'] {
if interpreter != "" && interpreter != f[1] { if interpreter != "" && interpreter != f[1] {
fmt.Fprintf(os.Stderr, "%s: conflict dynlinker: %s and %s\n", os.Args[0], interpreter, f[1]) fmt.Fprintf(os.Stderr, "%s: conflict dynlinker: %s and %s\n", os.Args[0], interpreter, f[1])
nerrors++ nerrors++
......
...@@ -448,7 +448,7 @@ func parseArmAttributes(ctxt *Link, e binary.ByteOrder, data []byte) { ...@@ -448,7 +448,7 @@ func parseArmAttributes(ctxt *Link, e binary.ByteOrder, data []byte) {
} }
func ldelf(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) { func ldelf(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f ldelf %s\n", obj.Cputime(), pn) fmt.Fprintf(ctxt.Bso, "%5.2f ldelf %s\n", obj.Cputime(), pn)
} }
......
...@@ -131,7 +131,7 @@ type PeObj struct { ...@@ -131,7 +131,7 @@ type PeObj struct {
} }
func ldpe(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) { func ldpe(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f ldpe %s\n", obj.Cputime(), pn) fmt.Fprintf(ctxt.Bso, "%5.2f ldpe %s\n", obj.Cputime(), pn)
} }
......
...@@ -130,7 +130,7 @@ func (r *Rpath) String() string { ...@@ -130,7 +130,7 @@ func (r *Rpath) String() string {
var ( var (
Thearch Arch Thearch Arch
Debug [128]int Debug [128]bool
Lcsize int32 Lcsize int32
rpath Rpath rpath Rpath
Spsize int32 Spsize int32
...@@ -198,8 +198,8 @@ var ( ...@@ -198,8 +198,8 @@ var (
elfglobalsymndx int elfglobalsymndx int
flag_dumpdep bool flag_dumpdep bool
flag_installsuffix string flag_installsuffix string
flag_race int flag_race bool
flag_msan int flag_msan bool
Buildmode BuildMode Buildmode BuildMode
Linkshared bool Linkshared bool
tracksym string tracksym string
...@@ -209,10 +209,10 @@ var ( ...@@ -209,10 +209,10 @@ var (
extldflags string extldflags string
extar string extar string
libgccfile string libgccfile string
debug_s int // backup old value of debug['s'] debug_s bool // backup old value of debug['s']
HEADR int32 HEADR int32
HEADTYPE int32 HEADTYPE int32
INITRND int32 INITRND int
INITTEXT int64 INITTEXT int64
INITDAT int64 INITDAT int64
INITENTRY string /* entry point */ INITENTRY string /* entry point */
...@@ -393,10 +393,10 @@ func libinit(ctxt *Link) { ...@@ -393,10 +393,10 @@ func libinit(ctxt *Link) {
if flag_installsuffix != "" { if flag_installsuffix != "" {
suffixsep = "_" suffixsep = "_"
suffix = flag_installsuffix suffix = flag_installsuffix
} else if flag_race != 0 { } else if flag_race {
suffixsep = "_" suffixsep = "_"
suffix = "race" suffix = "race"
} else if flag_msan != 0 { } else if flag_msan {
suffixsep = "_" suffixsep = "_"
suffix = "msan" suffix = "msan"
} }
...@@ -465,7 +465,7 @@ func loadinternal(ctxt *Link, name string) { ...@@ -465,7 +465,7 @@ func loadinternal(ctxt *Link, name string) {
for i := 0; i < len(ctxt.Libdir); i++ { for i := 0; i < len(ctxt.Libdir); i++ {
if Linkshared { if Linkshared {
shlibname := filepath.Join(ctxt.Libdir[i], name+".shlibname") shlibname := filepath.Join(ctxt.Libdir[i], name+".shlibname")
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "searching for %s.a in %s\n", name, shlibname) fmt.Fprintf(ctxt.Bso, "searching for %s.a in %s\n", name, shlibname)
} }
if _, err := os.Stat(shlibname); err == nil { if _, err := os.Stat(shlibname); err == nil {
...@@ -475,7 +475,7 @@ func loadinternal(ctxt *Link, name string) { ...@@ -475,7 +475,7 @@ func loadinternal(ctxt *Link, name string) {
} }
} }
pname := filepath.Join(ctxt.Libdir[i], name+".a") pname := filepath.Join(ctxt.Libdir[i], name+".a")
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "searching for %s.a in %s\n", name, pname) fmt.Fprintf(ctxt.Bso, "searching for %s.a in %s\n", name, pname)
} }
if _, err := os.Stat(pname); err == nil { if _, err := os.Stat(pname); err == nil {
...@@ -506,10 +506,10 @@ func (ctxt *Link) loadlib() { ...@@ -506,10 +506,10 @@ func (ctxt *Link) loadlib() {
if SysArch.Family == sys.ARM { if SysArch.Family == sys.ARM {
loadinternal(ctxt, "math") loadinternal(ctxt, "math")
} }
if flag_race != 0 { if flag_race {
loadinternal(ctxt, "runtime/race") loadinternal(ctxt, "runtime/race")
} }
if flag_msan != 0 { if flag_msan {
loadinternal(ctxt, "runtime/msan") loadinternal(ctxt, "runtime/msan")
} }
...@@ -517,7 +517,7 @@ func (ctxt *Link) loadlib() { ...@@ -517,7 +517,7 @@ func (ctxt *Link) loadlib() {
for i = 0; i < len(ctxt.Library); i++ { for i = 0; i < len(ctxt.Library); i++ {
iscgo = iscgo || ctxt.Library[i].Pkg == "runtime/cgo" iscgo = iscgo || ctxt.Library[i].Pkg == "runtime/cgo"
if ctxt.Library[i].Shlib == "" { if ctxt.Library[i].Shlib == "" {
if Debug['v'] > 1 { 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) fmt.Fprintf(ctxt.Bso, "%5.2f autolib: %s (from %s)\n", obj.Cputime(), ctxt.Library[i].File, ctxt.Library[i].Objref)
} }
objfile(ctxt, ctxt.Library[i]) objfile(ctxt, ctxt.Library[i])
...@@ -526,7 +526,7 @@ func (ctxt *Link) loadlib() { ...@@ -526,7 +526,7 @@ func (ctxt *Link) loadlib() {
for i = 0; i < len(ctxt.Library); i++ { for i = 0; i < len(ctxt.Library); i++ {
if ctxt.Library[i].Shlib != "" { if ctxt.Library[i].Shlib != "" {
if Debug['v'] > 1 { 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) fmt.Fprintf(ctxt.Bso, "%5.2f autolib: %s (from %s)\n", obj.Cputime(), ctxt.Library[i].Shlib, ctxt.Library[i].Objref)
} }
ldshlibsyms(ctxt, ctxt.Library[i].Shlib) ldshlibsyms(ctxt, ctxt.Library[i].Shlib)
...@@ -561,7 +561,7 @@ func (ctxt *Link) loadlib() { ...@@ -561,7 +561,7 @@ func (ctxt *Link) loadlib() {
} }
// Force external linking for msan. // Force external linking for msan.
if flag_msan != 0 { if flag_msan {
Linkmode = LinkExternal Linkmode = LinkExternal
} }
} }
...@@ -696,12 +696,12 @@ func (ctxt *Link) loadlib() { ...@@ -696,12 +696,12 @@ func (ctxt *Link) loadlib() {
} }
args := hostlinkArchArgs() args := hostlinkArchArgs()
args = append(args, "--print-libgcc-file-name") args = append(args, "--print-libgcc-file-name")
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%s %v\n", extld, args) fmt.Fprintf(ctxt.Bso, "%s %v\n", extld, args)
} }
out, err := exec.Command(extld, args...).Output() out, err := exec.Command(extld, args...).Output()
if err != nil { if err != nil {
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintln(ctxt.Bso, "not using a libgcc file because compiler failed") fmt.Fprintln(ctxt.Bso, "not using a libgcc file because compiler failed")
fmt.Fprintf(ctxt.Bso, "%v\n%s\n", err, out) fmt.Fprintf(ctxt.Bso, "%v\n%s\n", err, out)
} }
...@@ -733,7 +733,7 @@ func (ctxt *Link) loadlib() { ...@@ -733,7 +733,7 @@ func (ctxt *Link) loadlib() {
switch Buildmode { switch Buildmode {
case BuildmodeExe, BuildmodePIE: case BuildmodeExe, BuildmodePIE:
if havedynamic == 0 && HEADTYPE != obj.Hdarwin && HEADTYPE != obj.Hsolaris { if havedynamic == 0 && HEADTYPE != obj.Hdarwin && HEADTYPE != obj.Hsolaris {
Debug['d'] = 1 Debug['d'] = true
} }
} }
...@@ -775,7 +775,7 @@ func nextar(bp *bio.Reader, off int64, a *ArHdr) int64 { ...@@ -775,7 +775,7 @@ func nextar(bp *bio.Reader, off int64, a *ArHdr) int64 {
func objfile(ctxt *Link, lib *Library) { func objfile(ctxt *Link, lib *Library) {
pkg := pathtoprefix(lib.Pkg) pkg := pathtoprefix(lib.Pkg)
if Debug['v'] > 1 { if ctxt.Debugvlog > 1 {
fmt.Fprintf(ctxt.Bso, "%5.2f ldobj: %s (%s)\n", obj.Cputime(), lib.File, pkg) fmt.Fprintf(ctxt.Bso, "%5.2f ldobj: %s (%s)\n", obj.Cputime(), lib.File, pkg)
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -951,7 +951,7 @@ func hostlinksetup() { ...@@ -951,7 +951,7 @@ func hostlinksetup() {
// and turn off -s internally: the external linker needs the symbol // and turn off -s internally: the external linker needs the symbol
// information for its final link. // information for its final link.
debug_s = Debug['s'] debug_s = Debug['s']
Debug['s'] = 0 Debug['s'] = false
// create temporary directory and arrange cleanup // create temporary directory and arrange cleanup
if tmpdir == "" { if tmpdir == "" {
...@@ -1043,7 +1043,7 @@ func (ctxt *Link) archive() { ...@@ -1043,7 +1043,7 @@ func (ctxt *Link) archive() {
argv = append(argv, filepath.Join(tmpdir, "go.o")) argv = append(argv, filepath.Join(tmpdir, "go.o"))
argv = append(argv, hostobjCopy()...) argv = append(argv, hostobjCopy()...)
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "archive: %s\n", strings.Join(argv, " ")) fmt.Fprintf(ctxt.Bso, "archive: %s\n", strings.Join(argv, " "))
ctxt.Bso.Flush() ctxt.Bso.Flush()
} }
...@@ -1069,7 +1069,7 @@ func (l *Link) hostlink() { ...@@ -1069,7 +1069,7 @@ func (l *Link) hostlink() {
argv = append(argv, extld) argv = append(argv, extld)
argv = append(argv, hostlinkArchArgs()...) argv = append(argv, hostlinkArchArgs()...)
if Debug['s'] == 0 && debug_s == 0 { if !Debug['s'] && !debug_s {
argv = append(argv, "-gdwarf-2") argv = append(argv, "-gdwarf-2")
} else { } else {
argv = append(argv, "-s") argv = append(argv, "-s")
...@@ -1219,7 +1219,7 @@ func (l *Link) hostlink() { ...@@ -1219,7 +1219,7 @@ func (l *Link) hostlink() {
} }
} }
sanitizers := flag_race != 0 sanitizers := flag_race
for _, flag := range ldflag { for _, flag := range ldflag {
if strings.HasPrefix(flag, "-fsanitize=") { if strings.HasPrefix(flag, "-fsanitize=") {
...@@ -1269,7 +1269,7 @@ func (l *Link) hostlink() { ...@@ -1269,7 +1269,7 @@ func (l *Link) hostlink() {
argv = append(argv, peimporteddlls()...) argv = append(argv, peimporteddlls()...)
} }
if Debug['v'] != 0 { if l.Debugvlog != 0 {
fmt.Fprintf(l.Bso, "host link:") fmt.Fprintf(l.Bso, "host link:")
for _, v := range argv { for _, v := range argv {
fmt.Fprintf(l.Bso, " %q", v) fmt.Fprintf(l.Bso, " %q", v)
...@@ -1280,12 +1280,12 @@ func (l *Link) hostlink() { ...@@ -1280,12 +1280,12 @@ func (l *Link) hostlink() {
if out, err := exec.Command(argv[0], argv[1:]...).CombinedOutput(); err != nil { if out, err := exec.Command(argv[0], argv[1:]...).CombinedOutput(); err != nil {
Exitf("running %s failed: %v\n%s", argv[0], err, out) Exitf("running %s failed: %v\n%s", argv[0], err, out)
} else if Debug['v'] != 0 && len(out) > 0 { } else if l.Debugvlog != 0 && len(out) > 0 {
fmt.Fprintf(l.Bso, "%s", out) fmt.Fprintf(l.Bso, "%s", out)
l.Bso.Flush() l.Bso.Flush()
} }
if Debug['s'] == 0 && debug_s == 0 && HEADTYPE == obj.Hdarwin { if !Debug['s'] && !debug_s && HEADTYPE == obj.Hdarwin {
// Skip combining dwarf on arm. // Skip combining dwarf on arm.
if !SysArch.InFamily(sys.ARM, sys.ARM64) { if !SysArch.InFamily(sys.ARM, sys.ARM64) {
dsym := filepath.Join(tmpdir, "go.dwarf") dsym := filepath.Join(tmpdir, "go.dwarf")
...@@ -1383,7 +1383,7 @@ func ldobj(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string, file ...@@ -1383,7 +1383,7 @@ func ldobj(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string, file
t := fmt.Sprintf("%s %s %s ", goos, obj.Getgoarch(), obj.Getgoversion()) t := fmt.Sprintf("%s %s %s ", goos, obj.Getgoarch(), obj.Getgoversion())
line = strings.TrimRight(line, "\n") line = strings.TrimRight(line, "\n")
if !strings.HasPrefix(line[10:]+" ", t) && Debug['f'] == 0 { if !strings.HasPrefix(line[10:]+" ", t) && !Debug['f'] {
ctxt.Diag("%s: object is [%s] expected [%s]", pn, line[10:], t) ctxt.Diag("%s: object is [%s] expected [%s]", pn, line[10:], t)
return nil return nil
} }
...@@ -1938,7 +1938,7 @@ func setheadtype(s string) { ...@@ -1938,7 +1938,7 @@ func setheadtype(s string) {
} }
func setinterp(s string) { func setinterp(s string) {
Debug['I'] = 1 // denote cmdline interpreter override Debug['I'] = true // denote cmdline interpreter override
interpreter = s interpreter = s
} }
...@@ -2070,7 +2070,7 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, int, int64, int64, i ...@@ -2070,7 +2070,7 @@ func genasmsym(ctxt *Link, put func(*Link, *Symbol, string, int, int64, int64, i
// Otherwise, off is addressing the saved program counter. // Otherwise, off is addressing the saved program counter.
// Something underhanded is going on. Say nothing. // Something underhanded is going on. Say nothing.
if Debug['v'] != 0 || Debug['n'] != 0 { if ctxt.Debugvlog != 0 || Debug['n'] {
fmt.Fprintf(ctxt.Bso, "%5.2f symsize = %d\n", obj.Cputime(), uint32(Symsize)) fmt.Fprintf(ctxt.Bso, "%5.2f symsize = %d\n", obj.Cputime(), uint32(Symsize))
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -2149,7 +2149,7 @@ func (ctxt *Link) undef() { ...@@ -2149,7 +2149,7 @@ func (ctxt *Link) undef() {
} }
func (ctxt *Link) callgraph() { func (ctxt *Link) callgraph() {
if Debug['c'] == 0 { if !Debug['c'] {
return return
} }
...@@ -2177,7 +2177,7 @@ func (ctxt *Link) Diag(format string, args ...interface{}) { ...@@ -2177,7 +2177,7 @@ func (ctxt *Link) Diag(format string, args ...interface{}) {
} }
fmt.Printf("%s%s%s\n", tn, sep, fmt.Sprintf(format, args...)) fmt.Printf("%s%s%s\n", tn, sep, fmt.Sprintf(format, args...))
nerrors++ nerrors++
if Debug['h'] != 0 { if Debug['h'] {
panic("error") panic("error")
} }
if nerrors > 20 { if nerrors > 20 {
......
...@@ -162,7 +162,7 @@ type Link struct { ...@@ -162,7 +162,7 @@ type Link struct {
Goarm int32 Goarm int32
Headtype int Headtype int
Arch *sys.Arch Arch *sys.Arch
Debugvlog int32 Debugvlog int
Bso *bufio.Writer Bso *bufio.Writer
Windows int32 Windows int32
Goroot string Goroot string
......
...@@ -295,7 +295,7 @@ func machowrite() int { ...@@ -295,7 +295,7 @@ func machowrite() int {
} }
func (ctxt *Link) domacho() { func (ctxt *Link) domacho() {
if Debug['d'] != 0 { if Debug['d'] {
return return
} }
...@@ -493,7 +493,7 @@ func Asmbmacho(ctxt *Link) { ...@@ -493,7 +493,7 @@ func Asmbmacho(ctxt *Link) {
} }
/* dwarf */ /* dwarf */
if Debug['w'] == 0 { if !Debug['w'] {
if Linkmode != LinkExternal { if Linkmode != LinkExternal {
ms = newMachoSeg("__DWARF", 20) ms = newMachoSeg("__DWARF", 20)
ms.vaddr = Segdwarf.Vaddr ms.vaddr = Segdwarf.Vaddr
...@@ -539,7 +539,7 @@ func Asmbmacho(ctxt *Link) { ...@@ -539,7 +539,7 @@ func Asmbmacho(ctxt *Link) {
} }
} }
if Debug['d'] == 0 { if !Debug['d'] {
// must match domacholink below // must match domacholink below
s1 := Linklookup(ctxt, ".machosymtab", 0) s1 := Linklookup(ctxt, ".machosymtab", 0)
s2 := Linklookup(ctxt, ".linkedit.plt", 0) s2 := Linklookup(ctxt, ".linkedit.plt", 0)
......
...@@ -367,7 +367,7 @@ func (ctxt *Link) pclntab() { ...@@ -367,7 +367,7 @@ func (ctxt *Link) pclntab() {
ftab.Size = int64(len(ftab.P)) ftab.Size = int64(len(ftab.P))
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f pclntab=%d bytes, funcdata total %d bytes\n", obj.Cputime(), ftab.Size, funcdata_bytes) fmt.Fprintf(ctxt.Bso, "%5.2f pclntab=%d bytes, funcdata total %d bytes\n", obj.Cputime(), ftab.Size, funcdata_bytes)
} }
} }
......
...@@ -1021,7 +1021,7 @@ func addpesymtable(ctxt *Link) { ...@@ -1021,7 +1021,7 @@ func addpesymtable(ctxt *Link) {
// write COFF symbol table // write COFF symbol table
var symcnt int var symcnt int
if Debug['s'] == 0 || Linkmode == LinkExternal { if !Debug['s'] || Linkmode == LinkExternal {
symcnt = writePESymTableRecords(ctxt) symcnt = writePESymTableRecords(ctxt)
} }
...@@ -1168,7 +1168,7 @@ func Asmbpe(ctxt *Link) { ...@@ -1168,7 +1168,7 @@ func Asmbpe(ctxt *Link) {
c = addinitarray(ctxt) c = addinitarray(ctxt)
} }
if Debug['s'] == 0 { if !Debug['s'] {
dwarfaddpeheaders(ctxt) dwarfaddpeheaders(ctxt)
} }
......
...@@ -49,14 +49,9 @@ func Ldmain() { ...@@ -49,14 +49,9 @@ func Ldmain() {
ctxt := linknew(SysArch) ctxt := linknew(SysArch)
ctxt.Bso = bufio.NewWriter(os.Stdout) ctxt.Bso = bufio.NewWriter(os.Stdout)
Debug = [128]int{} Debug = [128]bool{}
nerrors = 0 nerrors = 0
outfile = ""
HEADTYPE = -1 HEADTYPE = -1
INITTEXT = -1
INITDAT = -1
INITRND = -1
INITENTRY = ""
Linkmode = LinkAuto Linkmode = LinkAuto
// For testing behavior of go command when tools crash silently. // For testing behavior of go command when tools crash silently.
...@@ -69,61 +64,60 @@ func Ldmain() { ...@@ -69,61 +64,60 @@ func Ldmain() {
} }
if SysArch.Family == sys.AMD64 && obj.Getgoos() == "plan9" { if SysArch.Family == sys.AMD64 && obj.Getgoos() == "plan9" {
obj.Flagcount("8", "use 64-bit addresses in symbol table", &Debug['8']) flag.BoolVar(&Debug['8'], "8", false, "use 64-bit addresses in symbol table")
} }
obj.Flagfn1("B", "add an ELF NT_GNU_BUILD_ID `note` when using ELF", addbuildinfo) obj.Flagfn1("B", "add an ELF NT_GNU_BUILD_ID `note` when using ELF", addbuildinfo)
obj.Flagcount("C", "check Go calls to C code", &Debug['C']) flag.BoolVar(&Debug['C'], "C", false, "check Go calls to C code")
obj.Flagint64("D", "set data segment `address`", &INITDAT) flag.Int64Var(&INITDAT, "D", -1, "set data segment `address`")
obj.Flagstr("E", "set `entry` symbol name", &INITENTRY) flag.StringVar(&INITENTRY, "E", "", "set `entry` symbol name")
obj.Flagfn1("I", "use `linker` as ELF dynamic linker", setinterp) obj.Flagfn1("I", "use `linker` as ELF dynamic linker", setinterp)
obj.Flagfn1("L", "add specified `directory` to library path", func(a string) { Lflag(ctxt, a) }) obj.Flagfn1("L", "add specified `directory` to library path", func(a string) { Lflag(ctxt, a) })
obj.Flagfn1("H", "set header `type`", setheadtype) obj.Flagfn1("H", "set header `type`", setheadtype)
obj.Flagint32("R", "set address rounding `quantum`", &INITRND) flag.IntVar(&INITRND, "R", -1, "set address rounding `quantum`")
obj.Flagint64("T", "set text segment `address`", &INITTEXT) flag.Int64Var(&INITTEXT, "T", -1, "set text segment `address`")
obj.Flagfn0("V", "print version and exit", doversion) obj.Flagfn0("V", "print version and exit", doversion)
obj.Flagfn1("X", "add string value `definition` of the form importpath.name=value", func(s string) { addstrdata1(ctxt, s) }) obj.Flagfn1("X", "add string value `definition` of the form importpath.name=value", func(s string) { addstrdata1(ctxt, s) })
obj.Flagcount("a", "disassemble output", &Debug['a']) flag.BoolVar(&Debug['a'], "a", false, "disassemble output")
obj.Flagstr("buildid", "record `id` as Go toolchain build id", &buildid) flag.StringVar(&buildid, "buildid", "", "record `id` as Go toolchain build id")
flag.Var(&Buildmode, "buildmode", "set build `mode`") flag.Var(&Buildmode, "buildmode", "set build `mode`")
obj.Flagcount("c", "dump call graph", &Debug['c']) flag.BoolVar(&Debug['c'], "c", false, "dump call graph")
obj.Flagcount("d", "disable dynamic executable", &Debug['d']) flag.BoolVar(&Debug['d'], "d", false, "disable dynamic executable")
flag.BoolVar(&flag_dumpdep, "dumpdep", false, "dump symbol dependency graph") flag.BoolVar(&flag_dumpdep, "dumpdep", false, "dump symbol dependency graph")
obj.Flagstr("extar", "archive program for buildmode=c-archive", &extar) flag.StringVar(&extar, "extar", "", "archive program for buildmode=c-archive")
obj.Flagstr("extld", "use `linker` when linking in external mode", &extld) flag.StringVar(&extld, "extld", "", "use `linker` when linking in external mode")
obj.Flagstr("extldflags", "pass `flags` to external linker", &extldflags) flag.StringVar(&extldflags, "extldflags", "", "pass `flags` to external linker")
obj.Flagcount("f", "ignore version mismatch", &Debug['f']) flag.BoolVar(&Debug['f'], "f", false, "ignore version mismatch")
obj.Flagcount("g", "disable go package data checks", &Debug['g']) flag.BoolVar(&Debug['g'], "g", false, "disable go package data checks")
obj.Flagcount("h", "halt on error", &Debug['h']) flag.BoolVar(&Debug['h'], "h", false, "halt on error")
obj.Flagstr("installsuffix", "set package directory `suffix`", &flag_installsuffix) flag.StringVar(&flag_installsuffix, "installsuffix", "", "set package directory `suffix`")
obj.Flagstr("k", "set field tracking `symbol`", &tracksym) flag.StringVar(&tracksym, "k", "", "set field tracking `symbol`")
obj.Flagstr("libgcc", "compiler support lib for internal linking; use \"none\" to disable", &libgccfile) flag.StringVar(&libgccfile, "libgcc", "", "compiler support lib for internal linking; use \"none\" to disable")
obj.Flagfn1("linkmode", "set link `mode` (internal, external, auto)", setlinkmode) obj.Flagfn1("linkmode", "set link `mode` (internal, external, auto)", setlinkmode)
flag.BoolVar(&Linkshared, "linkshared", false, "link against installed Go shared libraries") flag.BoolVar(&Linkshared, "linkshared", false, "link against installed Go shared libraries")
obj.Flagcount("msan", "enable MSan interface", &flag_msan) flag.BoolVar(&flag_msan, "msan", false, "enable MSan interface")
obj.Flagcount("n", "dump symbol table", &Debug['n']) flag.BoolVar(&Debug['n'], "n", false, "dump symbol table")
obj.Flagstr("o", "write output to `file`", &outfile) flag.StringVar(&outfile, "o", "", "write output to `file`")
flag.Var(&rpath, "r", "set the ELF dynamic linker search `path` to dir1:dir2:...") flag.Var(&rpath, "r", "set the ELF dynamic linker search `path` to dir1:dir2:...")
obj.Flagcount("race", "enable race detector", &flag_race) flag.BoolVar(&flag_race, "race", false, "enable race detector")
obj.Flagcount("s", "disable symbol table", &Debug['s']) flag.BoolVar(&Debug['s'], "s", false, "disable symbol table")
var flagShared int var flagShared bool
if SysArch.InFamily(sys.ARM, sys.AMD64) { if SysArch.InFamily(sys.ARM, sys.AMD64) {
obj.Flagcount("shared", "generate shared object (implies -linkmode external)", &flagShared) flag.BoolVar(&flagShared, "shared", false, "generate shared object (implies -linkmode external)")
} }
obj.Flagstr("tmpdir", "use `directory` for temporary files", &tmpdir) flag.StringVar(&tmpdir, "tmpdir", "", "use `directory` for temporary files")
obj.Flagcount("u", "reject unsafe packages", &Debug['u']) flag.BoolVar(&Debug['u'], "u", false, "reject unsafe packages")
obj.Flagcount("v", "print link trace", &Debug['v']) obj.Flagcount("v", "print link trace", &ctxt.Debugvlog)
obj.Flagcount("w", "disable DWARF generation", &Debug['w']) flag.BoolVar(&Debug['w'], "w", false, "disable DWARF generation")
obj.Flagstr("cpuprofile", "write cpu profile to `file`", &cpuprofile) flag.StringVar(&cpuprofile, "cpuprofile", "", "write cpu profile to `file`")
obj.Flagstr("memprofile", "write memory profile to `file`", &memprofile) flag.StringVar(&memprofile, "memprofile", "", "write memory profile to `file`")
obj.Flagint64("memprofilerate", "set runtime.MemProfileRate to `rate`", &memprofilerate) flag.Int64Var(&memprofilerate, "memprofilerate", 0, "set runtime.MemProfileRate to `rate`")
obj.Flagparse(usage) obj.Flagparse(usage)
startProfile() startProfile()
ctxt.Bso = ctxt.Bso ctxt.Bso = ctxt.Bso
ctxt.Debugvlog = int32(Debug['v']) if flagShared {
if flagShared != 0 {
if Buildmode == BuildmodeUnset { if Buildmode == BuildmodeUnset {
Buildmode = BuildmodeCShared Buildmode = BuildmodeCShared
} else if Buildmode != BuildmodeCShared { } else if Buildmode != BuildmodeCShared {
...@@ -161,7 +155,7 @@ func Ldmain() { ...@@ -161,7 +155,7 @@ func Ldmain() {
Exitf("-linkshared can only be used on elf systems") Exitf("-linkshared can only be used on elf systems")
} }
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "HEADER = -H%d -T0x%x -D0x%x -R0x%x\n", HEADTYPE, uint64(INITTEXT), uint64(INITDAT), uint32(INITRND)) fmt.Fprintf(ctxt.Bso, "HEADER = -H%d -T0x%x -D0x%x -R0x%x\n", HEADTYPE, uint64(INITTEXT), uint64(INITDAT), uint32(INITRND))
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -212,7 +206,7 @@ func Ldmain() { ...@@ -212,7 +206,7 @@ func Ldmain() {
ctxt.undef() ctxt.undef()
ctxt.hostlink() ctxt.hostlink()
ctxt.archive() ctxt.archive()
if Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f cpu time\n", obj.Cputime()) 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 symbols\n", len(ctxt.Allsym))
fmt.Fprintf(ctxt.Bso, "%d liveness data\n", liveness) fmt.Fprintf(ctxt.Bso, "%d liveness data\n", liveness)
......
...@@ -226,7 +226,7 @@ func putplan9sym(ctxt *Link, x *Symbol, s string, t int, addr int64, size int64, ...@@ -226,7 +226,7 @@ func putplan9sym(ctxt *Link, x *Symbol, s string, t int, addr int64, size int64,
'Z', 'Z',
'm': 'm':
l := 4 l := 4
if HEADTYPE == obj.Hplan9 && SysArch.Family == sys.AMD64 && Debug['8'] == 0 { if HEADTYPE == obj.Hplan9 && SysArch.Family == sys.AMD64 && !Debug['8'] {
Lputb(uint32(addr >> 32)) Lputb(uint32(addr >> 32))
l = 8 l = 8
} }
......
...@@ -183,7 +183,7 @@ func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 { ...@@ -183,7 +183,7 @@ func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
} }
func asmb(ctxt *ld.Link) { func asmb(ctxt *ld.Link) {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -201,7 +201,7 @@ func asmb(ctxt *ld.Link) { ...@@ -201,7 +201,7 @@ func asmb(ctxt *ld.Link) {
} }
if ld.Segrodata.Filelen > 0 { if ld.Segrodata.Filelen > 0 {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -210,7 +210,7 @@ func asmb(ctxt *ld.Link) { ...@@ -210,7 +210,7 @@ func asmb(ctxt *ld.Link) {
ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen)) ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
} }
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -226,9 +226,9 @@ func asmb(ctxt *ld.Link) { ...@@ -226,9 +226,9 @@ func asmb(ctxt *ld.Link) {
ld.Lcsize = 0 ld.Lcsize = 0
symo := uint32(0) symo := uint32(0)
if ld.Debug['s'] == 0 { if ld.Debug['s'] {
// TODO: rationalize // TODO: rationalize
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -247,7 +247,7 @@ func asmb(ctxt *ld.Link) { ...@@ -247,7 +247,7 @@ func asmb(ctxt *ld.Link) {
switch ld.HEADTYPE { switch ld.HEADTYPE {
default: default:
if ld.Iself { if ld.Iself {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
} }
ld.Asmelfsym(ctxt) ld.Asmelfsym(ctxt)
...@@ -276,7 +276,7 @@ func asmb(ctxt *ld.Link) { ...@@ -276,7 +276,7 @@ func asmb(ctxt *ld.Link) {
} }
ctxt.Cursym = nil ctxt.Cursym = nil
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -306,7 +306,7 @@ func asmb(ctxt *ld.Link) { ...@@ -306,7 +306,7 @@ func asmb(ctxt *ld.Link) {
} }
ld.Cflush() ld.Cflush()
if ld.Debug['c'] != 0 { if ld.Debug['c'] {
fmt.Printf("textsize=%d\n", ld.Segtext.Filelen) fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
fmt.Printf("datsize=%d\n", ld.Segdata.Filelen) fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen) fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
......
...@@ -804,7 +804,7 @@ func ensureglinkresolver(ctxt *ld.Link) *ld.Symbol { ...@@ -804,7 +804,7 @@ func ensureglinkresolver(ctxt *ld.Link) *ld.Symbol {
} }
func asmb(ctxt *ld.Link) { func asmb(ctxt *ld.Link) {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -822,7 +822,7 @@ func asmb(ctxt *ld.Link) { ...@@ -822,7 +822,7 @@ func asmb(ctxt *ld.Link) {
} }
if ld.Segrodata.Filelen > 0 { if ld.Segrodata.Filelen > 0 {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -831,7 +831,7 @@ func asmb(ctxt *ld.Link) { ...@@ -831,7 +831,7 @@ func asmb(ctxt *ld.Link) {
ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen)) ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
} }
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -847,9 +847,9 @@ func asmb(ctxt *ld.Link) { ...@@ -847,9 +847,9 @@ func asmb(ctxt *ld.Link) {
ld.Lcsize = 0 ld.Lcsize = 0
symo := uint32(0) symo := uint32(0)
if ld.Debug['s'] == 0 { if !ld.Debug['s'] {
// TODO: rationalize // TODO: rationalize
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -868,7 +868,7 @@ func asmb(ctxt *ld.Link) { ...@@ -868,7 +868,7 @@ func asmb(ctxt *ld.Link) {
switch ld.HEADTYPE { switch ld.HEADTYPE {
default: default:
if ld.Iself { if ld.Iself {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
} }
ld.Asmelfsym(ctxt) ld.Asmelfsym(ctxt)
...@@ -897,7 +897,7 @@ func asmb(ctxt *ld.Link) { ...@@ -897,7 +897,7 @@ func asmb(ctxt *ld.Link) {
} }
ctxt.Cursym = nil ctxt.Cursym = nil
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -923,7 +923,7 @@ func asmb(ctxt *ld.Link) { ...@@ -923,7 +923,7 @@ func asmb(ctxt *ld.Link) {
} }
ld.Cflush() ld.Cflush()
if ld.Debug['c'] != 0 { if ld.Debug['c'] {
fmt.Printf("textsize=%d\n", ld.Segtext.Filelen) fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
fmt.Printf("datsize=%d\n", ld.Segdata.Filelen) fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen) fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
......
...@@ -146,7 +146,7 @@ func archinit(ctxt *ld.Link) { ...@@ -146,7 +146,7 @@ func archinit(ctxt *ld.Link) {
case obj.Hlinux: /* ppc64 elf */ case obj.Hlinux: /* ppc64 elf */
if ld.SysArch == sys.ArchPPC64 { if ld.SysArch == sys.ArchPPC64 {
ld.Debug['d'] = 1 // TODO(austin): ELF ABI v1 not supported yet ld.Debug['d'] = true // TODO(austin): ELF ABI v1 not supported yet
} }
ld.Elfinit(ctxt) ld.Elfinit(ctxt)
ld.HEADR = ld.ELFRESERVE ld.HEADR = ld.ELFRESERVE
......
...@@ -499,7 +499,7 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -499,7 +499,7 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) {
} }
func asmb(ctxt *ld.Link) { func asmb(ctxt *ld.Link) {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -517,7 +517,7 @@ func asmb(ctxt *ld.Link) { ...@@ -517,7 +517,7 @@ func asmb(ctxt *ld.Link) {
} }
if ld.Segrodata.Filelen > 0 { if ld.Segrodata.Filelen > 0 {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -526,7 +526,7 @@ func asmb(ctxt *ld.Link) { ...@@ -526,7 +526,7 @@ func asmb(ctxt *ld.Link) {
ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen)) ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
} }
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -542,11 +542,11 @@ func asmb(ctxt *ld.Link) { ...@@ -542,11 +542,11 @@ func asmb(ctxt *ld.Link) {
ld.Lcsize = 0 ld.Lcsize = 0
symo := uint32(0) symo := uint32(0)
if ld.Debug['s'] == 0 { if !ld.Debug['s'] {
if !ld.Iself { if !ld.Iself {
ctxt.Diag("unsupported executable format") ctxt.Diag("unsupported executable format")
} }
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -554,14 +554,14 @@ func asmb(ctxt *ld.Link) { ...@@ -554,14 +554,14 @@ func asmb(ctxt *ld.Link) {
symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND))) symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND)))
ld.Cseek(int64(symo)) ld.Cseek(int64(symo))
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
} }
ld.Asmelfsym(ctxt) ld.Asmelfsym(ctxt)
ld.Cflush() ld.Cflush()
ld.Cwrite(ld.Elfstrdat) ld.Cwrite(ld.Elfstrdat)
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
} }
...@@ -571,7 +571,7 @@ func asmb(ctxt *ld.Link) { ...@@ -571,7 +571,7 @@ func asmb(ctxt *ld.Link) {
} }
ctxt.Cursym = nil ctxt.Cursym = nil
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -584,7 +584,7 @@ func asmb(ctxt *ld.Link) { ...@@ -584,7 +584,7 @@ func asmb(ctxt *ld.Link) {
} }
ld.Cflush() ld.Cflush()
if ld.Debug['c'] != 0 { if ld.Debug['c'] {
fmt.Printf("textsize=%d\n", ld.Segtext.Filelen) fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
fmt.Printf("datsize=%d\n", ld.Segdata.Filelen) fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen) fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
......
...@@ -614,7 +614,7 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) { ...@@ -614,7 +614,7 @@ func addgotsym(ctxt *ld.Link, s *ld.Symbol) {
} }
func asmb(ctxt *ld.Link) { func asmb(ctxt *ld.Link) {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -633,7 +633,7 @@ func asmb(ctxt *ld.Link) { ...@@ -633,7 +633,7 @@ func asmb(ctxt *ld.Link) {
} }
if ld.Segrodata.Filelen > 0 { if ld.Segrodata.Filelen > 0 {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -642,7 +642,7 @@ func asmb(ctxt *ld.Link) { ...@@ -642,7 +642,7 @@ func asmb(ctxt *ld.Link) {
ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen)) ld.Datblk(ctxt, int64(ld.Segrodata.Vaddr), int64(ld.Segrodata.Filelen))
} }
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f datblk\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -662,9 +662,9 @@ func asmb(ctxt *ld.Link) { ...@@ -662,9 +662,9 @@ func asmb(ctxt *ld.Link) {
ld.Spsize = 0 ld.Spsize = 0
ld.Lcsize = 0 ld.Lcsize = 0
symo := uint32(0) symo := uint32(0)
if ld.Debug['s'] == 0 { if !ld.Debug['s'] {
// TODO: rationalize // TODO: rationalize
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
...@@ -690,7 +690,7 @@ func asmb(ctxt *ld.Link) { ...@@ -690,7 +690,7 @@ func asmb(ctxt *ld.Link) {
switch ld.HEADTYPE { switch ld.HEADTYPE {
default: default:
if ld.Iself { if ld.Iself {
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
} }
ld.Asmelfsym(ctxt) ld.Asmelfsym(ctxt)
...@@ -717,7 +717,7 @@ func asmb(ctxt *ld.Link) { ...@@ -717,7 +717,7 @@ func asmb(ctxt *ld.Link) {
} }
case obj.Hwindows: case obj.Hwindows:
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
} }
...@@ -728,7 +728,7 @@ func asmb(ctxt *ld.Link) { ...@@ -728,7 +728,7 @@ func asmb(ctxt *ld.Link) {
} }
} }
if ld.Debug['v'] != 0 { if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f headr\n", obj.Cputime()) fmt.Fprintf(ctxt.Bso, "%5.2f headr\n", obj.Cputime())
} }
ctxt.Bso.Flush() ctxt.Bso.Flush()
......
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