}
func asmb(ctxt *ld.Link) {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
}
ctxt.Bso.Flush()
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f codeblk\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
if ld.Segrodata.Filelen > 0 {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ctxt.Bso.Flush()
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())
}
ctxt.Bso.Flush()
break
case obj.Hdarwin:
- ld.Debug['8'] = 1 /* 64-bit addresses */
+ ld.Debug['8'] = true /* 64-bit addresses */
case obj.Hlinux,
obj.Hfreebsd,
obj.Hopenbsd,
obj.Hdragonfly,
obj.Hsolaris:
- ld.Debug['8'] = 1 /* 64-bit addresses */
+ ld.Debug['8'] = true /* 64-bit addresses */
case obj.Hnacl,
obj.Hwindows:
ld.Spsize = 0
ld.Lcsize = 0
symo := int64(0)
- if ld.Debug['s'] == 0 {
- if ld.Debug['v'] != 0 {
+ if !ld.Debug['s'] {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
}
ctxt.Bso.Flush()
switch ld.HEADTYPE {
default:
case obj.Hplan9:
- ld.Debug['s'] = 1
+ ld.Debug['s'] = true
symo = int64(ld.Segdata.Fileoff + ld.Segdata.Filelen)
case obj.Hdarwin:
ld.Cflush()
ld.Cwrite(ld.Elfstrdat)
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
}
}
case obj.Hwindows:
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
}
}
}
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f headr\n", obj.Cputime())
}
ctxt.Bso.Flush()
case obj.Hnacl:
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.Funcalign = 32
if ld.INITTEXT == -1 {
}
func asmb(ctxt *ld.Link) {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
if ld.Segrodata.Filelen > 0 {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ctxt.Bso.Flush()
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())
}
ctxt.Bso.Flush()
ld.Lcsize = 0
symo := uint32(0)
- if ld.Debug['s'] == 0 {
+ if !ld.Debug['s'] {
// TODO: rationalize
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
}
ctxt.Bso.Flush()
switch ld.HEADTYPE {
default:
if ld.Iself {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
}
ctxt.Cursym = nil
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
ld.Cflush()
- if ld.Debug['c'] != 0 {
+ if ld.Debug['c'] {
fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
obj.Hfreebsd,
obj.Hnetbsd,
obj.Hopenbsd:
- ld.Debug['d'] = 0
+ ld.Debug['d'] = false
// with dynamic linking
ld.Elfinit(ctxt)
ld.HEADR = ld.ELFRESERVE
}
case obj.Hdarwin: /* apple MACH */
- ld.Debug['w'] = 1 // disable DWARF generation
+ ld.Debug['w'] = true // disable DWARF generation
ld.Machoinit()
ld.HEADR = ld.INITIAL_MACHO_HEADR
if ld.INITTEXT == -1 {
}
func asmb(ctxt *ld.Link) {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
if ld.Segrodata.Filelen > 0 {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ctxt.Bso.Flush()
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())
}
ctxt.Bso.Flush()
ld.Lcsize = 0
symo := uint32(0)
- if ld.Debug['s'] == 0 {
+ if !ld.Debug['s'] {
// TODO: rationalize
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
}
ctxt.Bso.Flush()
switch ld.HEADTYPE {
default:
if ld.Iself {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
}
ctxt.Cursym = nil
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
ld.Cflush()
- if ld.Debug['c'] != 0 {
+ if ld.Debug['c'] {
fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
}
case obj.Hdarwin: /* apple MACH */
- ld.Debug['w'] = 1 // disable DWARF generation
+ ld.Debug['w'] = true // disable DWARF generation
ld.Machoinit()
ld.HEADR = ld.INITIAL_MACHO_HEADR
if ld.INITTEXT == -1 {
if err != nil {
if os.IsNotExist(err) {
// 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)
}
return
}
func (ctxt *Link) reloc() {
- if Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f reloc\n", obj.Cputime())
}
ctxt.Bso.Flush()
func dynreloc(ctxt *Link, data *[obj.SXREF][]*Symbol) {
// -d suppresses dynamic loader format, so we may as well not
// compute these sections or mark their symbols as reachable.
- if Debug['d'] != 0 && HEADTYPE != obj.Hwindows {
+ if Debug['d'] && HEADTYPE != obj.Hwindows {
return
}
- if Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f reloc\n", obj.Cputime())
}
ctxt.Bso.Flush()
CodeblkPad(ctxt, addr, size, zeros[:])
}
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())
}
blk(ctxt, ctxt.Textp, addr, size, pad)
/* again for printing */
- if Debug['a'] == 0 {
+ if !Debug['a'] {
return
}
}
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())
}
blk(ctxt, datap, addr, size, zeros[:])
/* again for printing */
- if Debug['a'] == 0 {
+ if !Debug['a'] {
return
}
}
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())
}
var datap []*Symbol
func (ctxt *Link) dodata() {
- if Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dodata\n", obj.Cputime())
}
ctxt.Bso.Flush()
if len(data[obj.STLSBSS]) > 0 {
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.Align = int32(SysArch.PtrSize)
sect.Vaddr = 0
//
// Any unreached text symbols are removed from ctxt.Textp.
func deadcode(ctxt *Link) {
- if Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f deadcode\n", obj.Cputime())
}
if r.Sym.Attr.Reachable() {
r.Type = obj.R_ADDROFF
} else {
- if Debug['v'] > 1 {
+ if d.ctxt.Debugvlog > 1 {
fmt.Fprintf(d.ctxt.Bso, "removing method %s\n", r.Sym.Name)
}
r.Sym = nil
s := d.markQueue[0]
d.markQueue = d.markQueue[1:]
if s.Type == obj.STEXT {
- if Debug['v'] > 1 {
+ if d.ctxt.Debugvlog > 1 {
fmt.Fprintf(d.ctxt.Bso, "marktext %s\n", s.Name)
}
if s.FuncInfo != nil {
if strings.HasPrefix(s.Name, "type.") && s.Name[5] != '.' {
if decodetype_kind(s)&kindMask == kindInterface {
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)
}
d.ifaceMethod[sig] = true
*
*/
func dwarfgeneratedebugsyms(ctxt *Link) {
- if Debug['w'] != 0 { // disable dwarf
+ if Debug['w'] { // disable dwarf
return
}
- if Debug['s'] != 0 && HEADTYPE != obj.Hdarwin {
+ if Debug['s'] && HEADTYPE != obj.Hdarwin {
return
}
if HEADTYPE == obj.Hplan9 {
}
}
- if Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
}
* Elf.
*/
func dwarfaddshstrings(ctxt *Link, shstrtab *Symbol) {
- if Debug['w'] != 0 { // disable dwarf
+ if Debug['w'] { // disable dwarf
return
}
// Add section symbols for DWARF debug info. This is called before
// dwarfaddelfheaders.
func dwarfaddelfsectionsyms(ctxt *Link) {
- if Debug['w'] != 0 { // disable dwarf
+ if Debug['w'] { // disable dwarf
return
}
if Linkmode != LinkExternal {
* Windows PE
*/
func dwarfaddpeheaders(ctxt *Link) {
- if Debug['w'] != 0 { // disable dwarf
+ if Debug['w'] { // disable dwarf
return
}
for sect := Segdwarf.Sect; sect != nil; sect = sect.Next {
// binutils could correctly calculate PT_TLS size.
// see https://golang.org/issue/5200.
if HEADTYPE != obj.Hopenbsd {
- if Debug['d'] == 0 || Linkmode == LinkExternal {
+ if !Debug['d'] || Linkmode == LinkExternal {
Addstring(ctxt, shstrtab, ".tbss")
}
}
Addstring(ctxt, shstrtab, relro_prefix+".gopclntab")
if Linkmode == LinkExternal {
- Debug['d'] = 1
+ Debug['d'] = true
Addstring(ctxt, shstrtab, elfRelType+".text")
Addstring(ctxt, shstrtab, elfRelType+".rodata")
Addstring(ctxt, shstrtab, elfRelType+".init_array")
}
- if Debug['s'] == 0 {
+ if !Debug['s'] {
Addstring(ctxt, shstrtab, ".symtab")
Addstring(ctxt, shstrtab, ".strtab")
dwarfaddshstrings(ctxt, 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, ".hash")
Addstring(ctxt, shstrtab, ".got")
Segtext.Filelen += uint64(o)
}
- if Debug['d'] == 0 { /* -d suppresses dynamic loader format */
+ if !Debug['d'] { /* -d suppresses dynamic loader format */
/* interpreter */
sh := elfshname(ctxt, ".interp")
elfphload(ctxt, &Segdata)
/* Dynamic linking sections */
- if Debug['d'] == 0 {
+ if !Debug['d'] {
sh := elfshname(ctxt, ".dynsym")
sh.type_ = SHT_DYNSYM
sh.flags = SHF_ALLOC
eh.shstrndx = uint16(sh.shnum)
// put these sections early in the list
- if Debug['s'] == 0 {
+ if !Debug['s'] {
elfshname(ctxt, ".symtab")
elfshname(ctxt, ".strtab")
}
sh.flags = 0
}
- if Debug['s'] == 0 {
+ if !Debug['s'] {
sh := elfshname(ctxt, ".symtab")
sh.type_ = SHT_SYMTAB
sh.off = uint64(symo)
a += int64(elfwritehdr())
a += int64(elfwritephdrs())
a += int64(elfwriteshdrs())
- if Debug['d'] == 0 {
+ if !Debug['d'] {
a += int64(elfwriteinterp(ctxt))
}
if Linkmode != LinkExternal {
func ldpkg(ctxt *Link, f *bio.Reader, pkg string, length int64, filename string, whence int) {
var p0, p1 int
- if Debug['g'] != 0 {
+ if Debug['g'] {
return
}
if int64(int(length)) != length {
fmt.Fprintf(os.Stderr, "%s: too much pkg data in %s\n", os.Args[0], filename)
- if Debug['u'] != 0 {
+ if Debug['u'] {
errorexit()
}
return
bdata := make([]byte, length)
if _, err := io.ReadFull(f, bdata); err != nil {
fmt.Fprintf(os.Stderr, "%s: short pkg read %s\n", os.Args[0], filename)
- if Debug['u'] != 0 {
+ if Debug['u'] {
errorexit()
}
return
if pkg == "main" && !isMain {
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)
}
}
i := strings.IndexByte(data[p0+1:], '\n')
if i < 0 {
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()
}
return
}
if p1 < 0 {
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()
}
return
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)
nerrors++
return
goto err
}
- if Debug['I'] == 0 {
+ if !Debug['I'] {
if interpreter != "" && interpreter != f[1] {
fmt.Fprintf(os.Stderr, "%s: conflict dynlinker: %s and %s\n", os.Args[0], interpreter, f[1])
nerrors++
}
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)
}
}
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)
}
var (
Thearch Arch
- Debug [128]int
+ Debug [128]bool
Lcsize int32
rpath Rpath
Spsize int32
elfglobalsymndx int
flag_dumpdep bool
flag_installsuffix string
- flag_race int
- flag_msan int
+ flag_race bool
+ flag_msan bool
Buildmode BuildMode
Linkshared bool
tracksym string
extldflags string
extar string
libgccfile string
- debug_s int // backup old value of debug['s']
+ debug_s bool // backup old value of debug['s']
HEADR int32
HEADTYPE int32
- INITRND int32
+ INITRND int
INITTEXT int64
INITDAT int64
INITENTRY string /* entry point */
if flag_installsuffix != "" {
suffixsep = "_"
suffix = flag_installsuffix
- } else if flag_race != 0 {
+ } else if flag_race {
suffixsep = "_"
suffix = "race"
- } else if flag_msan != 0 {
+ } else if flag_msan {
suffixsep = "_"
suffix = "msan"
}
for i := 0; i < len(ctxt.Libdir); i++ {
if Linkshared {
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)
}
if _, err := os.Stat(shlibname); err == nil {
}
}
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)
}
if _, err := os.Stat(pname); err == nil {
if SysArch.Family == sys.ARM {
loadinternal(ctxt, "math")
}
- if flag_race != 0 {
+ if flag_race {
loadinternal(ctxt, "runtime/race")
}
- if flag_msan != 0 {
+ if flag_msan {
loadinternal(ctxt, "runtime/msan")
}
for i = 0; i < len(ctxt.Library); i++ {
iscgo = iscgo || ctxt.Library[i].Pkg == "runtime/cgo"
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)
}
objfile(ctxt, ctxt.Library[i])
for i = 0; i < len(ctxt.Library); i++ {
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)
}
ldshlibsyms(ctxt, ctxt.Library[i].Shlib)
}
// Force external linking for msan.
- if flag_msan != 0 {
+ if flag_msan {
Linkmode = LinkExternal
}
}
}
args := hostlinkArchArgs()
args = append(args, "--print-libgcc-file-name")
- if Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%s %v\n", extld, args)
}
out, err := exec.Command(extld, args...).Output()
if err != nil {
- if Debug['v'] != 0 {
+ 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)
}
switch Buildmode {
case BuildmodeExe, BuildmodePIE:
if havedynamic == 0 && HEADTYPE != obj.Hdarwin && HEADTYPE != obj.Hsolaris {
- Debug['d'] = 1
+ Debug['d'] = true
}
}
func objfile(ctxt *Link, lib *Library) {
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)
}
ctxt.Bso.Flush()
// and turn off -s internally: the external linker needs the symbol
// information for its final link.
debug_s = Debug['s']
- Debug['s'] = 0
+ Debug['s'] = false
// create temporary directory and arrange cleanup
if tmpdir == "" {
argv = append(argv, filepath.Join(tmpdir, "go.o"))
argv = append(argv, hostobjCopy()...)
- if Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "archive: %s\n", strings.Join(argv, " "))
ctxt.Bso.Flush()
}
argv = append(argv, extld)
argv = append(argv, hostlinkArchArgs()...)
- if Debug['s'] == 0 && debug_s == 0 {
+ if !Debug['s'] && !debug_s {
argv = append(argv, "-gdwarf-2")
} else {
argv = append(argv, "-s")
}
}
- sanitizers := flag_race != 0
+ sanitizers := flag_race
for _, flag := range ldflag {
if strings.HasPrefix(flag, "-fsanitize=") {
argv = append(argv, peimporteddlls()...)
}
- if Debug['v'] != 0 {
+ if l.Debugvlog != 0 {
fmt.Fprintf(l.Bso, "host link:")
for _, v := range argv {
fmt.Fprintf(l.Bso, " %q", v)
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 Debug['v'] != 0 && len(out) > 0 {
+ } else if l.Debugvlog != 0 && len(out) > 0 {
fmt.Fprintf(l.Bso, "%s", out)
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.
if !SysArch.InFamily(sys.ARM, sys.ARM64) {
dsym := filepath.Join(tmpdir, "go.dwarf")
t := fmt.Sprintf("%s %s %s ", goos, obj.Getgoarch(), obj.Getgoversion())
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)
return nil
}
}
func setinterp(s string) {
- Debug['I'] = 1 // denote cmdline interpreter override
+ Debug['I'] = true // denote cmdline interpreter override
interpreter = s
}
// Otherwise, off is addressing the saved program counter.
// 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))
}
ctxt.Bso.Flush()
}
func (ctxt *Link) callgraph() {
- if Debug['c'] == 0 {
+ if !Debug['c'] {
return
}
}
fmt.Printf("%s%s%s\n", tn, sep, fmt.Sprintf(format, args...))
nerrors++
- if Debug['h'] != 0 {
+ if Debug['h'] {
panic("error")
}
if nerrors > 20 {
Goarm int32
Headtype int
Arch *sys.Arch
- Debugvlog int32
+ Debugvlog int
Bso *bufio.Writer
Windows int32
Goroot string
}
func (ctxt *Link) domacho() {
- if Debug['d'] != 0 {
+ if Debug['d'] {
return
}
}
/* dwarf */
- if Debug['w'] == 0 {
+ if !Debug['w'] {
if Linkmode != LinkExternal {
ms = newMachoSeg("__DWARF", 20)
ms.vaddr = Segdwarf.Vaddr
}
}
- if Debug['d'] == 0 {
+ if !Debug['d'] {
// must match domacholink below
s1 := Linklookup(ctxt, ".machosymtab", 0)
s2 := Linklookup(ctxt, ".linkedit.plt", 0)
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)
}
}
// write COFF symbol table
var symcnt int
- if Debug['s'] == 0 || Linkmode == LinkExternal {
+ if !Debug['s'] || Linkmode == LinkExternal {
symcnt = writePESymTableRecords(ctxt)
}
c = addinitarray(ctxt)
}
- if Debug['s'] == 0 {
+ if !Debug['s'] {
dwarfaddpeheaders(ctxt)
}
ctxt := linknew(SysArch)
ctxt.Bso = bufio.NewWriter(os.Stdout)
- Debug = [128]int{}
+ Debug = [128]bool{}
nerrors = 0
- outfile = ""
HEADTYPE = -1
- INITTEXT = -1
- INITDAT = -1
- INITRND = -1
- INITENTRY = ""
Linkmode = LinkAuto
// For testing behavior of go command when tools crash silently.
}
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.Flagcount("C", "check Go calls to C code", &Debug['C'])
- obj.Flagint64("D", "set data segment `address`", &INITDAT)
- obj.Flagstr("E", "set `entry` symbol name", &INITENTRY)
+ flag.BoolVar(&Debug['C'], "C", false, "check Go calls to C code")
+ flag.Int64Var(&INITDAT, "D", -1, "set data segment `address`")
+ flag.StringVar(&INITENTRY, "E", "", "set `entry` symbol name")
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("H", "set header `type`", setheadtype)
- obj.Flagint32("R", "set address rounding `quantum`", &INITRND)
- obj.Flagint64("T", "set text segment `address`", &INITTEXT)
+ flag.IntVar(&INITRND, "R", -1, "set address rounding `quantum`")
+ flag.Int64Var(&INITTEXT, "T", -1, "set text segment `address`")
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.Flagcount("a", "disassemble output", &Debug['a'])
- obj.Flagstr("buildid", "record `id` as Go toolchain build id", &buildid)
+ flag.BoolVar(&Debug['a'], "a", false, "disassemble output")
+ flag.StringVar(&buildid, "buildid", "", "record `id` as Go toolchain build id")
flag.Var(&Buildmode, "buildmode", "set build `mode`")
- obj.Flagcount("c", "dump call graph", &Debug['c'])
- obj.Flagcount("d", "disable dynamic executable", &Debug['d'])
+ flag.BoolVar(&Debug['c'], "c", false, "dump call graph")
+ flag.BoolVar(&Debug['d'], "d", false, "disable dynamic executable")
flag.BoolVar(&flag_dumpdep, "dumpdep", false, "dump symbol dependency graph")
- obj.Flagstr("extar", "archive program for buildmode=c-archive", &extar)
- obj.Flagstr("extld", "use `linker` when linking in external mode", &extld)
- obj.Flagstr("extldflags", "pass `flags` to external linker", &extldflags)
- obj.Flagcount("f", "ignore version mismatch", &Debug['f'])
- obj.Flagcount("g", "disable go package data checks", &Debug['g'])
- obj.Flagcount("h", "halt on error", &Debug['h'])
- obj.Flagstr("installsuffix", "set package directory `suffix`", &flag_installsuffix)
- obj.Flagstr("k", "set field tracking `symbol`", &tracksym)
- obj.Flagstr("libgcc", "compiler support lib for internal linking; use \"none\" to disable", &libgccfile)
+ flag.StringVar(&extar, "extar", "", "archive program for buildmode=c-archive")
+ flag.StringVar(&extld, "extld", "", "use `linker` when linking in external mode")
+ flag.StringVar(&extldflags, "extldflags", "", "pass `flags` to external linker")
+ flag.BoolVar(&Debug['f'], "f", false, "ignore version mismatch")
+ flag.BoolVar(&Debug['g'], "g", false, "disable go package data checks")
+ flag.BoolVar(&Debug['h'], "h", false, "halt on error")
+ flag.StringVar(&flag_installsuffix, "installsuffix", "", "set package directory `suffix`")
+ flag.StringVar(&tracksym, "k", "", "set field tracking `symbol`")
+ flag.StringVar(&libgccfile, "libgcc", "", "compiler support lib for internal linking; use \"none\" to disable")
obj.Flagfn1("linkmode", "set link `mode` (internal, external, auto)", setlinkmode)
flag.BoolVar(&Linkshared, "linkshared", false, "link against installed Go shared libraries")
- obj.Flagcount("msan", "enable MSan interface", &flag_msan)
- obj.Flagcount("n", "dump symbol table", &Debug['n'])
- obj.Flagstr("o", "write output to `file`", &outfile)
+ flag.BoolVar(&flag_msan, "msan", false, "enable MSan interface")
+ flag.BoolVar(&Debug['n'], "n", false, "dump symbol table")
+ flag.StringVar(&outfile, "o", "", "write output to `file`")
flag.Var(&rpath, "r", "set the ELF dynamic linker search `path` to dir1:dir2:...")
- obj.Flagcount("race", "enable race detector", &flag_race)
- obj.Flagcount("s", "disable symbol table", &Debug['s'])
- var flagShared int
+ flag.BoolVar(&flag_race, "race", false, "enable race detector")
+ flag.BoolVar(&Debug['s'], "s", false, "disable symbol table")
+ var flagShared bool
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)
- obj.Flagcount("u", "reject unsafe packages", &Debug['u'])
- obj.Flagcount("v", "print link trace", &Debug['v'])
- obj.Flagcount("w", "disable DWARF generation", &Debug['w'])
+ flag.StringVar(&tmpdir, "tmpdir", "", "use `directory` for temporary files")
+ flag.BoolVar(&Debug['u'], "u", false, "reject unsafe packages")
+ obj.Flagcount("v", "print link trace", &ctxt.Debugvlog)
+ flag.BoolVar(&Debug['w'], "w", false, "disable DWARF generation")
- obj.Flagstr("cpuprofile", "write cpu profile to `file`", &cpuprofile)
- obj.Flagstr("memprofile", "write memory profile to `file`", &memprofile)
- obj.Flagint64("memprofilerate", "set runtime.MemProfileRate to `rate`", &memprofilerate)
+ flag.StringVar(&cpuprofile, "cpuprofile", "", "write cpu profile to `file`")
+ flag.StringVar(&memprofile, "memprofile", "", "write memory profile to `file`")
+ flag.Int64Var(&memprofilerate, "memprofilerate", 0, "set runtime.MemProfileRate to `rate`")
obj.Flagparse(usage)
startProfile()
ctxt.Bso = ctxt.Bso
- ctxt.Debugvlog = int32(Debug['v'])
- if flagShared != 0 {
+ if flagShared {
if Buildmode == BuildmodeUnset {
Buildmode = BuildmodeCShared
} else if Buildmode != BuildmodeCShared {
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))
}
ctxt.Bso.Flush()
ctxt.undef()
ctxt.hostlink()
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, "%d symbols\n", len(ctxt.Allsym))
fmt.Fprintf(ctxt.Bso, "%d liveness data\n", liveness)
'Z',
'm':
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))
l = 8
}
}
func asmb(ctxt *ld.Link) {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
if ld.Segrodata.Filelen > 0 {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ctxt.Bso.Flush()
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())
}
ctxt.Bso.Flush()
ld.Lcsize = 0
symo := uint32(0)
- if ld.Debug['s'] == 0 {
+ if ld.Debug['s'] {
// TODO: rationalize
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
}
ctxt.Bso.Flush()
switch ld.HEADTYPE {
default:
if ld.Iself {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
}
ctxt.Cursym = nil
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
ld.Cflush()
- if ld.Debug['c'] != 0 {
+ if ld.Debug['c'] {
fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
}
func asmb(ctxt *ld.Link) {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
if ld.Segrodata.Filelen > 0 {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ctxt.Bso.Flush()
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())
}
ctxt.Bso.Flush()
ld.Lcsize = 0
symo := uint32(0)
- if ld.Debug['s'] == 0 {
+ if !ld.Debug['s'] {
// TODO: rationalize
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
}
ctxt.Bso.Flush()
switch ld.HEADTYPE {
default:
if ld.Iself {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
}
ctxt.Cursym = nil
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
ld.Cflush()
- if ld.Debug['c'] != 0 {
+ if ld.Debug['c'] {
fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
case obj.Hlinux: /* ppc64 elf */
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.HEADR = ld.ELFRESERVE
}
func asmb(ctxt *ld.Link) {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
if ld.Segrodata.Filelen > 0 {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ctxt.Bso.Flush()
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())
}
ctxt.Bso.Flush()
ld.Lcsize = 0
symo := uint32(0)
- if ld.Debug['s'] == 0 {
+ if !ld.Debug['s'] {
if !ld.Iself {
ctxt.Diag("unsupported executable format")
}
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
}
ctxt.Bso.Flush()
symo = uint32(ld.Rnd(int64(symo), int64(ld.INITRND)))
ld.Cseek(int64(symo))
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
ld.Cflush()
ld.Cwrite(ld.Elfstrdat)
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
}
}
ctxt.Cursym = nil
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f header\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
ld.Cflush()
- if ld.Debug['c'] != 0 {
+ if ld.Debug['c'] {
fmt.Printf("textsize=%d\n", ld.Segtext.Filelen)
fmt.Printf("datsize=%d\n", ld.Segdata.Filelen)
fmt.Printf("bsssize=%d\n", ld.Segdata.Length-ld.Segdata.Filelen)
}
func asmb(ctxt *ld.Link) {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f asmb\n", obj.Cputime())
}
ctxt.Bso.Flush()
}
if ld.Segrodata.Filelen > 0 {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f rodatblk\n", obj.Cputime())
}
ctxt.Bso.Flush()
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())
}
ctxt.Bso.Flush()
ld.Spsize = 0
ld.Lcsize = 0
symo := uint32(0)
- if ld.Debug['s'] == 0 {
+ if !ld.Debug['s'] {
// TODO: rationalize
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f sym\n", obj.Cputime())
}
ctxt.Bso.Flush()
switch ld.HEADTYPE {
default:
if ld.Iself {
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f elfsym\n", obj.Cputime())
}
ld.Asmelfsym(ctxt)
}
case obj.Hwindows:
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f dwarf\n", obj.Cputime())
}
}
}
- if ld.Debug['v'] != 0 {
+ if ctxt.Debugvlog != 0 {
fmt.Fprintf(ctxt.Bso, "%5.2f headr\n", obj.Cputime())
}
ctxt.Bso.Flush()